该项目赢得了';t在Tkinter Python中更改文本之间等待

该项目赢得了';t在Tkinter Python中更改文本之间等待,python,tkinter,label,config,Python,Tkinter,Label,Config,我想在标签中显示一段文本,但它将跳到第二个更改 def retrieveThickness(): try: t = float(width_input.get()) stsDesc2.config(text = "Now give me the THICKNESS of the specimen(mm)") OK_Button1.config(command = retrieveThickness)

我想在标签中显示一段文本,但它将跳到第二个更改

def retrieveThickness():
     try:              
         t = float(width_input.get())
         stsDesc2.config(text = "Now give me the THICKNESS of the specimen(mm)")
         OK_Button1.config(command = retrieveThickness)
         Crs_Sect = w * t
         time.sleep(0.1)
         stsDesc2.config(text = "The CROSS SECTION is " + str(Crs_Sect) + "mm squared")
         time.sleep(5)
         stsDesc2.config(text = "How many values do you want to calculate the stress for?")
     except ValueError:
         response = "Field can't be empty, have any letters or symbols other than ."
         errorLabel = tkinter.Label(stsWindow,
                                    text = response,
                                    font = ("Arial",10, "bold"))
         errorLabel.grid(row = 5, column = 0, sticky = "N", padx = 20, pady = 20)


当计算crs_截面时,它不会在标签上显示“横截面为”+str(crs_截面)+“mm平方”。它立即进入时间。睡眠(5),然后将标签更改为“你想计算多少压力值?”。

在这个网站上肯定有几十个这样的问题。当您执行
time.sleep(5)
时,您正在阻止tkinter刷新窗口。这是否回答了您的问题?