Changeset 32c0841 in sasview for guiframe/statusbar.py


Ignore:
Timestamp:
Nov 23, 2010 11:21:20 AM (13 years ago)
Author:
Gervaise Alina <gervyh@…>
Branches:
master, ESS_GUI, ESS_GUI_Docs, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_iss959, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc, costrafo411, magnetic_scatt, release-4.1.1, release-4.1.2, release-4.2.2, release_4.0.1, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
Children:
a54e4be
Parents:
4a2b054
Message:

working on pylint

File:
1 edited

Legend:

Unmodified
Added
Removed
  • guiframe/statusbar.py

    rd955bf19 r32c0841  
    22from wx import StatusBar as wxStatusB 
    33import wx.lib 
    4 from wx.lib import newevent 
     4#from wx.lib import newevent 
    55(MessageEvent, EVT_MESSAGE) = wx.lib.newevent.NewEvent() 
    66#numner of fields of the status bar  
     
    2020    """ 
    2121    def __init__(self, parent, *args, **kwargs): 
    22         wx.Panel.__init__(self, parent=parent,*args, **kwargs) 
     22        """ 
     23        """ 
     24        wx.Panel.__init__(self, parent=parent, *args, **kwargs) 
    2325        self.parent = parent 
    2426        self.sizer = wx.BoxSizer(wx.VERTICAL) 
     
    3133        self.SetSizer(self.sizer) 
    3234         
    33     def set_message(self, status=""):   
    34         msg = status+ "\n"   
     35    def set_message(self, status=""): 
     36        """ 
     37        """ 
     38        msg = status + "\n"   
    3539        self.msg_txt.AppendText(str(msg)) 
    3640         
     
    6367    """ 
    6468    def __init__(self, parent, *args, **kargs): 
    65          wxStatusB.__init__(self, parent, *args, **kargs) 
    66          """ 
     69        wxStatusB.__init__(self, parent, *args, **kargs) 
     70        """ 
    6771        Implement statusbar functionalities  
    68          """ 
    69          self.parent= parent 
    70          self.parent.SetStatusBarPane(MSG_POSITION) 
    71         
    72          #Layout of status bar 
    73          self.SetFieldsCount(NB_FIELDS)  
    74          self.SetStatusWidths([BUTTON_SIZE, -2, -1,BUTTON_SIZE]) 
    75          
    76          #display default message 
    77          self.msg_position = MSG_POSITION  
    78         
    79          #save the position of the gauge 
    80          width, height = self.GetSize() 
    81          self.gauge = wx.Gauge(self, size=(width/10,height-3), 
    82                                style= wx.GA_HORIZONTAL) 
    83           
    84          self.gauge.Hide() 
    85           
    86          #status bar icon 
    87          self.bitmap_bt_warning = wx.BitmapButton(self, -1, size=(BUTTON_SIZE,-1), 
     72        """ 
     73        self.parent = parent 
     74        self.parent.SetStatusBarPane(MSG_POSITION) 
     75        #Layout of status bar 
     76        self.SetFieldsCount(NB_FIELDS)  
     77        self.SetStatusWidths([BUTTON_SIZE, -2, -1, BUTTON_SIZE]) 
     78        #display default message 
     79        self.msg_position = MSG_POSITION  
     80        #save the position of the gauge 
     81        width, height = self.GetSize() 
     82        self.gauge = wx.Gauge(self, size=(width/10, height-3), 
     83                               style=wx.GA_HORIZONTAL) 
     84        self.gauge.Hide() 
     85        #status bar icon 
     86        self.bitmap_bt_warning = wx.BitmapButton(self, -1, 
     87                                                 size=(BUTTON_SIZE,-1), 
    8888                                                  style=wx.NO_BORDER) 
    89          console_bmp = wx.ArtProvider.GetBitmap(wx.ART_TIP, wx.ART_TOOLBAR) 
    90          self.bitmap_bt_console = wx.BitmapButton(self, -1,  
     89        console_bmp = wx.ArtProvider.GetBitmap(wx.ART_TIP, wx.ART_TOOLBAR) 
     90        self.bitmap_bt_console = wx.BitmapButton(self, -1,  
    9191                                 size=(BUTTON_SIZE-5, height-4)) 
    92          self.bitmap_bt_console.SetBitmapLabel(console_bmp) 
    93          console_hint = "History of status bar messages" 
    94          self.bitmap_bt_console.SetToolTipString(console_hint) 
    95          self.bitmap_bt_console.Bind(wx.EVT_BUTTON, self._onMonitor, 
     92        self.bitmap_bt_console.SetBitmapLabel(console_bmp) 
     93        console_hint = "History of status bar messages" 
     94        self.bitmap_bt_console.SetToolTipString(console_hint) 
     95        self.bitmap_bt_console.Bind(wx.EVT_BUTTON, self._onMonitor, 
    9696                                            id=self.bitmap_bt_console.GetId()) 
    97          self.reposition() 
    98          ## Current progress value of the bar  
    99          self.nb_start = 0 
    100          self.nb_progress = 0 
    101          self.nb_stop = 0 
    102           
    103          self.frame = None 
    104          self.list_msg = [] 
    105          self.progress = 0       
    106          self.timer = wx.Timer(self, -1)  
    107          self.timer_stop = wx.Timer(self, -1)  
    108          self.thread = None 
    109          self.Bind(wx.EVT_TIMER,self.OnTimer, self.timer)  
    110          self.Bind(wx.EVT_TIMER,self.OnTimer_stop, self.timer_stop)  
    111          self.Bind(wx.EVT_SIZE, self.OnSize) 
    112          self.Bind(wx.EVT_IDLE, self.OnIdle) 
     97        self.reposition() 
     98        ## Current progress value of the bar  
     99        self.nb_start = 0 
     100        self.nb_progress = 0 
     101        self.nb_stop = 0 
     102        self.frame = None 
     103        self.list_msg = [] 
     104        self.progress = 0       
     105        self.timer = wx.Timer(self, -1)  
     106        self.timer_stop = wx.Timer(self, -1)  
     107        self.thread = None 
     108        self.Bind(wx.EVT_TIMER, self._on_time, self.timer)  
     109        self.Bind(wx.EVT_TIMER, self._on_time_stop, self.timer_stop)  
     110        self.Bind(wx.EVT_SIZE, self.OnSize) 
     111        self.Bind(wx.EVT_IDLE, self.OnIdle) 
    113112         
    114113    def reposition(self): 
     
    116115        """ 
    117116        rect = self.GetFieldRect(GAUGE_POSITION) 
    118         self.gauge.SetPosition((rect.x+5, rect.y-2)) 
     117        self.gauge.SetPosition((rect.x + 5, rect.y - 2)) 
    119118        rect = self.GetFieldRect(ICON_POSITION) 
    120         self.bitmap_bt_warning.SetPosition((rect.x+5, rect.y-2)) 
     119        self.bitmap_bt_warning.SetPosition((rect.x + 5, rect.y - 2)) 
    121120        rect = self.GetFieldRect(CONSOLE_POSITION) 
    122         self.bitmap_bt_console.SetPosition((rect.x-5, rect.y-2)) 
     121        self.bitmap_bt_console.SetPosition((rect.x - 5, rect.y - 2)) 
    123122        self.sizeChanged = False 
    124123         
    125124    def OnIdle(self, event): 
     125        """ 
     126        """ 
    126127        if self.sizeChanged: 
    127128            self.reposition() 
    128129             
    129130    def OnSize(self, evt): 
     131        """ 
     132        """ 
    130133        self.reposition()  
    131134        self.sizeChanged = True 
     
    139142        """ 
    140143        """ 
    141         wxStatusB.SetStatusText(self, text, MSG_POSITION) 
     144        wxStatusB.SetStatusText(self, text, number) 
    142145        self.list_msg.append(text) 
    143         icon_bmp =  wx.ArtProvider.GetBitmap(wx.ART_INFORMATION, wx.ART_TOOLBAR) 
     146        icon_bmp = wx.ArtProvider.GetBitmap(wx.ART_INFORMATION, wx.ART_TOOLBAR) 
    144147        self.bitmap_bt_warning.SetBitmapLabel(icon_bmp) 
    145148        try: 
     
    153156    def PopStatusText(self, *args, **kwds): 
    154157        """ 
     158        Override status bar  
    155159        """ 
    156160        wxStatusB.PopStatusText(self, field=MSG_POSITION) 
     
    159163        """ 
    160164        """ 
    161         wxStatusB.PushStatusText(self, field=MSG_POSITION,string=string) 
     165        wxStatusB.PushStatusText(self, field=MSG_POSITION, string=string) 
    162166         
    163167    def enable_clear_gauge(self): 
    164168        """ 
     169        clear the progress bar 
    165170        """ 
    166171        flag = False 
    167         if (self.nb_start <= self.nb_stop) or (self.nb_progress <= self.nb_stop): 
     172        if (self.nb_start <= self.nb_stop) or \ 
     173            (self.nb_progress <= self.nb_stop): 
    168174            flag = True 
    169175        return flag 
    170176     
    171     def OnTimer_stop(self, evt):  
     177    def _on_time_stop(self, evt):  
    172178        """ 
    173179        Clear the progress bar 
     
    185191        self.nb_stop = 0 
    186192        
    187     def OnTimer(self, evt):  
     193    def _on_time(self, evt):  
    188194        """ 
    189195        Update the progress bar while the timer is running  
     
    219225            self.bitmap_bt_warning.SetBitmapLabel(icon_bmp) 
    220226        if msg == "info": 
    221             icon_bmp =  wx.ArtProvider.GetBitmap(wx.ART_INFORMATION, wx.ART_TOOLBAR) 
     227            icon_bmp =  wx.ArtProvider.GetBitmap(wx.ART_INFORMATION, 
     228                                                 wx.ART_TOOLBAR) 
    222229            self.bitmap_bt_warning.SetBitmapLabel(icon_bmp) 
    223230     
     
    237244        type = event.type 
    238245        self.gauge.Show(True) 
    239         if type.lower()=="start": 
     246        if type.lower() == "start": 
    240247            self.nb_start += 1 
    241248            self.timer.Stop() 
     
    243250            self.gauge.SetValue(int(self.progress))  
    244251            self.progress += 10 
    245             if self.progress < self.gauge.GetRange()-20: 
     252            if self.progress < self.gauge.GetRange() - 20: 
    246253                self.gauge.SetValue(int(self.progress))  
    247         if type.lower()=="progress": 
     254        if type.lower() == "progress": 
    248255            self.nb_progress += 1 
    249256            self.timer.Start(100) 
    250257            self.gauge.Pulse() 
    251         if type.lower()=="update": 
     258        if type.lower() == "update": 
    252259            self.progress += 10 
    253             if self.progress < self.gauge.GetRange()-20: 
     260            if self.progress < self.gauge.GetRange()- 20: 
    254261                self.gauge.SetValue(int(self.progress))    
    255         if type.lower()=="stop": 
     262        if type.lower() == "stop": 
    256263            self.nb_stop += 1 
    257264            self.gauge.Show(True) 
     
    278285    def _onMonitor(self, event): 
    279286        """ 
     287        Pop up a frame with messages sent to the status bar 
    280288        """ 
    281289        self.frame = Console(parent=self) 
    282          
    283290        self.frame.set_multiple_messages(self.list_msg) 
    284291        self.frame.Show(True) 
     
    286293         
    287294if __name__ == "__main__": 
    288      app = wx.PySimpleApp() 
    289      frame= wx.Frame(None,wx.ID_ANY,'test frame') 
    290      statusBar = StatusBar(frame, wx.ID_ANY) 
    291      frame.SetStatusBar(statusBar) 
    292      frame.Show(True) 
    293       
    294      event = MessageEvent() 
    295      event.type = "progress" 
    296      event.status  = "statusbar...." 
    297      event.info = "error" 
    298      statusBar.set_status(event=event) 
    299      app.MainLoop() 
     295    app = wx.PySimpleApp() 
     296    frame = wx.Frame(None, wx.ID_ANY, 'test frame') 
     297    statusBar = StatusBar(frame, wx.ID_ANY) 
     298    frame.SetStatusBar(statusBar) 
     299    frame.Show(True) 
     300    event = MessageEvent() 
     301    event.type = "progress" 
     302    event.status  = "statusbar...." 
     303    event.info = "error" 
     304    statusBar.set_status(event=event) 
     305    app.MainLoop() 
    300306 
Note: See TracChangeset for help on using the changeset viewer.