该程序不会在Tkinter Python中更改文本之间等待

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

我想在标签中显示一段文字,但是它将跳至第二个更改。

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_sect时,它不会在标签上显示“ CROSS SECTION is“ + str(Crs_Sect)+” mm squared“。它立即转到time.sleep(5),然后将标签更改为“您要计算多少压力?”。

python tkinter label config
1个回答
0
投票

没有所有代码就很难回答...是否已导入所需的库或模块?

例如:

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