Gui-Python 3-帧内框架-行4列

时间:2019-01-05 19:09:15

标签: python tkinter frame

几个小时以来,我尝试在其他框架中创建框架,以便有一个主框架,在其中找到带有图像的标签(标题),在另一个框架中找到3个按钮。

我尝试放置它们,以使所有内容都居中,但没有任何东西可以正确密封。

from tkinter import *

class FourInARow:

    def __init__(self, parent):
        self.__parent = parent
        self.__init_parent(self.__parent)

        menu_frame = Frame(self.__parent, bg="white", width = 1000, height = 800)
        menu_frame.pack()

        title_frame = Frame(menu_frame, borderwidth=2, bg= "green", width = 450, height = 150)
        title_frame.pack(side=TOP, pady=105)

        self.__create_label_title(title_frame)

        buttons_frame = Frame(menu_frame, borderwidth=2, bg ="grey", width = 450, height = 370)
        buttons_frame.pack(side=BOTTOM)

        self.__create_menu_buttons(buttons_frame)

    def __init_parent(self, parent):
        parent.wm_title("Four In A Row x BENKO")
        parent.config(width = 1000, height = 800)
        parent.resizable(0, 0)

    def __create_label_title(self, parent):
        label_title = Label(parent, text="FRAME TITLE", borderwidth=2, bg="green", width = 450, height = 150)
        label_title.pack()

    def __create_menu_buttons(self, parent):
        button1 = Button(parent, bg = "red", borderwidth=2, width = 150, height=150)
        button1.pack(side =LEFT)

        button2 = Button(parent, bg = "red", borderwidth=2, width = 150, height=150)
        button2.pack(side =RIGHT)

        button3 = Button(parent, bg = "red", borderwidth=2, width = 150, height=150)
        button3.pack(side =BOTTOM, pady = 70)

if __name__ == '__main__':
    root = Tk()
    FourInARow(root)
    root.mainloop()

0 个答案:

没有答案