[wxPython] wxFrame::OnSize

I have the following line in my code:
wxFrame.OnSize(self, event)

and it complains:
Traceback (most recent call last):
  File "./reader.py", line 138, in OnSize
    wxFrame.OnSize(self, event)
AttributeError: class wxFrame has no attribute 'OnSize'

The docs clearly say that wxFrame does have a func called OnSize. Am I just
not calling it right?

I have the following line in my code:
wxFrame.OnSize(self, event)

and it complains:
Traceback (most recent call last):
  File "./reader.py", line 138, in OnSize
    wxFrame.OnSize(self, event)
AttributeError: class wxFrame has no attribute 'OnSize'

The docs clearly say that wxFrame does have a func called OnSize. Am I

just

not calling it right?

Most of the On** methods have been pulled out of the docs. Some were there
for historical reasons, others were supposed to be an example of event
handlers. Mostly they just caused confusion.

···

--
Robin Dunn
Software Craftsman
robin@AllDunn.com Java give you jitters?
http://wxPython.org Relax with wxPython!

OK, then, how would I do the following: I want to keep track of the size of
my frame. I want it to resize itself and it's one sub-window properly, but
I also want to grab the width and height each time it is resized. I tried
to catch the event with EVT_SIZE(self, self.OnSize), but then it didn't
re-size it's sub-window properly, so I tried calling wxFrame::OnSize to
force it to do so.

So, how do I catch an event that is already being caught, store some
information about it, but then have it behave just like normally does?

> I have the following line in my code:
> wxFrame.OnSize(self, event)
>
> and it complains:
> Traceback (most recent call last):
> File "./reader.py", line 138, in OnSize
> wxFrame.OnSize(self, event)
> AttributeError: class wxFrame has no attribute 'OnSize'
>
> The docs clearly say that wxFrame does have a func called OnSize. Am I
just
> not calling it right?

Most of the On** methods have been pulled out of the docs. Some were

there

···

for historical reasons, others were supposed to be an example of event
handlers. Mostly they just caused confusion.

OK, could you please tell me how to do what I was trying to do?

I want to keep track of the size of my frame, so I called EVT_SIZE(self,
self.OnSize) to catch the event and store the new size. But it wasn't
automatically re-sizing the one sub-window that I had, so I tried calling
wxFrame::OnSize to force it to still behave in the default manner, and then
let me extract the info I want from the event.

Basically, how can I catch an event (sizing, moving, closing, etc.), do
something custom, but still have it do what it does by default?

> I have the following line in my code:
> wxFrame.OnSize(self, event)
>
> and it complains:
> Traceback (most recent call last):
> File "./reader.py", line 138, in OnSize
> wxFrame.OnSize(self, event)
> AttributeError: class wxFrame has no attribute 'OnSize'
>
> The docs clearly say that wxFrame does have a func called OnSize. Am I
just
> not calling it right?

Most of the On** methods have been pulled out of the docs. Some were

there

···

for historical reasons, others were supposed to be an example of event
handlers. Mostly they just caused confusion.

So, how do I catch an event that is already being caught, store some
information about it, but then have it behave just like normally does?

Call event.Skip() in your handler and then the searching for an event
handler will continue, calling a default handler if there is one.

···

--
Robin Dunn
Software Craftsman
robin@AllDunn.com Java give you jitters?
http://wxPython.org Relax with wxPython!

I believe you want something like the following (untested):

class Foo:
    def __init__(self, ...):
        ...
        EVT_SIZE(self,self.OnSize)
        ...

    def OnSize(self, event):
        # Do some custom stuff such as store the current size away
        self.old_size = self.GetSize()
        # Then call event.Skip to get the original OnSize behaviour
        event.Skip()

-tim

OK, could you please tell me how to do what I was trying to do?

I want to keep track of the size of my frame, so I called EVT_SIZE(self,
self.OnSize) to catch the event and store the new size. But it wasn't
automatically re-sizing the one sub-window that I had, so I tried calling
wxFrame::OnSize to force it to still behave in the default manner, and

then

let me extract the info I want from the event.

Basically, how can I catch an event (sizing, moving, closing, etc.), do
something custom, but still have it do what it does by default?

> > I have the following line in my code:
> > wxFrame.OnSize(self, event)
> >
> > and it complains:
> > Traceback (most recent call last):
> > File "./reader.py", line 138, in OnSize
> > wxFrame.OnSize(self, event)
> > AttributeError: class wxFrame has no attribute 'OnSize'
> >
> > The docs clearly say that wxFrame does have a func called OnSize. Am

I

···

> just
> > not calling it right?
>
> Most of the On** methods have been pulled out of the docs. Some were
there
> for historical reasons, others were supposed to be an example of event
> handlers. Mostly they just caused confusion.

_______________________________________________
wxpython-users mailing list
wxpython-users@lists.wxwindows.org
http://lists.wxwindows.org/mailman/listinfo/wxpython-users