python之tkinter入坑Pack

python 中写GUI界面还是有很多方法的,下面我就说说这个tkinter吧,感觉刚上手不久,感觉不好用的样子,可能是我自己的原因导致的用不顺手。这篇主要写tkinter的pack()方法。

tkinter 的pack()可以设置的属性

  • 我从官网帮助手册中看到的是这样

pack_configure(self, cnf={}, **kw)Pack a widget in the parent widget. Use as options:

after=widget - pack it after you have packed widget
anchor=NSEW (or subset) - position widget according to
                          given direction
before=widget - pack it before you will pack widget
expand=bool - expand widget if parent size grows
fill=NONE or X or Y or BOTH - fill widget if widget grows
in=master - use master to contain this widget
in_=master - see 'in' option description
ipadx=amount - add internal padding in x direction
ipady=amount - add internal padding in y direction
padx=amount - add padding in x direction
pady=amount - add padding in y direction
side=TOP or BOTTOM or LEFT or RIGHT -  where to add this widget.
  • 上面的部分中文意思是说

iqo2If.png
  • 上面的界面代码如下

iqoWi8.png

Last updated

Was this helpful?