Changeset 0250d2f in sasview
- Timestamp:
- Apr 12, 2010 3:56:37 PM (15 years ago)
- 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:
- f4fe424
- Parents:
- 8dcfb2e
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
guiframe/statusbar.py
r04349fe r0250d2f 3 3 import wx.lib 4 4 from wx.lib import newevent 5 (MessageEvent, EVT_MESSAGE) = wx.lib.newevent.NewEvent() 5 6 #numner of fields of the status bar 6 NB_FIELDS = 37 NB_FIELDS = 4 7 8 #position of the status bar's fields 8 9 ICON_POSITION = 0 9 10 MSG_POSITION = 1 10 11 GAUGE_POSITION = 2 12 CONSOLE_POSITION = 3 11 13 BUTTON_SIZE = 40 14 15 CONSOLE_WIDTH = 340 16 CONSOLE_HEIGHT = 240 17 18 class ConsolePanel(wx.Panel): 19 def __init__(self, parent, *args, **kwargs): 20 wx.Panel.__init__(self, parent=parent,*args, **kwargs) 21 self.parent = parent 22 self.sizer = wx.BoxSizer(wx.VERTICAL) 23 self.msg_txt = wx.TextCtrl(self, size=(CONSOLE_WIDTH-40, 24 CONSOLE_HEIGHT-60), 25 style=wx.TE_MULTILINE) 26 self.msg_txt.SetValue('No message available') 27 self.sizer.Add(self.msg_txt, 1, wx.EXPAND|wx.ALL, 10) 28 self.SetSizer(self.sizer) 29 30 def set_message(self, status=""): 31 msg = status+ "\n" 32 self.msg_txt.AppendText(str(msg)) 33 34 class Console(wx.Frame): 35 def __init__(self, parent=None, status="", *args, **kwds): 36 kwds["size"] = (CONSOLE_WIDTH, CONSOLE_HEIGHT) 37 kwds["title"] = "Console" 38 wx.Frame.__init__(self, parent=parent, *args, **kwds) 39 self.panel = ConsolePanel(self) 40 self.panel.set_message(status=status) 41 self.Bind(EVT_MESSAGE, self.set_message) 42 self.Show(True) 43 44 def set_multiple_messages(self, messages=[]): 45 """ 46 """ 47 if messages: 48 for status in messages: 49 self.panel.set_message(status) 50 51 def set_message(self, event): 52 """ 53 """ 54 self.panel.set_message(event.status) 55 12 56 class StatusBar(wxStatusB): 13 57 def __init__(self, parent, *args, **kargs): … … 21 65 #Layout of status bar 22 66 self.SetFieldsCount(NB_FIELDS) 23 self.SetStatusWidths([BUTTON_SIZE, -2, -1 ])67 self.SetStatusWidths([BUTTON_SIZE, -2, -1,BUTTON_SIZE]) 24 68 25 69 #display default message … … 39 83 rect = self.GetFieldRect(ICON_POSITION) 40 84 self.bitmap_bt_warning.SetPosition((rect.x+5, rect.y-2)) 41 85 86 console_bmp = wx.ArtProvider.GetBitmap(wx.ART_TIP, wx.ART_TOOLBAR) 87 self.bitmap_bt_console = wx.BitmapButton(self, -1, 88 size=(BUTTON_SIZE-5, height-4)) 89 self.bitmap_bt_console.SetBitmapLabel(console_bmp) 90 self.bitmap_bt_console.Bind(wx.EVT_BUTTON, self._onMonitor, 91 id=self.bitmap_bt_console.GetId()) 92 rect = self.GetFieldRect(CONSOLE_POSITION) 93 self.bitmap_bt_console.SetPosition((rect.x+5, rect.y-2)) 42 94 ## Current progress value of the bar 43 95 self.nb_start = 0 44 96 self.nb_progress = 0 45 97 self.nb_stop = 0 98 99 self.frame = None 100 self.list_msg = [] 46 101 self.progress = 0 47 102 self.timer = wx.Timer(self, -1) … … 60 115 """ 61 116 wxStatusB.SetStatusText(self, text, MSG_POSITION) 117 self.list_msg.append(text) 62 118 icon_bmp = wx.ArtProvider.GetBitmap(wx.ART_INFORMATION, wx.ART_TOOLBAR) 63 119 self.bitmap_bt_warning.SetBitmapLabel(icon_bmp) 64 120 try: 121 if self.frame is not None and self.frame.IsShown(): 122 event = MessageEvent() 123 event.status = text 124 wx.PostEvent(self.frame, event) 125 except: 126 return 127 65 128 def PopStatusText(self, *args, **kwds): 66 129 wxStatusB.PopStatusText(self, field=MSG_POSITION) … … 179 242 self.set_message(event=event) 180 243 self.set_gauge(event=event) 244 245 def _onMonitor(self, event): 246 """ 247 """ 248 self.frame = Console(parent=self) 249 self.frame.set_multiple_messages(self.list_msg) 250 self.frame.Show(True) 251 181 252 182 253 if __name__ == "__main__": … … 186 257 frame.SetStatusBar(statusBar) 187 258 frame.Show(True) 188 (NewPlotEvent, EVT_NEW_PLOT) = wx.lib.newevent.NewEvent()189 event = NewPlotEvent()259 260 event = MessageEvent() 190 261 event.type = "progress" 191 262 event.status = "statusbar...."
Note: See TracChangeset
for help on using the changeset viewer.