[wxPython] Graph drawing / panel / frame

Mike Gilfix, Drawing / Panel / Frame
Warning, serious discussion ahead :slight_smile:

My advice: don't draw a graph directly onto a panel. Create a class eg
'plotarea' derived from a wxWindow, which contains everything for drawing
you graph (paint events, plot routines, etc). Put this 'plotarea widget' on
the panel that is in the frame. The panel has automatically the client size
of the frame. The plotarea has its own position and size properties and can
be placed anywhere on the panel.

I wrote some applications using intensive drawing of mathematical functions
(real or complex functions). They used what is described above. see
http://www.chez.com/spinecho

Jean-Michel Fauth, Martigny, Switzerland

Jean-Michel Fauth wrote:

My advice: don't draw a graph directly onto a panel. Create a class eg
'plotarea' derived from a wxWindow, which contains everything for drawing
you graph (paint events, plot routines, etc). Put this 'plotarea widget' on
the panel that is in the frame. The panel has automatically the client size
of the frame. The plotarea has its own position and size properties and can
be placed anywhere on the panel.

I've done something siilar for ddrawing stuff, but I always derive form
wxPanel, rather than wxWindow. My understanding is that wxPanel hadds a
few features that I'd want, but I'm not too sure what they are. Why
would want to derive such a class from wxWindow vs. wxPanel?

-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

Chris Barker wrote:

Jean-Michel Fauth wrote:

> My advice: don't draw a graph directly onto a panel. Create a class eg
> 'plotarea' derived from a wxWindow, which contains everything for drawing
> you graph (paint events, plot routines, etc). Put this 'plotarea widget' on
> the panel that is in the frame. The panel has automatically the client size
> of the frame. The plotarea has its own position and size properties and can
> be placed anywhere on the panel.

I've done something siilar for ddrawing stuff, but I always derive form
wxPanel, rather than wxWindow. My understanding is that wxPanel hadds a
few features that I'd want, but I'm not too sure what they are. Why
would want to derive such a class from wxWindow vs. wxPanel?

As I understand it, most of the added features of wxPanel are to support
dialog-like functionality -- tabbing between contained controls and such like.
If you're not holding multiple controls, there's probably very little gain in
using a wxPanel over a wxWindow.

Depending on your usage, another possibility might be to derive from
wxStaticBitmap, and add methods that will draw into the contained bitmap. This
might be a bit clunky, however, if you're wanting to do anything that can't
easily be done on a wxBitmap.

Jeff Shannon
Technician/Programmer
Credit International

Jeff Shannon wrote:

As I understand it, most of the added features of wxPanel are to support
dialog-like functionality -- tabbing between contained controls and such like.
If you're not holding multiple controls, there's probably very little gain in
using a wxPanel over a wxWindow.

Thanks for the clarification. I'll try using a wxWindow next time ans
see if anything works differently for me.

Depending on your usage, another possibility might be to derive from
wxStaticBitmap, and add methods that will draw into the contained bitmap. This
might be a bit clunky, however, if you're wanting to do anything that can't
easily be done on a wxBitmap.

This doesn't sound like such a great idea, but I am double buffering, so
I do all the drawing to an offscreen bitmap anyway. At first thought,
I'm thinking I wouldn't be able to capture the coordiantes of mouse
clicks, however...

-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

As I understand it, most of the added features of wxPanel are to support
dialog-like functionality -- tabbing between contained controls and such

like.

If you're not holding multiple controls, there's probably very little gain

in

using a wxPanel over a wxWindow.

Correct.

路路路

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