【发布时间】:2014-12-21 20:05:24
【问题描述】:
我正在尝试创建一个在创建文件之前运行 ttk 进度条的函数。似乎Widget.after 导致了 APPCRASH,但我不知道为什么。请帮忙!
def FilePgBar(title, file):
if root:
root.withdraw()
boxRoot = Toplevel(master=root)
boxRoot.withdraw()
else:
boxRoot = Tk()
boxRoot.withdraw()
boxRoot.protocol('WM_DELETE_WINDOW', denyWindowManagerClose )
boxRoot.title(title)
boxRoot.iconname('Dialog')
boxRoot.geometry(rootWindowPosition)
boxRoot.minsize(400, 100)
pgBar = ttk.Progressbar(boxRoot, orient=HORIZONTAL, length=300, mode='indeterminate')
pgBar.grid(row=1, column=0)
pgBar.pack()
pgBar.start()
def checkfile():
if os.path.exists(file):
pgBar.stop()
pgBar.destroy()
boxRoot.deiconify()
boxRoot.mainloop()
boxRoot.destroy()
if root: root.deiconify()
else:
boxRoot.after(100, checkfile)
checkfile()
我想从其他脚本调用这个函数,所以我不确定使用类
编辑:我编辑了代码。我不再得到 APPCRASH,但运行程序时什么也没有发生。
【问题讨论】:
标签: windows python-3.x progress-bar ttk crash