当updateCustomerList
完成列表更新后,我想刷新MainPage
,这样更新后的列表就会显示在MainPage
小部件上。在
我尝试过使用tk.show_frame(<frame>)
等等,但是由于函数本身没有绑定到主Tkinter框架本身或者甚至不是Tkinter对象,所以我不完全确定如何重新加载页面。有什么建议吗?在
下面的代码是我整个程序的一个片段:
customerList = [] #list is updated at the updateCustomerList function; global variable
class POS(tk.Tk):
def __init__(self,*args,**kwargs):
tk.Tk.__init__(self, *args, **kwargs)
container = tk.Frame(self)
container.pack(side = "top", fill = "both", expand = True)
container.grid_rowconfigure(0, weight = 1)
container.grid_columnconfigure(0, weight = 1)
self.frames = {}
for F in (ErrorPage, PaymentPage, MainPage):
frame = F(container, self)
self.frames[F] = frame
frame.grid(row=0, column = 0, sticky = "nsew")
#show frame here
class MainPage(tk.Frame):
def __init__(self, parent, controller):
tk.Frame.__init__(self,parent)
"""
Tkinter frame that I would like to "refresh" and use the new updated list
"""
frame5Button = ttk.Button(frame5, text = "Add Item", command = lambda: updateCustomerList(barCode, quantity))
frame5Button.grid(row = 0, column = 5, padx = 90, pady = 10)
#This button allows me to go into the updateCustomerList function
def updateCustomerList(barCode, quantity):
#some code to update a list
#when function finishes updating the list, I would like to go back to the MainPage Tk frame and reload all the widgets like labels and entry boxes using the updated customerList list
app = POS()
app.geometry("700x700")
app.resizable(False, False)
app.after(100, MasterFilePopUp)
app.mainloop()
只需删除并在内部重新创建
Mainframe
的实例,作为updateCustomerList
的最后一行:在POS机内添加“全球集装箱”(tk.tk.塔卡)在
^{pr2}$相关问题 更多 >
编程相关推荐