generate wx.EVT_LEAVE_WINDOW evt?

Hi, as a stop-gap fix for an issue I am still trying to
resolve regarding posting matplotlib plots into an
AUINotebook on Ubuntu (see: http://tiny.cc/dh5n3),
how can I programatically create an EVT_LEAVE_WINDOW
event for the frame?

By the way, this is for use with Ubuntu 8.10.

I have not programatically created events before, and
though have found some posts to it, am still a bit unsure
as to the right way for this case (is there a good docs
section on it somewhere?)

Thanks,
Che

Hello,

···

On Wed, Mar 18, 2009 at 10:53 AM, C M cmpython@gmail.com wrote:

Hi, as a stop-gap fix for an issue I am still trying to
resolve regarding posting matplotlib plots into an

AUINotebook on Ubuntu (see: http://tiny.cc/dh5n3),
how can I programatically create an EVT_LEAVE_WINDOW
event for the frame?

By the way, this is for use with Ubuntu 8.10.

I have not programatically created events before, and
though have found some posts to it, am still a bit unsure
as to the right way for this case (is there a good docs
section on it somewhere?)

For this case EVT_LEAVE_WINDOW is a MouseEvent so you need to make a mouse event. (see docs.wxwidgets.org, or the wxpython docs this information can be found in both with a simple search.).

event = wx.MouseEvent(wx.wxEVT_LEAVE_WINDOW)

wx.PostEvent(destination_window, event)

Cody

Thanks, Cody.

Unfortunately, this didn't do the trick as I'd hoped. What's odd is that
if the cursor actually leaves the frame, a mpl plot posts to the AUINotebook.
If I merely post this event (as above, subbing the frame reference for the
destination_window), it doesn't. (This problem explained in the other email).

Why are they not equivalent? Is EVT_LEAVE_WINDOW not applicable
to a wxFrame?

Thanks,
Che

···

2009/3/18 Cody Precord <codyprecord@gmail.com>:

Hello,

On Wed, Mar 18, 2009 at 10:53 AM, C M <cmpython@gmail.com> wrote:

Hi, as a stop-gap fix for an issue I am still trying to
resolve regarding posting matplotlib plots into an
AUINotebook on Ubuntu (see: AdultFriendFinder.co.uk),
how can I programatically create an EVT_LEAVE_WINDOW
event for the frame?

By the way, this is for use with Ubuntu 8.10.

I have not programatically created events before, and
though have found some posts to it, am still a bit unsure
as to the right way for this case (is there a good docs
section on it somewhere?)

For this case EVT_LEAVE_WINDOW is a MouseEvent so you need to make a mouse
event. (see docs.wxwidgets.org, or the wxpython docs this information can be
found in both with a simple search.).

event = wx.MouseEvent(wx.wxEVT_LEAVE_WINDOW)
wx.PostEvent(destination_window, event)

C M wrote:

Hello,

Hi, as a stop-gap fix for an issue I am still trying to
resolve regarding posting matplotlib plots into an
AUINotebook on Ubuntu (see: AdultFriendFinder.co.uk),
how can I programatically create an EVT_LEAVE_WINDOW
event for the frame?

By the way, this is for use with Ubuntu 8.10.

I have not programatically created events before, and
though have found some posts to it, am still a bit unsure
as to the right way for this case (is there a good docs
section on it somewhere?)

For this case EVT_LEAVE_WINDOW is a MouseEvent so you need to make a mouse
event. (see docs.wxwidgets.org, or the wxpython docs this information can be
found in both with a simple search.).

event = wx.MouseEvent(wx.wxEVT_LEAVE_WINDOW)
wx.PostEvent(destination_window, event)

Thanks, Cody.

Unfortunately, this didn't do the trick as I'd hoped. What's odd is that
if the cursor actually leaves the frame, a mpl plot posts to the AUINotebook.

Is it really not there or has it just not painted itself? Or is it
there but the window is too small to see anything and it is not resizing
to fit the notebook page until later?

To answer these questions you can add in a WIT to your app and then use
the widget tree and PyShell that it provides to do some introspection of
your app while it is running and having this problem. See
http://wiki.wxpython.org/Widget_Inspection_Tool

If I merely post this event (as above, subbing the frame reference for the
destination_window), it doesn't. (This problem explained in the other email).

Why are they not equivalent? Is EVT_LEAVE_WINDOW not applicable
to a wxFrame?

It is but there are two problems here. First manufacturing and sending
a wx event is not the same thing as the event happening naturally in the
system. In other words, the equivalent native event is not also
manufactured and send to the native widget. Only the wx side of the
classes will see the event.

Second, I really doubt that it is the EVT_LEAVE_WINDOW that is
triggering anything here. More likely it is some sort of side-effect of
the mouse movement or other events. For example, the EVT_IDLE issue
mentioned earlier could be the culprit if something in your app or maybe
AUI is eating the idle events, or preventing them from being delivered.
  Another would be if something is preventing return to the MainLoop,
maybe you are stuck in a nested event loop like from wx.Yield or
something. (IIRC if you call wx.Yield from a EVT_IDLE handler then it
may not send other idle events, depending on the situation.) So if the
yield is never returning until something like the mouse leaving the
frame kicks it in the pants then that could result in behavior like this
too.

Probably the best thing to do at this point would be to try and
duplicate the problem and then closely examine what you did to make it
fail.

···

2009/3/18 Cody Precord <codyprecord@gmail.com>:

On Wed, Mar 18, 2009 at 10:53 AM, C M <cmpython@gmail.com> wrote:

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

C M wrote:

Hello,

Hi, as a stop-gap fix for an issue I am still trying to
resolve regarding posting matplotlib plots into an
AUINotebook on Ubuntu (see: AdultFriendFinder.co.uk),
how can I programatically create an EVT_LEAVE_WINDOW
event for the frame?

By the way, this is for use with Ubuntu 8.10.

I have not programatically created events before, and
though have found some posts to it, am still a bit unsure
as to the right way for this case (is there a good docs
section on it somewhere?)

For this case EVT_LEAVE_WINDOW is a MouseEvent so you need to make a
mouse
event. (see docs.wxwidgets.org, or the wxpython docs this information can
be
found in both with a simple search.).

event = wx.MouseEvent(wx.wxEVT_LEAVE_WINDOW)
wx.PostEvent(destination_window, event)

Thanks, Cody.

Unfortunately, this didn't do the trick as I'd hoped. What's odd is that
if the cursor actually leaves the frame, a mpl plot posts to the
AUINotebook.

Is it really not there or has it just not painted itself? Or is it
there but the window is too small to see anything and it is not resizing
to fit the notebook page until later?

It appears to be there in the form of a small grey square.

To answer these questions you can add in a WIT to your app and then use
the widget tree and PyShell that it provides to do some introspection of
your app while it is running and having this problem. See
http://wiki.wxpython.org/Widget_Inspection_Tool

Useful, thank you, but interestingly, I can't even use it in the midst of
this problem it seems. If I have it running and I get to the point of
"have to leave frame before plot is (fully) shown", and then I mouse
over to the WIT (given that I can move the cursor over it without leaving
either frame's boundary), I can't click on Refresh there to see whether
the plotpanel has been added or not. In fact, I can't take any action
vis-a-vis wxPython--like closing the frames--unless I first leave the
frame.

Also, I've noticed that if I leave the frame BEFORE I attempt to post
a plot, then that plot posts OK. So it either posts if I have already
left the frame prior to or following attempting to post my plot.

Probably the best thing to do at this point would be to try and
duplicate the problem and then closely examine what you did to make it
fail.

I am trying. I have already tried posting a mpl plot with 250,000 pts,
thinking maybe it was a larger graph that was the problem, but that
worked. There are sqlite queries involved here, too, suspect that
might be part of it somehow. I will keep at it, but it just seems very
mysterious for now. By the way, I don't think my idle events have
anything to do with this, since I am not using the "size on idle"
strategy that the other person referred to, nor doing anything in idle.
I am also not using any wx.Yield.

Thanks, Robin.
Che

···

On Wed, Mar 18, 2009 at 7:23 PM, Robin Dunn <robin@alldunn.com> wrote:

2009/3/18 Cody Precord <codyprecord@gmail.com>:

On Wed, Mar 18, 2009 at 10:53 AM, C M <cmpython@gmail.com> wrote:

For what it's worth, here is the latest data on this problem...

I have removed sqlite from the app entirely. Still have the
problem.

Now it only happens on every 4th plot! I can plot 3 mpl
plots fine, and on the 4th one it hangs and requires that
I move the cursor out of the frame before it fully posts.
This is after I removed sqlite and simplified the plot a bit.

If I look at the System Monitor in Ubuntu, each plot causes
the memory to increase by 4-10 MiB, and after each one
the waiting channel column says "do_poll" until the 4th
one, in which it says "pipe_wait". This is meaningless
to me, but perhaps it can be a clue to someone else as
to what is happening here?

Thanks,
Che