简体   繁体   English

python的Tkinter中的Windows进度条

[英]Windows progress bar in python's Tkinter

Is there any way in python's Tkinter, bwidget or anything similar to show a Windwos' default progress bar? 有没有办法在python的Tkinter,bwidget或类似的东西显示Windwos的默认进度条? I already know the bwidget.ProgressBar, but it produces an ugly progress bar while I mean showing a valid windows progress bar - the green, glowing one: 我已经知道了bwidget.ProgressBar,但它产生了一个丑陋的进度条,而我的意思是显示一个有效的Windows进度条 - 绿色,发光的:

http://imageshack.us/photo/my-images/853/unledtph.png/ http://imageshack.us/photo/my-images/853/unledtph.png/

I need it because that way Windows will automatically show the progress of my program in the task bar. 我需要它,因为Windows会自动在任务栏中显示我的程序的进度。 Plus, it looks better. 而且,它看起来更好。

如果您使用的是现代(2.7+)版本的Tkinter,您可以尝试ttk.ProgressBar ,它是Tkinter的一部分。

You can install the pyttk module separately. 您可以单独安装pyttk模块。

from Tkinter import *
import ttk
root = Tk()
progressbar = ttk.Progressbar(orient=HORIZONTAL, length=200, mode='determinate')
progressbar.pack(side="bottom")
progressbar.start()
root.mainloop()

As far as the taskbar functionality, that is not available in Tkinter yet (at least to the best of my knowledge). 就任务栏功能而言,Tkinter尚未提供(至少据我所知)。 You'll need to make use of the Windows API for that. 您需要为此使用Windows API。 Although this question is for PyQt, the answers should prove helpful. 虽然这个问题适用于PyQt,但答案应该证明是有帮助的。 Hope it gets you started. 希望它能让你开始。

The simplest solution would appear to be to use themed Tk with the tkinter.ttk module included in Python 2.7 and 3.1. 最简单的解决方案似乎是使用主题Tk和Python 2.7和3.1中包含的tkinter.ttk模块。 The Progressbar widget is what you want. Progressbar小部件是您想要的。

Since you appear to be considering other frameworks you might look at Qt or wxWidgets which look native and have excellent Python bindings. 由于您似乎正在考虑使用其他框架,因此您可能会看到Qt或wxWidgets,它们看起来很原生且具有出色的Python绑定。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM