source: sasview/guiframe/statusbar.py @ dd66fbd

ESS_GUIESS_GUI_DocsESS_GUI_batch_fittingESS_GUI_bumps_abstractionESS_GUI_iss1116ESS_GUI_iss879ESS_GUI_iss959ESS_GUI_openclESS_GUI_orderingESS_GUI_sync_sascalccostrafo411magnetic_scattrelease-4.1.1release-4.1.2release-4.2.2release_4.0.1ticket-1009ticket-1094-headlessticket-1242-2d-resolutionticket-1243ticket-1249ticket885unittest-saveload
Last change on this file since dd66fbd was dd66fbd, checked in by Gervaise Alina <gervyh@…>, 15 years ago

status bar changed—-removed error from data remove

  • Property mode set to 100644
File size: 3.7 KB
Line 
1import wx
2class MyStatusBar(wx.StatusBar):
3    def __init__(self,*args,**kargs):
4         wx.StatusBar.__init__(self, *args,**kargs)
5         #Layout of status bar
6         self.SetFieldsCount(3) 
7         width,height = self.GetSize()
8         self.gauge = wx.Gauge(self, size=(-1,height-4),style= wx.GA_PROGRESSBAR)
9         rect = self.GetFieldRect(1)
10         self.gauge.SetPosition((rect.x+ 10, rect.y-2))
11         self.gauge.Hide()
12         #Progess
13
14         self.progress = 0       # Current progress value of the bar
15         self.timer = wx.Timer(self,-1) 
16         self.thread= None
17         #self.Bind(wx.EVT_TIMER,self.OnTimer, self.timer)
18         
19    def OnTimer(self, evt): 
20        """Update the progress bar while the timer is running
21        @param evt: wx.EVT_TIMER
22 
23        """ 
24        # Check stop flag that can be set from non main thread
25        if self.thread!=None and self.thread.isrunning():
26            self.set_progress()
27       
28    def set_progress(self):
29        self.gauge.Show(True)
30        if self.timer.IsRunning(): 
31            while(self.thread.isrunning()):
32                self.progress += 1
33               
34                # Update the Rqnge if it has changed
35                #if self.range >= 0 and self.range != self.gauge.GetRange():
36                #    self.gauge.SetRange(self.range)
37     
38                # Update the progress value if it is less than the range
39                if self.progress < self.gauge.GetRange()-20: 
40                    self.gauge.SetValue(int(self.progress)) 
41                else:
42                    self.gauge.SetValue(70) 
43                    self.progress =0
44                    self.timer.Stop()
45                    #self.gauge.Hide()
46            self.timer.Stop()
47            self.gauge.SetValue(90) 
48            self.progress =0
49           
50    def clear_gauge(self, msg=""):
51        self.timer.Stop()
52        self.SetStatusText( str(msg), 0)
53        self.progress =0
54        self.gauge.SetValue(0)
55        self.gauge.Hide() 
56         
57    def set_status(self, type=None,msg="", thread=None):
58        if type==None:
59            self.SetStatusText(str(msg),0)
60       
61        else:
62            self.thread= thread
63            if self.thread !=None:
64                self.gauge.Show(True)
65                if type.lower()=="start":
66                    self.SetStatusText( str(msg), 0)
67                    #self.timer.Start(1000)
68                    #print "went here"
69                    #self.set_progress()
70                    self.progress +=10
71                    if self.progress < self.gauge.GetRange()-20:
72                        self.gauge.SetValue(int(self.progress)) 
73                if  type.lower()=="update":
74                   
75                    self.timer.Stop()
76                    self.SetStatusText( str(msg), 0)
77                    self.progress +=10
78                    if self.progress < self.gauge.GetRange()-20:
79                        self.gauge.SetValue(int(self.progress)) 
80            if type.lower()=="stop":
81                print "it is complete"
82                self.gauge.Show(True)
83                self.timer.Stop()
84                self.SetStatusText( str(msg), 0)
85                self.progress =0
86                self.gauge.SetValue(90) 
87                   
88           
89   
90   
91if __name__ == "__main__":
92     app = wx.PySimpleApp()
93     frame= wx.Frame(None,wx.ID_ANY,'test frame')
94     statusBar= MyStatusBar(frame,wx.ID_ANY)
95     frame.SetStatusBar(statusBar)
96     frame.Show(True)
97     statusBar.SetStatusText("status text..")
98     statusBar.set_status( "progress","progessing")
99     
100     
101     app.MainLoop()
102
Note: See TracBrowser for help on using the repository browser.