[wxPython] wxGLCanvas demo

Howdy,

One of the nice things about using OpenGL with Tkinter is the convenient canvas classes provided with the PyOpenGL distribution. These make it super convenient to throw together a quick interactive OpenGL app. Since I like wxPython a lot more than Tkinter, I decided to try and implement the same functionality in wxPython. The results are attached to this message.

wxGLBase.py defines two classes exposing OpenGL canvases, RawOpengl and Opengl, which behave similarly to the equivalent classes in OpenGL.Tk.
drawcube.py and square.py are little demos.

If nothing else, this might be useful to someone who is figuring out how to deal with OpenGL in wxPython. The demo is, unfortunately, not all that much help.

I haven't put much (any) effort into documenting wxGLBase yet, but if there is any interest in these things, I'd be happy to do so.

If anyone takes a look at the way autospin is handled and is horrified, please let me know. I'm not completely certain that this is the best way to deal with IdleEvents.

-greg

wxGLBase.py (9.87 KB)

square.py (2.36 KB)

drawcube.py (1.74 KB)

One of the nice things about using OpenGL with Tkinter is the convenient
canvas classes provided with the PyOpenGL distribution. These make it
super convenient to throw together a quick interactive OpenGL app. Since

I

like wxPython a lot more than Tkinter, I decided to try and implement the
same functionality in wxPython. The results are attached to this message.

wxGLBase.py defines two classes exposing OpenGL canvases, RawOpengl and
Opengl, which behave similarly to the equivalent classes in OpenGL.Tk.
drawcube.py and square.py are little demos.

Very awesome Greg! I wish I knew more about OpenGL so I could figure out
how you did what you did! <wink>

I haven't put much (any) effort into documenting wxGLBase yet, but if

there

is any interest in these things, I'd be happy to do so.

With some good docs in the module, and maybe some different naming
conventions, I'll add it to the wxPython.lib package.

If anyone takes a look at the way autospin is handled and is horrified,
please let me know. I'm not completely certain that this is the best way
to deal with IdleEvents.

This is the right way to do what you did:

  def wxIdle(self,event):
    if self.autospin:
      self.do_AutoSpin(event)
      event.RequestMore()

Although I wonder if the do_AutoSpin method needs to be called that often?
This way it will get called as fast as the system will allow, effectivly
maxing out the CPU. Perhaps a timer would work just as well for the
animation, but be less resource intensive.

···

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

_______________________________________________
wxPython-users mailing list
wxPython-users@lists.sourceforge.net
http://lists.sourceforge.net/mailman/listinfo/wxpython-users

I'm working on something where I want to capture mouse events on a panel
that I have drawn on. More specifically, I want to be able to do
something on a click, and something else on a drag with the left mouse
button.

