How to make a Tkinter widget always visible?
Miki
miki.tebeka at gmail.com
Wed Mar 12 18:34:48 EDT 2008
Hello Kevin,
> Please post the code you're using--it will be easier to help if we can
> see exactly what you are trying.
In a nutshell:
-------------------------------
import Tkinter as tk, tkFont
from tkMessageBox import showinfo, showerror
from os import popen
def main():
root = tk.Tk()
# Log window
tk.Label(root, text="Log:", anchor=tk.W).pack(fill=tk.X)
frame = tk.Frame(root)
scrollbar = tk.Scrollbar(frame)
scrollbar.pack(side=tk.RIGHT, fill=tk.Y)
log = tk.Text(frame, width=80)
log.config(state=tk.DISABLED)
log.pack(side=tk.LEFT, fill=tk.BOTH, expand=1)
scrollbar.config(command=log.yview)
frame.pack(fill=tk.BOTH, expand=1)
# Button frame
frame = tk.Frame(root)
update = tk.Button(frame, text="GO", command=lambda:
showinfo("OUCH"))
update.pack(side=tk.LEFT)
tk.Button(frame, text="Quit",
command=root.quit).pack(side=tk.LEFT)
frame.pack(fill=tk.X)
root.bind("<Escape>", lambda e: root.quit())
update.focus()
root.minsize(-1, 100)
root.mainloop()
if __name__ == "__main__":
main()
-------------------------------
When I pack the buttons frame first (using side=BOTTOM), it stays
visible at all times.
Thanks,
--
Miki <miki.tebeka at gmail.com>
http://pythonwise.blogspot.com
More information about the Python-list
mailing list