我尝试在 Google 中找到解决方案,但是所有的解决方案对我来说都不起作用,也许在这里我可以得到正确的答案。
我有以下代码:
from tkinter import *
class gui_main:
def __init__(self):
self.win_about = Tk() #creat new windows
self.win_about.title("About software") # Get title to new windows -> "About software"
self.win_about.geometry("400x120+600+200") # Get size to window
self.win_about.resizable(width=False, height=False) # Off option Increase / decrease window
lab = Label(self.win_about, text="""
welcome to app
For Enter to app click on button Next.
""", justify='center') # Create new text in the window
lab.place(x=-18, y=-11) # Position of text in window (x - up/down , y - left/right)
btn_next = Button(self.win_about, text="Next", fg="red", command=gui_main.screen_menu()) # Create new button
btn_next.place(x=350, y=90) # Position of button in window (x - up/down , y - left/right)
btn_exit = Button(self.win_about, text="Exit", fg="red", command=self.win_about.destroy) # Create new button
btn_exit.place(x=10, y=90) # Position of button in window (x - up/down , y - left/right)
self.win_about.mainloop() # Run the cod in loop
def screen_menu(self):
self.win_menu = Tk()
self.win_menu.title("Menu")
self.win_menu.geometry("500x500+400+400")
self.win_about.destroy()
self.win_menu.mainloop()
if __name__ == "__main__":
g = gui_main()
g.win_about()
我收到的错误信息如下:
Traceback (most recent call last): File "文件路径", line 42, in g = gui_main() File "文件路径", line 26, in init btn_next = Button(self.win_about, text="下一页", fg="红色", command=gui_main.screen_menu()) # 创建新的按钮 TypeError: screen_menu()缺少1个必需的位置参数:'self'
感谢您的帮助,我希望能找到解决方案。
Tk()
实例。 - acw1668command
是如何指定的。注意到了什么不同吗? - Karl Knechtel