Tkinter如何不断更新显示?

问题描述 投票:0回答:1

所以,我正在制作一个 UI,不断检查闪存驱动器是否插入电脑(仅用于测试)或 Raspberry Pi 4。但我遇到的问题是,当我移除或插入 USB 闪存驱动器

这是我尝试过的:

def __init__(self, parent, controller, bg):
    tk.Frame.__init__(self, parent)
    self.dir_path = "D:\\"
    self.controller = controller
    
    self.label_height = 100
    self.configure(bg = bg)
    self.gcode_list = []
    self.labels = []
    self.current_label_index = 0
    
    self.Run()

def Run(self):
    self.FileExplorerFrame()
    self.DisplayFiles()
    self.DisplaySelectionButtons()

这是实施的地方:

def __init__(self, parent, controller, bg):
    tk.Frame.__init__(self, parent)
    self.dir_path = "D:\\"
    self.controller = controller
    
    self.label_height = 100
    self.configure(bg = bg)
    self.gcode_list = []
    self.labels = []
    self.current_label_index = 0
 
    self.Run()

def Run(self):
    self.FileExplorerFrame()
    self.DisplayFiles()
    self.DisplaySelectionButtons()
python tkinter
1个回答
0
投票

据我所知,tk.mainloop()函数启动循环。你用过吗?

© www.soinside.com 2019 - 2024. All rights reserved.