There doesn't seem to be what I would expect: a "EVT_LEFT_DRAG" event.
Instead, looking at the demo, and the wxWindows code, it seems there is
an EVT_MOTION enent that I have to capture. This means that every time
the mouse is moved, whether a button is pressed or not, my mouse motion
handler is called, and I have to check to see if it is a drag enent, and
if so, I have to have some way of knowing which button is pressed. This
means that that handler is going to be getting called constantly (which,
frankly doesn't seem to slow anything down), but also that I have to do
a lot of logic to figure out what exactly is happening.

It seems that I am doing much lower level stuff than I should have to.
Am I missing something?

-Chris

···

--
Christopher Barker,
Ph.D.
cbarker@jps.net --- --- ---
http://www.jps.net/cbarker -----@@ -----@@ -----@@
                                   ------@@@ ------@@@ ------@@@
Water Resources Engineering ------ @ ------ @ ------ @
Coastal and Fluvial Hydrodynamics ------- --------- --------
------------------------------------------------------------------------
------------------------------------------------------------------------

_______________________________________________
wxPython-users mailing list
wxPython-users@lists.sourceforge.net
http://lists.sourceforge.net/mailman/listinfo/wxpython-users

Use EVT_MOTION along with EVT_LEFT_DOWN.
Bob

···

At 01:30 PM 12/15/00 -0800, you wrote:

I'm working on something where I want to capture mouse events on a panel
that I have drawn on. More specifically, I want to be able to do
something on a click, and something else on a drag with the left mouse
button.

There doesn't seem to be what I would expect: a "EVT_LEFT_DRAG" event.
Instead, looking at the demo, and the wxWindows code, it seems there is
an EVT_MOTION enent that I have to capture. This means that every time
the mouse is moved, whether a button is pressed or not, my mouse motion
handler is called, and I have to check to see if it is a drag enent, and
if so, I have to have some way of knowing which button is pressed. This
means that that handler is going to be getting called constantly (which,
frankly doesn't seem to slow anything down), but also that I have to do
a lot of logic to figure out what exactly is happening.

It seems that I am doing much lower level stuff than I should have to.
Am I missing something?

-------------------------------------------------
Robert B. Klimek
NASA Glenn Research Center
robert.klimek@grc.nasa.gov
(216) 433-2837
--------------------------------------------------

_______________________________________________
wxPython-users mailing list
wxPython-users@lists.sourceforge.net
http://lists.sourceforge.net/mailman/listinfo/wxpython-users

"Robert B. Klimek" wrote:

>There doesn't seem to be what I would expect: a "EVT_LEFT_DRAG" event.
>Instead, looking at the demo, and the wxWindows code, it seems there is
>an EVT_MOTION enent that I have to capture. This means that every time
>the mouse is moved, whether a button is pressed or not, my mouse motion
>handler is called, and I have to check to see if it is a drag enent, and
>if so, I have to have some way of knowing which button is pressed. This
>means that that handler is going to be getting called constantly (which,
>frankly doesn't seem to slow anything down), but also that I have to do
>a lot of logic to figure out what exactly is happening.
>
>It seems that I am doing much lower level stuff than I should have to.
>Am I missing something?
>

Use EVT_MOTION along with EVT_LEFT_DOWN.
Bob

Thanks, I have it working now, but it seems that what I now am left with
is having to pass virtually all the mouse events through the same
handler, because I don't know whether the mouse is going to be dragged
or not when a EVT_LEFT_DOWN happens, for instance. Then, when an
EVT_MOTION happens, I don't know whether it is a simple move or a drag,
and whoch button is pressed if it is a drag. The net result is that
every mouse event has to be passed through one handler, that figures all
this out. If there was an EVT_LEFT_DRAG event, then I could process
right and left button events separately, and move and drag events
separately.

···

--
Christopher Barker,
Ph.D.
cbarker@jps.net --- --- ---
http://www.jps.net/cbarker -----@@ -----@@ -----@@
                                   ------@@@ ------@@@ ------@@@
Water Resources Engineering ------ @ ------ @ ------ @
Coastal and Fluvial Hydrodynamics ------- --------- --------
------------------------------------------------------------------------
------------------------------------------------------------------------

_______________________________________________
wxPython-users mailing list
wxPython-users@lists.sourceforge.net
http://lists.sourceforge.net/mailman/listinfo/wxpython-users

I'm working on something where I want to capture mouse events on a panel
that I have drawn on. More specifically, I want to be able to do
something on a click, and something else on a drag with the left mouse
button.

There doesn't seem to be what I would expect: a "EVT_LEFT_DRAG" event.
Instead, looking at the demo, and the wxWindows code, it seems there is
an EVT_MOTION enent that I have to capture. This means that every time
the mouse is moved, whether a button is pressed or not, my mouse motion
handler is called, and I have to check to see if it is a drag enent, and
if so, I have to have some way of knowing which button is pressed. This
means that that handler is going to be getting called constantly (which,
frankly doesn't seem to slow anything down), but also that I have to do
a lot of logic to figure out what exactly is happening.

It seems that I am doing much lower level stuff than I should have to.
Am I missing something?

-Chris

--
Christopher Barker,
Ph.D.
cbarker@jps.net --- --- ---
http://www.jps.net/cbarker -----@@ -----@@ -----@@
                                   ------@@@ ------@@@ ------@@@
Water Resources Engineering ------ @ ------ @ ------ @
Coastal and Fluvial Hydrodynamics ------- --------- --------
------------------------------------------------------------------------
------------------------------------------------------------------------

_______________________________________________
wxPython-users mailing list
wxPython-users@lists.sourceforge.net
http://lists.sourceforge.net/mailman/listinfo/wxpython-users

···

----- Original Message -----
From: "Chris Barker" <cbarker@jps.net>
To: <wxpython-users@lists.sourceforge.net>
Sent: Friday, December 15, 2000 1:30 PM
Subject: [wxPython] Mouse event questions

_______________________________________________
wxPython-users mailing list
wxPython-users@lists.sourceforge.net
http://lists.sourceforge.net/mailman/listinfo/wxpython-users

Hi all,

How do I change the mouse cursor? I don't see any examples of this in
the demo, and I have looked in the docs, and found wxCursor, but havn't
found how to actually use it to set the mouse cursor.

In my case I want to change the cursor depending on the mode a custom
window I am writing is in. Any example would be better than what I have
now....which is no idea!

Thanks,

-Chris

···

--
Christopher Barker,
Ph.D.
cbarker@jps.net --- --- ---
http://www.jps.net/cbarker -----@@ -----@@ -----@@
                                   ------@@@ ------@@@ ------@@@
Water Resources Engineering ------ @ ------ @ ------ @
Coastal and Fluvial Hydrodynamics ------- --------- --------
------------------------------------------------------------------------
------------------------------------------------------------------------

_______________________________________________
wxPython-users mailing list
wxPython-users@lists.sourceforge.net
http://lists.sourceforge.net/mailman/listinfo/wxpython-users

How do I change the mouse cursor? I don't see any examples of this in
the demo, and I have looked in the docs, and found wxCursor, but havn't
found how to actually use it to set the mouse cursor.

In my case I want to change the cursor depending on the mode a custom
window I am writing is in. Any example would be better than what I have
now....which is no idea!

See wxScrolledWindow.py in the demo.

···

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

_______________________________________________
wxPython-users mailing list
wxPython-users@lists.sourceforge.net
http://lists.sourceforge.net/mailman/listinfo/wxpython-users

Robin Dunn wrote:

> How do I change the mouse cursor? I don't see any examples of this in
> the demo, and I have looked in the docs, and found wxCursor, but havn't
> found how to actually use it to set the mouse cursor.

See wxScrolledWindow.py in the demo.

Thanks Robin, I can't believe I didnt' see that, I've actually spent a
lot of time examining the wxScrolledWindow demo!

-Chris

···

--
Christopher Barker,
Ph.D.
cbarker@jps.net --- --- ---
http://www.jps.net/cbarker -----@@ -----@@ -----@@
                                   ------@@@ ------@@@ ------@@@
Water Resources Engineering ------ @ ------ @ ------ @
Coastal and Fluvial Hydrodynamics ------- --------- --------
------------------------------------------------------------------------
------------------------------------------------------------------------

_______________________________________________
wxPython-users mailing list
wxPython-users@lists.sourceforge.net
http://lists.sourceforge.net/mailman/listinfo/wxpython-users