Newbie question about events and event handling
Patrick J. Anderson
pat.j.anderson at gmail.com
Fri Nov 2 16:11:21 PDT 2007
On Fri, 02 Nov 2007 15:37:32 -0700, Christopher Barker wrote:
> 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
Thanks for your help, Chris! It works well. Now I just need to refactor
my code and see if I can add data and update it in a similar way.
More information about the wxpython-users
mailing list