[英]How to show the current window in Tkinter?
Hope you can help me with the following issue.希望您能帮助我解决以下问题。
I'm using the library tkinter and I have a main_screen main_screen= Tk()
which is looping with mainloop()
我正在使用库 tkinter 并且我有一个 main_screen
main_screen= Tk()
它与mainloop()
循环
Inside of the main_screen, there is a little data form where you need to type some necessary data.在 main_screen 内部,有一个小数据表单,您需要在其中键入一些必要的数据。 And at the end of the window, I have a button to open a second window.
在 window 的末尾,我有一个按钮可以打开第二个 window。
Once I click in that button, report_screen appears (See below in my code)一旦我点击那个按钮,就会出现report_screen(见下面我的代码)
The new window should appear with the command Toplevel()
and print a label that says Starting:新的 window 应该与命令
Toplevel()
一起出现,并打印一个 label,上面写着:
request_start = LabelFrame(report_screen, text="Starting...").pack()
then my program must run a process where it takes around 10 seconds to complete it.那么我的程序必须运行一个大约需要 10 秒才能完成的进程。
Let's suppose that my process is just this假设我的流程就是这样
time.sleep(10)
And finally, run the next line:最后,运行下一行:
request_done = LabelFrame(report_screen, text="Done").pack()
What is my problem?我的问题是什么?
The problem is that report_screen
doesnt appear until the process of 10 sec has finished, and appears with both labels "Starting..." and "Done" at the same time.问题是,
report_screen
直到 10 秒的过程完成后才会出现,并且同时出现两个标签“Starting...”和“Done”。
I don't want that, I require that report_screen
appears with the label "Starting", and then run the process, and when the process finished, add the "Done" label我不希望这样,我要求
report_screen
出现 label “Starting”,然后运行该过程,当该过程完成时,添加“Done” label
This is the part of my code where I have this issue这是我遇到此问题的代码的一部分
report_screen = Toplevel()
request_start = Label(report_screen, text="Starting...").pack()
time.sleep(10) #example of my process that takes around 10 seconds
request_done = Label(report_screen, text="Done").pack()
Using update()
method works to update whatever is in the screen使用
update()
方法可以更新屏幕中的任何内容
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.