[wxPython] Draw a line with wxPython

I'm not using Linux but Windows NT... Sorry.

But, if I well understood, it's not possible to draw lines with just
wxPython?!
I'm very surprised because it's possible with Tkinter.

So, wxOGL is the best way to do this stuff? Better than Piddle or an
other one...

Thank you all for replying,

Carole.

(Oops. Sorry 'bout that last [empty] message.)

If you're using Red Hat Linux or some variant that uses RPM, you might

want to look at Mesa, which, if memory serves me, will help out the
wxOGL stuff, by supplying the underlying libs.

>
> > Hi,
>
> Hello...
>
> > I'm a new user of wxPython.
>
> My commiserations :wink:
>
> > I would like to draw some lines in a window in order to make a

road map.

> >
> > I think I need a "canvas" or something like this, to draw the

lines on

> > it. But I don't know how I can do this.
> > Furthermore: is wxPython sufficient to do this or do I need other
> > modules like Piddle?
>
> I think you'll probably be wanting wxOGL - it supplies canvas,

shapes,

> and other graphical toolkit stuff. Some of it even works the way

you'd

> expect it to (but don't count on it). Have fun....
>
> Regards,
> Denny
>
> ----------------------------------------------------------
> Denny De La Haye \ www-edc.eng.cam.ac.uk/~djd33
> Engineering Design Centre, \ www-edc.eng.cam.ac.uk
> Department of Engineering, \ www.eng.cam.ac.uk
> University of Cambridge, UK \ www.cam.ac.uk
> ----------------------------------------------------------
> "Only two things are infinite, the universe and human stupidity,
> and I'm not sure about the former." (Albert Einstein)
>
>
> _______________________________________________
> wxpython-users mailing list
> wxpython-users@lists.wxwindows.org
> http://lists.wxwindows.org/mailman/listinfo/wxpython-users
>

--
Kevin Cole, RHCE, Linux Admin | E-mail: kjcole@gri.gallaudet.edu
Gallaudet Research Institute | WWW:

http://gri.gallaudet.edu/~kjcole/

···

On Thu, 5 Apr 2001, Denny De La Haye wrote:
> On Thu, 5 Apr 2001, Carole Valentin wrote:
Hall Memorial Bldg S-419 | Voice: (202) 651-5135
Washington, D.C. 20002-3695 | FAX: (202) 651-5746

Carole Valentin wrote:

But, if I well understood, it's not possible to draw lines with just
wxPython?!
I'm very surprised because it's possible with Tkinter.

So, wxOGL is the best way to do this stuff? Better than Piddle or an
other one...

First of all, as a couple of posters have mentioned, it is, of course,
quite possible to draw whatever you want with wxPython. What wxPython
does not provide is a high level canvas like TKs. This is unfortunate,
but there is work being done on a wxCanvas, which may even be better
that TKs. Hopefully, it will be it good shape and ready to be wrapped up
for wxPython before too long.

In the meantime, your options are:

Use the native DCs. If all you are doing is drawing a fairly simple
picture, they work fine. See the wxScrolledWindow demo, as well as other
stuff people have already posted.

Use wxOGL (Object Graphics Library). It is designed to provide drawing
and manipulation of graphics objects like rectangles, etc. It was
written to be used for a CASE tool, and has good support for things like
drawing boxes with lines connecting them. When I looked at it a while
ago, I concluded that it wasn't ideal as a general purpose drawing
canvas for a number of reasons, so I've used DCS myself.

Use Piddle. Piddle was designed to be a output neutral drawing
framework, so that the same drawing code should work with different GUI
toolkits (wxPython, TK, etc) as well as file output (PS, PDF, GIF, etc).
If you want this capability, it is a good way to go. It is not, however,
much higher level than the wxDCs, so if you only want wxPython drawing,
there isn't much advantage.

Use wxGLcanvas. I havn't used it, but it gives you the ability to use
OpenGL. The strength here is high performance 3-d drawing, this may or
may not help you for your application.

There is another option, that may be perfect for your application. I
have written a class that provides a high level canvas for drawing
things in "world" . It has the following properties:

Arbitrary coordinates: This means that you don't have to deal with
translating your natural coordinates to pixels yourself.

Object based, so that individual objects (lines, circles, rectangles,
polygons, etc) have a set of properties that can be adjusted without
re-generating them.

Fully zoomable and scrollable, with no pre-set bounding box.

Allows coordinate tranformations. At this point the only one I have
implimented is a mercator projection, so that you can display maps in
Lat-Long coordiantes and have it projected properly. (well, that and no
transformation)

Double buffered, so that it re-draws instantly when the window is
uncovered.

Implimentation:

It is written entirely in Python, using Numeric for speed (you do need
to have a working Numeric installation to use it). Ideally, it (or part
of it anyway) should be written in C++ for substantial perfomance
benifits. At the moment, it really is fast enough if you are working
with up to hundreds of objects, but with thousands, it gets pretty slow.
The wxCanvas Project may provide most of this functionality (plus much
more), so I am holding out to see what happens there.

Status:

I wrote it with a particular application in mind, but also because I
often need to display something that is in arbitrary coordinates, and I
got really sick of dealing with pixels. It also took me a while to
figure out how to get zooming and scrolling to work, and I didn't want
to keep re-implimenting that.

As it happens, I have another project on a tight deadline, so I have not
done anything "real" with it yet. I do have it bundled up with a demo
application, that I wrote to test it out.

I have developed it on Linux with wxGTK. There is no reason it shouldn't
work on other platforms, but I havn't tested it anywhere else yet.

My intent is to get it into some state of completeness, document it a
little bit and then give it out to the world (perhaps Robin could add it
to the cool contribs section of the demo) It is not in that state yet,
but if someone wants to use it anyway, send me a note, and I'll send a
copy on to you. If you want to fix/add to/improve it, I'd be glad for
the help. I could even set up a CVS server for it. I'd also love
feedback from both programmers on how it could be better
designed/written, and users on how it could be easier to use.

Missing Features:

Lots, but the big one is that there is no way to tie an event to
clicking on an object. This is something I would really like to add, but
it's a pretty big addition so I have no idea when I will get around to
it.

Let me know if you are interested, and I'll send you a copy. I may even
set up a web page for it!

-Chris

···

--
Christopher Barker,
Ph.D.
ChrisHBarker@home.net --- --- ---
http://members.home.net/barkerlohmann ---@@ -----@@ -----@@
                                   ------@@@ ------@@@ ------@@@
Oil Spill Modeling ------ @ ------ @ ------ @
Water Resources Engineering ------- --------- --------
Coastal and Fluvial Hydrodynamics --------------------------------------
------------------------------------------------------------------------

My intent is to get it into some state of completeness, document it a
little bit and then give it out to the world (perhaps Robin could add it
to the cool contribs section of the demo)

Sounds great! What do you think of adding it to the wxPython distribution
in wxPython.lib or perhaps a subpackage?

It is not in that state yet,
but if someone wants to use it anyway, send me a note, and I'll send a
copy on to you.

I'd like to see it.

···

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