我不能使用wx.ProgressDialog
,因爲我需要在對話框中添加額外的內容(暫停按鈕以及有關當前正在處理內容的信息)。是否有可以在我自己的對話框中使用的進度條控件?wxPython進度條
我當然可以自己畫一些簡單的東西,但由於該程序需要在Mac OS X,Windows和Linux上運行,如果進度條具有本機外觀,它會更好。
我不能使用wx.ProgressDialog
,因爲我需要在對話框中添加額外的內容(暫停按鈕以及有關當前正在處理內容的信息)。是否有可以在我自己的對話框中使用的進度條控件?wxPython進度條
我當然可以自己畫一些簡單的東西,但由於該程序需要在Mac OS X,Windows和Linux上運行,如果進度條具有本機外觀,它會更好。
怎麼樣wxGauge顯示水平或垂直的酒吧?
http://www.wxpython.org/docs/api/wx.Gauge-class.html
更完整的C++ DOC: http://docs.wxwidgets.org/2.6/wx_wxgauge.html#wxgauge
你總是可以創建自己的wx.Dialog的衍生物和使用分級機,在您需要的小工具加入。
這裏有一個從我的程序,例如:
class ProgressDialog(wx.Dialog):
"""
Shows a Progres Gauge while an operation is taking place. May be cancellable
which is possible when converting pdf/ps
"""
def __init__(self, gui, title, to_add=1, cancellable=False):
"""Defines a gauge and a timer which updates the gauge."""
wx.Dialog.__init__(self, gui, title=title,
style=wx.CAPTION)
self.gui = gui
self.count = 0
self.to_add = to_add
self.timer = wx.Timer(self)
self.gauge = wx.Gauge(self, range=100, size=(180, 30))
sizer = wx.BoxSizer(wx.VERTICAL)
sizer.Add(self.gauge, 0, wx.ALL, 10)
if cancellable:
cancel = wx.Button(self, wx.ID_CANCEL, _("&Cancel"))
cancel.SetDefault()
cancel.Bind(wx.EVT_BUTTON, self.on_cancel)
btnSizer = wx.StdDialogButtonSizer()
btnSizer.AddButton(cancel)
btnSizer.Realize()
sizer.Add(btnSizer, 0, wx.ALIGN_CENTER | wx.TOP | wx.BOTTOM, 10)
self.SetSizer(sizer)
sizer.Fit(self)
self.SetFocus()
self.Bind(wx.EVT_TIMER, self.on_timer, self.timer)
self.timer.Start(30)
def on_timer(self, event):
"""Increases the gauge's progress."""
self.count += self.to_add
self.gauge.SetValue(self.count)
if self.count > 100:
self.count = 0
def on_cancel(self, event):
"""Cancels the conversion process"""
# do whatever