[wxPython] (no subject)

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

[wxPython] (no subject)

andy-224
linux - redhat 6.0
wxGTK 2.1 snapshot 9
wxPython 2.1b3

I have a wxFrame, that when I call SetSize() on it, I immediately get 2
OnSize() calls:  the first being the new size that I set, the second being
the previous size of the frame, so the size of the frame doesn't change.
What is generating this second OnSize() event?  If I "drag" the window to
a new size, I only get 1 OnSize() call with the new size.

Basically what I'm wanting to do is have a wxSpinButton that controls the
height & width of my frame, so that as the user is increasing the value of
the spin button, it's increasing the dimnesion of the frame.  So when I
get the OnSpin() event, I call SetSize() on the frame.

The "SPIN" below is from my OnSpin() method; the "Setting width to x" is
just before I call SetSize() on the frame, and the (width, height) are
from the frame's OnSize() method.

SPIN
Setting width to 192
(192, 200)
(200, 200)
SPIN
Setting width to 191
(191, 200)
(200, 200)

  This happens whether I'm spinning "up" or "down". Any ideas on what's
causing the second OnSize() call?

                            &y

_______________________________________________
wxPython-users maillist  -  [hidden email]
http://starship.python.net/mailman/listinfo/wxpython-users



Reply | Threaded
Open this post in threaded view
|

Re: [wxPython] (no subject)

Robin Dunn
> I have a wxFrame, that when I call SetSize() on it, I immediately get 2
> OnSize() calls:  the first being the new size that I set, the second being
> the previous size of the frame, so the size of the frame doesn't change.
> What is generating this second OnSize() event?  If I "drag" the window to
> a new size, I only get 1 OnSize() call with the new size.
>

Please send me a bit of sample code that exhibits this behaviour.

Thanks,

--
Robin Dunn
Software Craftsman
[hidden email]
http://AllDunn.com/robin/
http://AllDunn.com/wxPython/  Check it out!





_______________________________________________
wxPython-users maillist  -  [hidden email]
http://starship.python.net/mailman/listinfo/wxpython-users



Reply | Threaded
Open this post in threaded view
|

Re: [wxPython] (no subject)

Robin Dunn
In reply to this post by andy-224
> >> I have a wxFrame, that when I call SetSize() on it, I immediately get 2
> >> OnSize() calls:  the first being the new size that I set, the second
being
> >> the previous size of the frame, so the size of the frame doesn't
change.
> >> What is generating this second OnSize() event?  If I "drag" the window
to
> >> a new size, I only get 1 OnSize() call with the new size.
> >>
> >
> >Please send me a bit of sample code that exhibits this behaviour.
>

   [...]

> under the "View" menu option, select "Create a new Frame".  In the
> properties box, under the Dimension tab, use the spin buttons.  On each
> spin notification via OnButtonSpin(), I call UpdateProperty() on the
> parent, which eventually cascades down to the frame via SetProperty()
> which then generates a SetSize() call on the frame.

First things first...  I found some issues in radMWin before I could even
get to radFrame.

1. On MSW, there is a size event when a status bar is created, and also when
a menubar is added to the frame.  This caused an exception in radMWin.OnSize
because it was unable to find self.m_projectTree.  Rearranging things in
radMWin.__init__ takes care of this, but what I usually to is set some flag
to false at the begining of __init__, setting it to true at the end, and in
OnSize just checking this flag before I do anything.

2. In radMWin.__init__ you are calling self.SetAutoLayout(true), but you
don't use constraints.  This probably doesn't cause any problems since you
have your own OnSize, but it still shouldn't be there.

3. In your case, since radWin has only one child you don't need an onSize at
all.  wxFrames automatically size thier child to take the whole client area,
if there is only one.

4. I ran into an endless event loop starting in radMWin.OnSelChanged.  It
calls self.ObjectSelected which then calls
self.m_projectTree.SelectItem(node) which then generates another
EVT_TREE_SEL_CHANGED event...  You need to make sure that SelectItem is not
called if you are coming from OnSelChanged.


Okay, now on to the radFrame...

1. On MSW I do get two size events durring the SetSize call.  Looking at the
wxWindows C++ code it looks like one of them is coming from Windows and the
other is coming from wxFrame::DoSetSize.  In my case however the correct
size is coming second so the frame does in fact change to the right size.

2. With GTK, there is only one size event, and in fact it comes AFTER the
SetSize call has completed (in idle time).  Other window managers may behave
differently than this though and actually generate two events like MSW does.
I'm using KDE.

3.  I then looked a little closer at your radFrame.OnSetSize event handler
method.  You were using event.GetSize().  I switched it to self.GetSize, and
then the sizes printed for the two events were the same.  My guess is that
the size event coming from windows is incorrectly sending the size of the
client area instead of the whole frame.  Here is an example of doing this in
the OnSetSize method:

    print self.GetSize(), event.GetSize():


Setting width to 205
(205, 200) (197, 173)
(205, 200) (205, 200)
Done with SetSize
Setting width to 207
(207, 200) (199, 173)
(207, 200) (207, 200)
Done with SetSize
Setting width to 209
(209, 200) (201, 173)
(209, 200) (209, 200)
Done with SetSize
Setting width to 211
(211, 200) (203, 173)
(211, 200) (211, 200)
Done with SetSize
Setting width to 213
(213, 200) (205, 173)
(213, 200) (213, 200)
Done with SetSize
Setting width to 215
(215, 200) (207, 173)
(215, 200) (215, 200)
Done with SetSize




_______________________________________________
wxPython-users maillist  -  [hidden email]
http://starship.python.net/mailman/listinfo/wxpython-users