| CODENOTIFIER | HelpYou are not signed inSign in |
Project: Editra
Revision: 56061
Author: CJP
Date: 03 Oct 2008 13:03:30
Changes:Automatically expire status bar info text after 10 seconds.
Files:| ... | ...@@ -37,6 +37,11 @@ | |
| 37 | 37 | #--------------------------------------------------------------------------# |
| 38 | 38 | |
| 39 | 39 | class EdStatBar(pstatbar.ProgressStatusBar): |
| 40 | """Custom status bar that handles dynamic field width adjustment and | |
| 41 | automatic expiration of status messages. | |
| 42 | ||
| 43 | """ | |
| 44 | ID_CLEANUP_TIMER = wx.NewId() | |
| 40 | 45 | def __init__(self, parent): |
| 41 | 46 | pstatbar.ProgressStatusBar.__init__(self, parent, style=wx.ST_SIZEGRIP) |
| 42 | 47 | |
| ... | ...@@ -45,9 +50,12 @@ | |
| 45 | 50 | self._widths = list() |
| 46 | 51 | self.SetFieldsCount(6) # Info, vi stuff, line/progress |
| 47 | 52 | self.SetStatusWidths([-1, 90, 40, 40, 40, 155]) |
| 53 | self._cleanup_timer = wx.Timer(self, EdStatBar.ID_CLEANUP_TIMER) | |
| 48 | 54 | |
| 49 | 55 | # Event Handlers |
| 50 | 56 | self.Bind(wx.EVT_LEFT_DCLICK, self.OnLeftDClick) |
| 57 | self.Bind(wx.EVT_TIMER, self.OnExpireMessage, | |
| 58 | id=EdStatBar.ID_CLEANUP_TIMER) | |
| 51 | 59 | |
| 52 | 60 | # Messages |
| 53 | 61 | ed_msg.Subscribe(self.OnProgress, ed_msg.EDMSG_PROGRESS_SHOW) |
| ... | ...@@ -96,6 +104,16 @@ | |
| 96 | 104 | self._widths = widths |
| 97 | 105 | self.SetStatusWidths(self._widths) |
| 98 | 106 | |
| 107 | def OnExpireMessage(self, evt): | |
| 108 | """Handle Expiring the status message when the oneshot timer | |
| 109 | tells us it has expired. | |
| 110 | ||
| 111 | """ | |
| 112 | if evt.GetId() == EdStatBar.ID_CLEANUP_TIMER: | |
| 113 | wx.StatusBar.SetStatusText(self, u'', ed_glob.SB_INFO) | |
| 114 | else: | |
| 115 | evt.Skip() | |
| 116 | ||
| 99 | 117 | def OnLeftDClick(self, evt): |
| 100 | 118 | """Handlers mouse left double click on status bar |
| 101 | 119 | @param evt: Event fired that called this handler |
| ... | ...@@ -179,6 +197,12 @@ | |
| 179 | 197 | pstatbar.ProgressStatusBar.PushStatusText(self, txt, field) |
| 180 | 198 | self.AdjustFieldWidths() |
| 181 | 199 | |
| 200 | # Start the expiration countdown | |
| 201 | if self._cleanup_timer.IsRunning(): | |
| 202 | self._cleanup_timer.Stop() | |
| 203 | self._cleanup_timer.Start(10000, True) | |
| 204 | ||
| 205 | ||
| 182 | 206 | def SetStatusText(self, txt, field): |
| 183 | 207 | """Set the status text |
| 184 | 208 | @param txt: Text to put in bar |
| ... | ...@@ -188,6 +212,11 @@ | |
| 188 | 212 | pstatbar.ProgressStatusBar.SetStatusText(self, txt, field) |
| 189 | 213 | self.AdjustFieldWidths() |
| 190 | 214 | |
| 215 | # Start the expiration countdown | |
| 216 | if self._cleanup_timer.IsRunning(): | |
| 217 | self._cleanup_timer.Stop() | |
| 218 | self._cleanup_timer.Start(10000, True) | |
| 219 | ||
| 191 | 220 | |
| 192 | 221 | def UpdateFields(self): |
| 193 | 222 | """Update document fields based on the currently selected |
| ... | ...@@ -8,6 +8,21 @@ | |
| 8 | 8 | #-----------------------------------------------------------------------------# |
| 9 | 9 | Changes since last release: |
| 10 | 10 | |
| 11 | VERSION 0.x.xx | |
| 12 | DATE 1x/xx/2008 | |
| 13 | 16th Alpha Release | |
| 14 | ||
| 15 | NEWS: | |
| 16 | ||
| 17 | ||
| 18 | NEW: [features/improvements] | |
| 19 | +Automatically expire status bar info messages after 10 seconds | |
| 20 | ||
| 21 | BUG FIXES: | |
| 22 | ||
| 23 | ||
| 24 | #-----------------------------------------------------------------------------# | |
| 25 | ||
| 11 | 26 | VERSION 0.3.80 |
| 12 | 27 | DATE 10/02/2008 |
| 13 | 28 | 15th Alpha Release |