[wxPython-users] Re: Newbie question about events and event handling

Christopher Barker Chris.Barker at noaa.gov
Fri Nov 2 15:37:32 PDT 2007


Patrick J. Anderson wrote:
>>>  how do I update the widget, so it reflects the change?
>     def _createHeaders(self):
...
>         text2 = wx.StaticText(hp2, wx.NewId(), self.date.strftime('%A %d %
> B, %Y %H:%M:%S'), 
 >             style = wx.ALIGN_CENTER)

You've just created a StaticText with the date, but not saved a 
reference anywhere you can get at it to change it, so you need something 
like:

          self.DateLabel =  = wx.StaticText(hp2, wx.NewId(), 
self.date.strftime('%A %d % B, %Y %H:%M:%S'), style = wx.ALIGN_CENTER)

Then:
      def setDate(self, d):
          self.date = d
          self.DateLabel.SetLabel(self.date.strftime('%A %d % B, %Y 
%H:%M:%S'))

Then you may or not need a self.DateLabel.Update() or Refresh() or just 
a self.Update() or self.Refresh()

This should work.

-Chris



-- 
Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R            (206) 526-6959   voice
7600 Sand Point Way NE   (206) 526-6329   fax
Seattle, WA  98115       (206) 526-6317   main reception

Chris.Barker at noaa.gov




More information about the wxpython-users mailing list