wxSpinSequence, wxOscilloscope

Hello,

A few days ago I asked about how to make composite controls, in particular a logarithmic SpinButton that follows reasonably a sequence, such as .1, .2, .5, 1, 2, 5, 10, .... With some advice I received, I built a first version. Please find attached this version, which works, but needs certainly some refinement, such as its own EVT_SPINSEQUENCE, and some standard methods.

The aforementioned SpinSequence is employed in my oscilloscope, based on work from Gordon Williams and Christopher Barker. Please find also attached wxOscilloscope and the modified wxPyPlot it is based upon. It would also need some work, e.g. make the timer and daq independent of the control itself and add some API to "program" the scope. However, I have no idea so far how this could be acomplished in a reasonable way.

regards,
peter

wxSpinSequence.py (5.34 KB)

wxOscilloscope.py (14.2 KB)

wxPyPlot.py (55.7 KB)

Peter and Gordon,

I checked out Peter's wxOscilloscope, and I have a couple of comments:

* I've improved my version of wxPyPlot a little. I"ve enclosed it. As
far as I can tell, it works with the built-in demo, as well as
wwxOscilloscope. It now maintains an extra buffer with the axis in it,
so that you can have a grid showing. I'd like to re-structure it more,
but I really need to do my real work instead. If I find another use for
it, I may re-stucture it more. What I'd like to see is the code for
figuring out how to draw stuff, and the code for actually drawing it
distict. That way we could re-fresh stuff faster, and there might be no
reason to have the extra buffer.

* you really shouldn't use all those

"from whatever import *"

imports. You get a VERY cluttered workspace. It does seem to be the
convention for both Numeric and wxPython, but wxPython is changing to
stop people doing that, and you probably aren't using Numeric enough to
make it worth it. See how wxPyPlot does it, it really is cleaner and
more clear where the heck various functions come from!

* you shouldn't use "if something == None", but rather "if something is
None". "==" can be overloaded, so it can break if it has been overloaded
for whatever your something is (A Numeric array, for example)

* You have a few menu items from the wxPyPlot demo that don't really
make much sense.

Enjoy,

-Chris

wxPyPlot2.py (55.2 KB)

Gordon Williams wrote:

I tried to run your code using the included demo and only the points showed
up. There was no grid, labels, etc.

Let me guess.. you're running Windows. I didn't test the most recent
version on Windows. Now I have, and you're right, the Axis did not get
shown. I figured this was a bug I had found quite some time ago that I
never identified...under some cercumstances, dc.DrawBitmap() doesn't
work under Windows.

Now I've found it...yeah!!! I don't know if this is my old bug or not,
but the bug in this case is that DC.DrawBitmap() doesn't work under
Windows if the Bitmap is selected into another MemoryDC at the time of
the call. I've added a line that deleted the previous MemDC before
calling DrawData(), and it works on Windows now. I've enclosed my latest
version.

Robin...is this a bug or a feature? In any case, I've added a note to
the Platform Inconsistences section of the Wiki.

-Chris

-- --
Christopher Barker, Ph.D.
Oceanographer
                                                
NOAA/OR&R/HAZMAT (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception

Chris.Barker@noaa.gov

wxPyPlot2.py (55.4 KB)

OOPS.

The version I just posted saves a .bmp file of the plot whenever it
re-draws the data. It was there for testing, and I forgot to remove it.
Try this one instead.

-Chris

wxPyPlot.py (55.3 KB)

···

--
Christopher Barker, Ph.D.
Oceanographer
                                        
NOAA/OR&R/HAZMAT (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception

Chris.Barker@noaa.gov

Chris Barker wrote:

Now I've found it...yeah!!! I don't know if this is my old bug or not,
but the bug in this case is that DC.DrawBitmap() doesn't work under
Windows if the Bitmap is selected into another MemoryDC at the time of
the call. I've added a line that deleted the previous MemDC before
calling DrawData(), and it works on Windows now. I've enclosed my latest
version.

Robin...is this a bug or a feature? In any case, I've added a note to
the Platform Inconsistences section of the Wiki.

It's probably a limitation imposed by MS Windows.

···

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