如何使用tkinter在Python GUI中强制帧刷新/重绘?

时间:2014-10-22 05:32:20

标签: python user-interface tkinter

  • 当用户点击menubuttons时,会回调一个函数。
  • 我想要而不是调用函数,应该重绘框架区域(就像用户点击NEW CUSTOMER一样,应该绘制一个预订表单,如果用户点击了GUEST LIST,那么应该绘制一个guest列表表格。
  • 我想在每个框架中显示菜单栏。

class NewMenu(Frame):

def __init__(self,parent=None):
    Frame.__init__(self, parent)
    self.pack(expand=YES, fill=BOTH)
    self.createWidget()
    self.master.title("Hotel Ganga Maiya-Hotel_ERP")
    self.master.iconname("tkpython")

def createWidget(self):
    self.makeMenuBar()
    self.makeToolBar()
    L = Label(self, text='Welcome Back')
    L.config(relief=SUNKEN, width=100, height=20, bg='white')
    L.pack(expand=YES,fill=BOTH)

def makeToolBar(self):
    toolbar = Frame(self, cursor='hand2', relief=SUNKEN, bd=2)
    toolbar.pack(side=BOTTOM, fill=X)
    Button(toolbar, text='Quit', command=self.quit) .pack(side=RIGHT)
    Button(toolbar, text='Engage Room', command=self.greeting) .pack(side=LEFT)

def makeMenuBar(self):
    self.menubar = Menu(self.master)
    self.master.config(menu= self.menubar)
    self.bookRoomMenu()
    self.viewDataMenu()
    self.accountingMenu()
    self.imageMenu()
    self.billingMenu()

def bookRoomMenu(self):
    pulldown= Menu(self.menubar)
    pulldown.add_command(label='New Customer', command=self.notdone)
    pulldown.add_command(label= 'Old Customer', command=self.quit)
    self.menubar.add_cascade(label='Book Room', underline=0, menu=pulldown)

def viewDataMenu(self):
    pulldown = Menu(self.menubar)
    pulldown.add_command(label= 'Room Number Wise', command=self.notdone)
    pulldown.add_command(label= 'Room Category Wise' , command=self.greeting)
   # pulldown.add_separator()
   # pulldown.add_command(label='Delete', command=self.greeting)
    #pulldown.entryconfig(4, state=DISABLED)
    self.menubar.add_cascade(label='Booking History', underline=0, menu=pulldown)

def accountingMenu(self):
    pulldown= Menu(self.menubar)
    pulldown.add_command(label='Account Calculater', command=self.notdone)
    pulldown.add_command(label= 'Some thing', command=self.notdone)
    self.menubar.add_cascade(label='Accounting', underline=0, menu=pulldown)

def imageMenu(self):
     self.menubar.add_cascade(label='Guest list', underline=0, )
   # photoFiles = ('nike.png','adidas.png','Avira.png')
   # pulldown = Menu(self.menubar)
    #self.photoObjs=[]
    #for file in photoFiles:
      #  img = PhotoImage(file='C:/Users/CyberSurvillence/Documents/img/' + file)
       # pulldown.add_command(image=img, command=self.notdone)
       # self.photoObjs.append(img)

    #self.menubar.add_cascade(label='Guest List', underline=0, menu=pulldown)


def billingMenu(self):
    #pulldown= Menu(self.menubar)
   # pulldown.add_command(label='Account Calculater', command=self.notdone)
   # pulldown.add_command(label= 'Some thing', command=self.notdone)
    self.menubar.add_cascade(label='Billing', underline=0, )

def greeting(self):
    showinfo('greeting','Greeting')

def notdone(self):
    showerror('Not implemented','Not yet available')

def quit(self):
    if askyesno('Verity quit','Are you sure you want to quit?'):
        Frame.quit(self)

if __name__ == '__main__': NewMenu().mainloop()

`

0 个答案:

没有答案
相关问题