Newbie question about events and event handling

Patrick J. Anderson pat.j.anderson at gmail.com
Sat Nov 3 10:20:27 PDT 2007


On Fri, 02 Nov 2007 23:11:21 +0000, Patrick J. Anderson wrote:

> 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.

Setting the label work, but do I need to redraw the whole DayPlanner 
panel when I set a new date or should self.Refresh() or self.Update() 
take care of it?





More information about the wxpython-users mailing list