如何使此 特定 加载条形码同时显示百分比。有人也可以帮我把它放在TKInter窗口,然后关闭 特定的 TKInter窗口???
print 'LOADING'
toolbar_width = 40
for i in range(toolbar_width):
time.sleep(0.1) # do real work here
# update the bar
sys.stdout.write("-")
sys.stdout.flush()
sys.stdout.write("\n")
答案 0 :(得分:0)
根据您的代码,我看不到在任何地方打印的百分比。
您想如何同时打印?在哪里?
我个人看到了多种选择:
如果你想使用tkinter
,你应该首先创建你的脚本,然后尝试运行它,如果你遇到错误你可以问一个特定问题的特定错误的问题集。
正如布莱恩之前提到的,这是StackOverflow而不是某种" LetMeCodeThatForYou" 平台。不过,我会附上一些伪代码作为可以完成的提示。
您可以尝试使用某些tkinter代码:
import Tkinter as tk
class MyWidget(tk.Window):
def __init__(self, *args, **kwargs):
# [...] for real code there needs to be more in here...
self.percentage=tk.StringVar()
self.progressbarwidget=SomeWidget(self)
self.progressbarwidget.grid()
def increase_counter(step=1):
self.percentage.set("%s%%"%(int(self.percentage.get()[-1:])+step))
self.progessbarwidget.configure(width=width+step)
if self.percentage.get()=="100%":
#destroy the window / widget / whatever here...
self.destroy()
else:
self.after(1000, self.increase_counter)
在你的应用程序中使用这样的东西会同时更新两个值,百分比值和小部件的外观。
请注意,这是仅示例代码,某种暗示如何构建您想要的结构。