1

我是初学者,最近开始使用 tkinter 库。我有一个程序:我在使用全局的函数中声明了 MainScreen,但它说没有定义 Name Mainscreen。请帮忙。

        import tkinter
        from tkinter import *

        start_screen = tkinter.Tk()
        start_screen.title("Start screen")
        start_screen.attributes('-fullscreen', True)


        def stop_start():
             start_screen.destroy()
             global MainScreen
             MainScreen = tkinter.Tk()
             MainScreen.title("Main Screen")
             MainScreen.attributes('-fullscreen', True)


        Label(start_screen, text=' ', height=20).pack(side='top')
        strt_btn = Button(start_screen, text="START", command=stop_start).pack(side='top')


        def x_btn_root():
             MainScreen.destroy()


        LabelFrame(MainScreen, width=1280, bg='gray').grid(row=0, column=0)
        Button(LabelFrame, text="X", highlightcolor='red', command=x_btn_root).pack(side='left')
        start_screen.mainloop()
4

0 回答 0