Я пишу простой графический интерфейс ведьма содержит 5 экранов.Я хочу настроить базовый класс (tk.Frame
) и установить такие параметры, как геометрия, изменение размера, bg и т. Д. Как мне управлять этим в моем коде?
class FormApp(tk.Tk):
def __init__(self, *args, **kwargs):
tk.Tk.__init__(self, *args, *kwargs)
container = tk.Frame(self)
container.configure('%dx%d+%d+%d' % (XRes,YRes,
(ClientWidth-XRes)/2,
(ClientHeight-YRes)/2-20))
container.self.resizable(0, 0)
container.pack(side="top", fill="both", expand = True)
container.grid_rowconfigure(0, weight=0)
container.grid_columnconfigure(0, weight=0)
self.frames = {}
for F in (PageOne, PageTwo, PageThree, PageFour, PageFive):
frame=F(container, self)
self.frames[F]=frame
frame.grid(row=0, column=0, sticky="nsew")
self.show_frame(PageOne)
def show_frame(self, cont):
frame = self.frames[cont]
frame.tkraise()
Я получил ошибки:
Traceback (most recent call last): File "C:/Users/Vladimir/Desktop/python/!project/Five Windows.py", line 113, in <module>
app = FormApp() File "C:/Users/Vladimir/Desktop/python/!project/Five Windows.py", line 37, in __init__
(ClientHeight-YRes)/2-20)) File "C:\Program Files\Python36\lib\tkinter\__init__.py", line 1482, in configure
return self._configure('configure', cnf, kw) File "C:\Program Files\Python36\lib\tkinter\__init__.py", line 1472, in _configure
return self._getconfigure1(_flatten((self._w, cmd, '-'+cnf))) File "C:\Program Files\Python36\lib\tkinter\__init__.py", line 1460, in _getconfigure1
x = self.tk.splitlist(self.tk.call(*args))
_tkinter.TclError: unknown option "-700x960+610+40"
Не конфигурирует ли строка
container.configure('%dx%d+%d+%d' % (XRes,YRes,
(ClientWidth-XRes)/2,
(ClientHeight-YRes)/2-20))
контейнер?