Tkinter spacing
Peter Otten
__peter__ at web.de
Tue Jan 26 11:39:46 EST 2016
high5storage at gmail.com wrote:
>> from tkinter import *
>> from tkinter import ttk
>>
>> root = Tk()
>> root.geometry("822x600+100+100")
>> nav_bar = ttk.Frame(root, borderwidth=2, relief='ridge', padding=(10, 3,
>> 10, 3))
>>
>> btn_first = ttk.Button(nav_bar, text='|<', width=4) # for buttons
>> root.mainloop()
>
> Hmm - this only gives me an empty window (no errors).
That's strange.
If you ran the script in Idle, try again from the commandline.
> What puzzles me that every book/site on tkinter strongly warns of mixing
> pack and grid managers...
You can mix pack and grid for one window, but you have to pick one layout
manager per parent widget:
top = Toplevel(root)
panel = Frame(top)
panel.pack(...)
# we picked pack() and now have to use it for all
# children of top
canvas = Canvas(top, ...)
canvas.pack(...) # must use pack() again
# we are free to pick a layout for panel
ok = Button(panel)
ok.grid(...)
# we picked grid() and now have to use it for all
# children of panel
cancel = Button(panel)
cancel.grid(...) # must use grid()
More information about the Python-list
mailing list