[Tkinter-discuss] pack(fill=Y) not working as expected

Beinan Li li.beinan at gmail.com
Mon Aug 7 04:56:46 EDT 2017


Hello Tkinter,

I was following a book example code as following:

import Tkinter as tk
root = tk.Tk()
tk.Button(root, text="A").pack(side=tk.LEFT, expand=tk.YES, fill=tk.Y)
tk.Button(root, text="B").pack(side=tk.TOP, expand=tk.YES, fill=tk.BOTH)
tk.Button(root, text="C").pack(side=tk.RIGHT, expand=tk.YES, fill=tk.NONE,
anchor = tk.NE)
tk.Button(root, text="D").pack(side=tk.LEFT, expand=tk.NO, fill=tk.Y)
tk.Button(root, text="E").pack(side=tk.TOP, expand=tk.NO, fill=tk.BOTH)
tk.Button(root, text="G").pack(side=tk.BOTTOM, expand=tk.YES, fill=tk.Y)
tk.Button(root, text="H").pack(side=tk.TOP, expand=tk.NO, fill=tk.BOTH)
tk.Button(root, text="I").pack(side=tk.RIGHT, expand=tk.NO)
tk.Button(root, text="J").pack(anchor=tk.SE)
root.mainloop()

I was expecting to get the result in the attached expected.png,
but got what shows in got.png.

It seems that the fill option does not work as expected.
I tried with Python 2.7.13 on macOS Sierra.

What am I missing here?

Thanks,
Beinan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tkinter-discuss/attachments/20170807/a8f54eec/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: expected.png
Type: image/png
Size: 16424 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/tkinter-discuss/attachments/20170807/a8f54eec/attachment-0002.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: got.png
Type: image/png
Size: 65697 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/tkinter-discuss/attachments/20170807/a8f54eec/attachment-0003.png>


More information about the Tkinter-discuss mailing list