【问题标题】:How do I put a progress bar in a messagebox in tkinter in python?如何在 python 的 tkinter 的消息框中放置进度条?
【发布时间】:2011-12-24 03:50:15
【问题描述】:

我正在尝试在消息框中放置一个进度条来显示文件下载的进度;像这样:

(图片取自here。)

所以对于进度条,我将使用它:

pbar=ttk.Progressbar(app,orient='horizontal',length=200,mode='determinate')
pbar.pack()

也许我可以使用文本小部件,但我不太确定如何让这个新窗口出现。我会写这样的东西吗?

root1=Tk()
root1.title("Status Dialog")
pbar=ttk.Progressbar(app,orient='horizontal',length=200,mode='determinate')
pbar.pack()

root1.mainloop()

有什么想法吗?

【问题讨论】:

  • 您找到图像的页面包含源代码。看看就好。

标签: python user-interface tkinter


【解决方案1】:

我认为您有一个错误:在您的代码中,pbar=ttk.ProgressBar(app, ...) 应替换为 pbar=ttk.ProgressBar(root1, ...)。在这个类实例化中,第一个参数是父窗口小部件,我敢打赌它应该在你的代码中是root1

但正如 brc 在评论中所写,只要您不描述您的错误(例如,给我们 Traceback),我们就无法确定。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-12-17
    • 2011-09-17
    • 2015-11-08
    • 2019-08-30
    • 1970-01-01
    • 2020-10-07
    相关资源
    最近更新 更多