Python:运行实时跟踪的GUI
如何将动态时间导入tkinter?import date.time函数将仅从运行该函数的特定时间导入数据。我希望代码运行一次,但仍然像循环一样收集时间数据。您可以创建一个线程,用实际时间上载变量Python:运行实时跟踪的GUI,python,user-interface,tkinter,pycharm,Python,User Interface,Tkinter,Pycharm,如何将动态时间导入tkinter?import date.time函数将仅从运行该函数的特定时间导入数据。我希望代码运行一次,但仍然像循环一样收集时间数据。您可以创建一个线程,用实际时间上载变量 def This_Thread(): def Start_Acq(): Eth_BG = sched.scheduler(time.time, time.sleep) def Configure(sc): # do your stuf
def This_Thread():
def Start_Acq():
Eth_BG = sched.scheduler(time.time, time.sleep)
def Configure(sc):
# do your stuff, for example:
now = datetime.datetime.now()
dt_string = now.strftime("%d/%m/%Y; %H:%M:%S")
DSP_BG.enter(Insert_Here_Your_Rate, Insert_Here_Your_Priority, Configure, (DSP_BG,))
DSP_BG.run()
Ethernet_thread = threading.Thread(target=Start_Acq)
Ethernet_thread.start()
是否要模拟时钟?使用
root.after(time,function)
在“time”毫秒后运行“function”。在这个函数中,您可以在之后再次运行,以获得不阻塞GUI的循环。在该函数中,您可以获取当前时间date.time
并使用它。在tkinter中的标签中使用之后的显示当前时间的示例: