From: Steve F. <sf...@ih...> - 2006-07-05 23:36:25
|
Hi, For debugging let's say I put a method "on_size(self, event)" in my class, and it prints some stuff. Well, I noticed when playing with model.Background.singleItemExpandingSizerLayout(), if I provide an on_size(), then the resizing doesn't happen. So I tried... class Test(model.Background): def on_initialize(self, event): self.singleItemExpandingSizerLayout() def on_size(self, event): print self.size, self.c.StaticBox1.size super(Test, self).on_size(self, event) # This didn't work model.Background.on_size(self, event) # Nor this The exception for either approach is this: Traceback (most recent call last): File "/usr/lib/python2.3/site-packages/PythonCard/model.py", line 884, in _dispatch handler(background, aWxEvent) File "test.py", line 16, in on_size super(Test, self).on_size(self, event) AttributeError: 'super' object has no attribute 'on_size' And I guess that's because the superclass handles events by means other than prefab methods? So when I want to respond to an event but then toss the event back up afterward for normal handling, how do I do that? Thanks! Steve |
From: Alex T. <al...@tw...> - 2006-07-05 23:59:57
|
Steve Freitas wrote: >Hi, > >For debugging let's say I put a method "on_size(self, event)" in my >class, and it prints some stuff. Well, I noticed when playing with >model.Background.singleItemExpandingSizerLayout(), if I provide an >on_size(), then the resizing doesn't happen. So I tried... > >class Test(model.Background): > def on_initialize(self, event): > self.singleItemExpandingSizerLayout() > > def on_size(self, event): > print self.size, self.c.StaticBox1.size > super(Test, self).on_size(self, event) # This didn't work > model.Background.on_size(self, event) # Nor this > > >So when I want to respond to an event but then toss the event back up >afterward for normal handling, how do I do that? > > > def on_size(self, event): print self.size, self.c.StaticBox1.size event.skip() Actually, event.Skip() also seems to work - not 100% sure which is "correct" :-) -- Alex Tweedly http://www.tweedly.net -- No virus found in this outgoing message. Checked by AVG Free Edition. Version: 7.1.394 / Virus Database: 268.9.8/380 - Release Date: 30/06/2006 |
From: Steve F. <sf...@ih...> - 2006-07-06 04:29:06
|
Great, thanks for the tip. That's interesting. Before I discovered singleItemExpandingSizerLayout() (say that five times fast), I was using on_size() to adjust the size of StaticBox1 when the window size changed, but the redraws weren't coming through. Until, that is, I added event.skip(). So it seems like for proper handling of most general events (IOW, events not aimed at specific components), calling event.skip() at the end of the function is a good idea, no? Steve On Thu, 2006-07-06 at 00:59 +0100, Alex Tweedly wrote: > Steve Freitas wrote: > > >Hi, > > > >For debugging let's say I put a method "on_size(self, event)" in my > >class, and it prints some stuff. Well, I noticed when playing with > >model.Background.singleItemExpandingSizerLayout(), if I provide an > >on_size(), then the resizing doesn't happen. So I tried... > > > >class Test(model.Background): > > def on_initialize(self, event): > > self.singleItemExpandingSizerLayout() > > > > def on_size(self, event): > > print self.size, self.c.StaticBox1.size > > super(Test, self).on_size(self, event) # This didn't work > > model.Background.on_size(self, event) # Nor this > > > > > > >So when I want to respond to an event but then toss the event back up > >afterward for normal handling, how do I do that? > > > > > > > def on_size(self, event): > print self.size, self.c.StaticBox1.size > event.skip() > > Actually, event.Skip() also seems to work - not 100% sure which is "correct" :-) > > > > -- > Alex Tweedly http://www.tweedly.net > > > |
From: Kevin A. <al...@se...> - 2006-07-07 18:36:44
|
On Jul 5, 2006, at 4:59 PM, Alex Tweedly wrote: > Steve Freitas wrote: > >> Hi, >> >> For debugging let's say I put a method "on_size(self, event)" in my >> class, and it prints some stuff. Well, I noticed when playing with >> model.Background.singleItemExpandingSizerLayout(), if I provide an >> on_size(), then the resizing doesn't happen. So I tried... >> >> class Test(model.Background): >> def on_initialize(self, event): >> self.singleItemExpandingSizerLayout() >> >> def on_size(self, event): >> print self.size, self.c.StaticBox1.size >> super(Test, self).on_size(self, event) # This didn't work >> model.Background.on_size(self, event) # Nor this >> >> > >> So when I want to respond to an event but then toss the event back up >> afterward for normal handling, how do I do that? >> >> >> > def on_size(self, event): > print self.size, self.c.StaticBox1.size > event.skip() > > Actually, event.Skip() also seems to work - not 100% sure which is > "correct" :-) mixedCase method names are synonyms for wx methods which are always CamelCase (C++ style) or they are PythonCard specific. In the PythonCard event dispatch, the alias is added as a convenience like so: aWxEvent.skip = aWxEvent.Skip This way you can consistently use mixedCase style method names in your PythonCard code. ka |