Я пытаюсь сделать графическое окно для своего кода на питоне, но я не знаю, как добавлять кнопки, и я смотрел сайты, и это не было для моего издания (3.2.3) У меня есть код сейчас, что-то не так с этим?Код Tkinter для GUI python
import tkinter
import tkinter as tk
root = tk.Tk()
root.title("Adventure game")
root.geometry("1820x1000")
root.mainloop()
class Window(Tk):
def __init__(self, parent):
Tk.__init__(self, parent)
self.parent = parent
self.initialize()
def initialize(self):
self.geometry("600x400+30+30")
wButton = Button(self, text='start', command = self.OnButtonClick())
wButton.pack()
def OnButtonClick(self):
top = Toplevel()
top.title("title")
top.geometry("300x150+30+30")
topButton = Button(top, text="OPTION_1", command = self.OnButtonPress())
topButton = Button(top, text="OPTION_2", command = self.OnButtonPress())
topButton.pack()
def OnButtonPress(self):
top = Toplevel()
top.title("title")
top.geometry("300x150+30+30")
topButton = Button(top, text="OPTION_1", command = self.destroy)
bottomButton = Button(top, text="OPTION_2", command = self.destroy)
topButton.pack()
* «Что-то не так с этим?» * - почему вы спрашиваете нас ?! Вы проверили * это? Это работает*? – jonrsharpe
нет, это подразумевает, что ему нужна помощь. – Luke
... что? Тогда в чем ваш вопрос? Пожалуйста, прочитайте [ask] и сократите это до [mcve], который демонстрирует *, какова фактическая проблема *. – jonrsharpe