【发布时间】:2021-09-14 18:53:09
【问题描述】:
我需要显示一个进度条来向用户指示正在发生的事情。我想在单击 CLASSIFY(如图所示)启动函数时显示它,然后该栏将在函数结束时消失。
这是函数:
pbar = ttk.Progressbar(gui1, orient="horizontal", length=300)
pbar.place(x=500, y=120)
def Classifyall():
pbar.start(15)
table = BeautifulTable()
table.column_headers = ["File Name", "File Format"]
directory_path = '/home/.../All files/*'
file_list = glob.glob(directory_path)
for file in file_list:
filepath, file_extention = os.path.splitext(file)
filename = filepath.rsplit('/', 1)[1]
table.append_row([filename, file_extention])
tx.insert(END, table)
pbar.stop()
在这里我创建了一个包含功能的菜单栏
tool_menu = Menu(menu)
menu.add_cascade(label="Tool", menu=tool_menu)
tool_menu.add_command(label="Classify", command=Classifyall)
【问题讨论】:
-
你是如何尝试实现进度条的?
-
它试过这个:从进度条导入时间 import ProgressBar pbar = ProgressBar() def job(): Code ....
-
edit 问题并包括您的尝试