下面是一些示例代码。窗口没有调整大小(python3.2,在Mac上,从macports)。有没有办法可以修改它以便调整窗口大小?感谢。
import tkinter
import time
root = tkinter.Tk()
can = tkinter.Canvas(root, width = 10, height = 10)
can.pack()
for i in range(10):
can.configure(width = i * 50, height = i * 50)
root.update()
print(i)
time.sleep(0.5)
答案 0 :(得分:1)
也许试试这个:
import tkinter
import time
root = tkinter.Tk()
can = tkinter.Canvas(root, width = 10, height = 10)
can.rowconfigure(0, weight=1)
can.columnconfigure(0, weight=1)
can.grid()
root.rowconfigure(0, weight=1)
root.columnconfigure(0, weight=1)
for i in range(10):
can.configure(width = i * 50, height = i * 50)
root.update()
print(i)
time.sleep(0.5)