至于提到的问题,我找不到任何可以修复 gui 窗口和所有标签、按钮等位置的代码。
import tkinter
import tkinter.messagebox
class Menu:
def __init__(self):
self.main = tkinter.Tk(height = 200, width = 400)
self.position = tkinter.Label(self.main, text = '123',\
bg = 'Purple',\
height = 2, width = 8)
self.position.place(height=50, width= 100)
self.position.pack()
tkinter.mainloop()
gui = Menu()
为此,我只能调整标签的大小,而不是主窗口的位置和大小。它给出了这个错误
Traceback (most recent call last):
File "C:\Python33\Saves\Label position.py", line 18, in <module>
gui = Menu()
File "C:\Python33\Saves\Label position.py", line 7, in __init__
self.main = tkinter.Tk(height = 200, width = 400)
TypeError: __init__() got an unexpected keyword argument 'height'