为什么小部件不显示?

时间:2018-12-12 21:41:54

标签: python-3.x tkinter

我正在尝试创建一个显示5 x 3网格的GUI,每个网格模块都填充有一个按钮。我创建了一个使GUI如下的类。运行此命令时,主窗口是我期望的样子,但是主窗口的左上角仅显示第一个小部件。第二个窗口小部件从不显示。我在互联网上浏览了所有内容,但没有任何效果。

class choice_3_gui(Frame):
    def __init__(self): # Create the choice 3 GUI #
        ### --- Frame --- ###
            # Get Screen Dimensions #
        screen_width = root.winfo_screenwidth()
        screen_height = root.winfo_screenheight()
            # Get GUI Dimensions #
        width = screen_width
        height = screen_height/2
            # Center the GUI #
        posx = (screen_width/2) - (width/2)
        posy = 0
            # Place the GUI #
        root.geometry('%dx%d+%d+%d' % (width, height, posx, posy))
        ### --- Buttons --- ###
            # Area of Park #
        area_of_park_button = Button(root, text='AREA OF PARK', bg='white', fg='black', command=lambda: option_3_choice(1))
        area_of_park_button.grid(row=0, column=0)
            # Survey Date #
        survey_date_button = Button(root, text='SURVEY DATE', bg='white', fg='black', command=lambda: option_3_choice(2))
        area_of_park_button.grid(row=0,column=1)

        @staticmethod
        def option_3_index_choice(var):
            global option_3_choice
            option_3_choice = var
            root.destroy()

0 个答案:

没有答案