
代码实现
import tkinter as tk
root = tk.Tk()
root.geometry()
for e, expand in enumerate([False, True]):
for f, fill in enumerate([None, tk.X, tk.Y, tk.BOTH]):
for s, side in enumerate([tk.TOP, tk.LEFT, tk.BOTTOM, tk.RIGHT]):
position = '+{}+{}'.format(s * 205 + 100 + e * 820, f * 235 + 100)
win = tk.Toplevel(root)
win.geometry('200x200'+position)
text = str("side='{}'\nfill='{}'\nexpand={}".format(side, fill, str(expand)))
tk.Label(win, text=text, bg=['#FF5555', '#55FF55'][e]).pack(side=side, fill=fill, expand=expand)
root.mainloop()
本文详细介绍了如何使用Python的Tkinter库来创建并动态调整窗口的位置、填充方式和扩展性,通过`Toplevel`和几何管理方法展示代码实现。
3233

被折叠的 条评论
为什么被折叠?



