Hi all,
I’m intending to use wxpython to create a onscreen joystick, something like this.
Does anyone have any experience with this? or is it possible to have another package integrated with wxpython?
Rey
Hi all,
I’m intending to use wxpython to create a onscreen joystick, something like this.
Does anyone have any experience with this? or is it possible to have another package integrated with wxpython?
Rey
I'm intending to use wxpython to create a onscreen joystick, something
like this.
Is the idea that the user would click the mouse on the grey circle and
move it around?
Does anyone have any experience with this? or is it possible to have
another package integrated with wxpython?
Not sure what you mean by another package -- but this would be a bit
fiddly, but not too had to do in wxPython:
- You'll want to read up on custom drawing and mouse event handling with
wxPython -- the Wiki is good for this.
- Then derive a class from wxPanel.
- Write a draw method that draws the whole picture you have there. I would
probably draw the backgound in one methd, and the moving circle separately
-- maybe double buffer the background, but that may be overkill (see teh
wiki for couble buffer). All drawing shoud happen in the Paint handler.
-bind you mouse events:
- in mouse-down you'll want to check if the mouse hit the grey dot --
pretty easy with just a distance fmr the center check. then set a "hit" flag
- in mouse-move, you'll check if the mouse button is down, then if the
grey dot is "hit" -- if so, then you move the center of the dot. Once
moved, you call self.Refresh(); self.Update() -- that will force a paint
event to update the screen.
- in mouse-up, you reset the "hit" flag
I think that's about it.
NOTE: if you want this so be scalable, then you may want to use
wx.lib.floatcanvas -- it will handle all the scaling and drawing for you --
as well as the mouse hit-testing.
Also -- this would make a nice little demo for the Wiki if you do get it
done. -- or maybe even a module for wx.lib
HTH,
-Chris
On Wed, Feb 4, 2015 at 10:13 PM, Chong Hong Rui <reyreyrey1989@gmail.com> wrote:
Rey
--
You received this message because you are subscribed to the Google Groups
"wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to wxpython-users+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
Christopher Barker, Ph.D.
Oceanographer
Emergency Response Division
NOAA/NOS/OR&R (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