I have been trying to figure out why my
matplotlib graphs were not posting (fully) to
a wxAUINotebook (see other thread) under Ubuntu
until I moved my cursor out of the frame, but were
fine under Windows. The tentative answer strikes
me as bizarre, but maybe I am misunderstanding
something.
It's the print statements. (It seems).
Attached are two smallish (245 lines) sample
apps that are identical other than that one has all
the print statements commented out. These are
smaller versions of my original code (so excuse the
detritus). The one which includes uncommented print
statements will hang in the same way that I had been
experiencing this issue. To demonstrate the issue:
1. Run these on Ubuntu 8.10 (I'm using 64bit version).
(requires matplotlib and numpy of course). The
problem does not happen on WinXP. Haven't tested
on Mac.
2. Run the one with the print statements, as indicated
by the filename. DO NOT MOVE THE CURSOR
OUTSIDE THE FRAME in order to test this properly.
Press the button to add graphs. On my system (see
below for full stats) I can only add 5 graphs before it
hangs, and then I can get it to resume processing
and post a graph if I bring the cursor outside the
frame. Not good. Oddly, moving it outside the frame
will buy you 5 more graphs' worth before it hangs
again and requires this reset trick.
3. Now run the one with the print statement
commented out. Now add graphs. With this I have
been able to add 110 graphs before I got tired.
Good! (and in my real app, I can use it with an sqlite
database and a more complex graph and added 40+ of
those, too).
4. In fact, if you want to vary how many graphs you can
get before it hangs, just either comment out or copy
and add more of these print statements. Every 1-2
print statements subtracted buys you a graph or two
more before it requires this "reset" of leaving the frame.
Why does having or not having the print statements
make such a huge difference? There is nothing even
in those functions where they are that is very Python
intense, just basic stuff. And why does this hang like
this only under Ubuntu and not at all with WinXP?
Thanks for any help. I hope in understanding this I
will learn some new angle on wxPython or Python. I
had been using print statements to help in debugging,
and they have never been a problem before.
The system I am testing this on:
Ubuntu 8.10
Linux kernel 2.6.27-11-generic
GNOME 2.24.1
2 GB RAM
Dual core 1.8 Ghz
matplotlib 0.98.3
wxPython 2.6.3.2 (I thought it should be
2.8.x.x but this is what shell is telling me)
Thanks very much,
Che
sample_with_prints.py (10 KB)
sample_without_prints.py (10 KB)