多重框架接口

时间:2019-06-27 14:07:21

标签: python tkinter pagination frames

我正在为患者护理机构设计一个应用程序。 在这里,我们必须注册患者,保存他们的检查并在需要时检索患者信息。 我想将GUI设计为三个单独的页面,但要保持顶部框架和左侧框架相同。我只想更改另一部分的内容。

我已经尝试过框架,笔记本和顶层。但没有成功。

class Window(object):
    def __init__(self,master):
        self.master = master
        #Title
        self.master.title("Phenotype Predictor")
        #Geometry and Position
        self.master.geometry('800x500+300+100')
        self.master.config(bg="#292C35")
        #set the resize option to false
        self.master.resizable(0,0)
        #call the widget function to create widgets
        self.AddWidgets()
    def AddWidgets(self):
        self.TopFrame = Frame(self.master,bg = "#32323A",width =600, height=100)
        self.TopFrame.grid(column =1, row=0)

        self.RightFrame = Frame(self.master,bg = "#32323A",width =200, height=400)
        self.RightFrame.grid(column =0, row=1,)

        self.LogoFrame = Frame(self.master,bg = "#323200",width =200, height=100)
        self.LogoFrame.grid(column =0, row=0,)

        self.HomePage = Frame(self.master,bg = "#fff",width =600, height=400) #home page
        self.HomePage.grid(column =1, row=1,)


        self.topic = Label(self.TopFrame,text="Phenotype Predictor",fg='#fff',bg="#32323A",font=('Tahoma',20))
        self.topic.place(relx=0.5, rely=0.5, anchor="center")

        self.logo = Label(self.LogoFrame,text="LOGO",fg='#fff',bg="#32323A",font=('Tahoma',20))
        self.logo.place(relx=0.5, rely=0.5, anchor="center")


        self.AddPt = Button(self.RightFrame,text = "New Patient", font=('Tahoma',12), width =20,height = 3, bd=0,bg = "#688FD2",\
                               activebackground = "#32323A", activeforeground="#42f498", fg = "#fff",command =call_frame)
        self.AddPt.grid(column=0, row=3,padx=10,pady=10)

        self.FindPt = Button(self.RightFrame,text = "Find Patient", font=('Tahoma',12), width =20,height = 3, bd=0,bg = "#688FD2",\
                               activebackground = "#32323A", activeforeground="#42f498", fg = "#fff",command ='')
        self.FindPt.grid(column=0, row=4,padx=10,pady=10)

        self.predict = Button(self.RightFrame,text = "Predict Phenotype", font=('Tahoma',12), width =20,height = 3, bd=0,bg = "#688FD2",\
                               activebackground = "#32323A", activeforeground="#42f498", fg = "#fff",command ='')
        self.predict.grid(column=0, row=5,padx=10,pady=10)


    def ShowHome(self):
        '''Show a frame for the given page name'''
        HomePage.tkraise()
        print ("Home")
    def call_frame(self):
        #self.HomePage = Frame(self.master,bg = "#000000",width =600, height=400) #home page
        #self.HomePage.grid(column =1, row=1,)
        print ('worked')




app=Tk() #creating a tk object
Window =Window(app) #creating a window object
app.mainloop()

这是我得到的错误:

Exception in Tkinter callback
Traceback (most recent call last):
  File "c:\users\admin\appdata\local\programs\python\python36\lib\tkinter\__init__.py", line 1705, in __call__
    return self.func(*args)
  File "<ipython-input-15-15053b016662>", line 2, in call_frame
    self.HomePage = Frame(self.master,bg = "#000000",width =600, height=400) #home page
NameError: name 'self' is not defined

0 个答案:

没有答案