一堂课中出现的帧

时间:2019-05-24 20:34:57

标签: python class tkinter frame

我是使用Tkinter的新手,我需要帮助。我开始创建一个类,在主窗口顶部有一个框架,在底部有一个框架。当我在主驱动程序的python文件中调用该类时,好像框架不存在。我将顶部的蓝色和底部的红色上色以尝试看到任何东西,但我只看到一些蓝色弹出一秒钟,然后什么都没有,底部的红色也是如此。我知道我犯了一些愚蠢的错误,但我无法抓住它。任何帮助将不胜感激,谢谢。

from tkinter import *


class StockInventory:

    def __init__(self, master):
        master.title("Stock Inventory")
        master.geometry('{}x{}'.format(1250, 750))
        master.resizable(width=FALSE, height=FALSE)
        top_frame = Frame(master, height=100, width=1250, bg="blue")
        bottom_frame = Frame(master, height=550, width=1250, bg="red")
        top_frame.pack()
        bottom_frame.pack(side=BOTTOM)
        self.welcomeTitle = Label(top_frame, text="Welcome to the Inventory", bd=10, anchor=W)
        self.welcomeTitle.config(font=("Courier", 20))
        self.welcomeTitle.pack()
        self.status = Label(bottom_frame, text="Loading stock...", bd=1, relief=SUNKEN, anchor=W)
        self.status.pack(side=BOTTOM, fill=X)

----- main.py ------

from tkinter import *
from StockInventory import StockInventory

root = Tk()

inventory = StockInventory(root)

root.mainloop()

0 个答案:

没有答案