Code: Alles auswählen
#!/usr/bin/env python
# -*- coding: UTF-8 -*-
# generated by wxGlade 0.4.1 on Sun Apr 1 22:37:09 2007
import wx
import time
class MainFrame(wx.Frame):
def __init__(self, *args, **kwds):
# begin wxGlade: MainFrame.__init__
kwds["style"] = wx.DEFAULT_FRAME_STYLE
wx.Frame.__init__(self, *args, **kwds)
self.button_start = wx.Button(self, 100, "Zeige Progressbar")
self.__set_properties()
self.__do_layout()
self.Bind(wx.EVT_BUTTON, self.ON_START, id=100)
# end wxGlade
def __set_properties(self):
# begin wxGlade: MainFrame.__set_properties
self.SetTitle("Main")
# end wxGlade
def __do_layout(self):
# begin wxGlade: MainFrame.__do_layout
sizer_main = wx.BoxSizer(wx.VERTICAL)
sizer_main.Add(self.button_start, 0, wx.ALL|wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL|wx.ADJUST_MINSIZE, 15)
self.SetAutoLayout(True)
self.SetSizer(sizer_main)
sizer_main.Fit(self)
sizer_main.SetSizeHints(self)
self.Layout()
# end wxGlade
def ON_START(self, event): # wxGlade: MainFrame.<event_handler>
#Code für das Fortschreiten der Progressbar
start_progress = Progress(self)
start_progress.Show()
start_progressbar = start_progress.progressbar
for i in range(101):
start_progressbar.SetValue(i)
wx.Dialog.RequestUserAttention(start_progress)
time.sleep(0.1)
# end of class MainFrame
class Progress(wx.Dialog):
def __init__(self, *args, **kwds):
# begin wxGlade: Progress.__init__
kwds["style"] = wx.DEFAULT_DIALOG_STYLE
wx.Dialog.__init__(self, *args, **kwds)
self.sizer_progress_staticbox = wx.StaticBox(self, -1, "Progress")
self.progressbar = wx.Gauge(self, -1, 100)
self.__set_properties()
self.__do_layout()
# end wxGlade
def __set_properties(self):
# begin wxGlade: Progress.__set_properties
self.SetTitle("Progress")
self.SetSize((500, 70))
self.progressbar.SetMinSize((480, 28))
# end wxGlade
def __do_layout(self):
# begin wxGlade: Progress.__do_layout
sizer_progress = wx.StaticBoxSizer(self.sizer_progress_staticbox, wx.VERTICAL)
sizer_progress.Add(self.progressbar, 0, wx.ALL|wx.EXPAND|wx.ADJUST_MINSIZE, 5)
self.SetAutoLayout(True)
self.SetSizer(sizer_progress)
sizer_progress.Fit(self)
sizer_progress.SetSizeHints(self)
self.Layout()
# end wxGlade
# end of class Progress
if __name__ == "__main__":
app = wx.PySimpleApp(0)
wx.InitAllImageHandlers()
mainframe = MainFrame(None, -1, "")
app.SetTopWindow(mainframe)
mainframe.Show()
app.MainLoop()
In die Schleife kann man dann für Bestimmte schritte dann bestimmte funktionen einbauen