I've been meaning to try an onscreen keyboard in WXPython, wondering if anyone has any tips?
It only needs to interact with statictext boxes in my wxframe. In other words it doesn't need to
send keystrokes to external applications or even deal with things like modal dialog boxes.
I'm guessing the way to go is to make each keyboard button a bitmapbutton, and when clicked it
gets the selection point, appends that letter to the selection point, then sets focus back at the
selection point? Is that even possible, since when the butotn is clicked that becomes the new
selection point? I guess I can keep track of previous selection points in a timer...
Am I on the right track? Anything you'd do differently?
And since this is a whole lot of bitmap buttons that'd be nice to have moveable, should I put all
the buttons on their own panel? Woudl the panel then be moveable and hideable as a unit on my
frame? I've never made multiple panels, wondering if that's how it works.
Thanks for any tips.
···
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com
I've been meaning to try an onscreen keyboard in WXPython, wondering if anyone has any tips?
It only needs to interact with statictext boxes in my wxframe. In other words it doesn't need to
send keystrokes to external applications or even deal with things like modal dialog boxes.
I'm guessing the way to go is to make each keyboard button a bitmapbutton, and when clicked it
gets the selection point, appends that letter to the selection point, then sets focus back at the
selection point? Is that even possible, since when the butotn is clicked that becomes the new
selection point? I guess I can keep track of previous selection points in a timer...
I would use the widget's name parameter and set it to the key's label. So something like this for the "A" button:
In the bitmapBtn handler you would use probably just append the characters to the string in the statictext control and reset it to the new string, then set the focus elsewhere. I don't think you can set focus on a statictext box, so just leaving the focus on the last pressed button should be fine.
Am I on the right track? Anything you'd do differently?
And since this is a whole lot of bitmap buttons that'd be nice to have moveable, should I put all
the buttons on their own panel? Woudl the panel then be moveable and hideable as a unit on my
frame? I've never made multiple panels, wondering if that's how it works.
Thanks for any tips.
The panel would definitely be hideable. I'm not sure what you mean by moveable. If you have the panel on top of a frame, then yes, you could drag the whole thing around. Or you could use AUI to do that too, I suppose.
···
--------------
Mike Driscoll
Python Extension Building Network: http:\\www.pythonlibrary.org
Blog: http:\\blog.pythonlibrary.org
I've been meaning to try an onscreen keyboard in WXPython, wondering if anyone has any tips?
It only needs to interact with statictext boxes in my wxframe.
I'm unsure what your goals are for this, but are you sure it couldn't
use wxTextCtrls? (why: see below)
In other words it doesn't need to
send keystrokes to external applications or even deal with things like modal dialog boxes.
I'm guessing the way to go is to make each keyboard button a bitmapbutton, and when clicked it
gets the selection point, appends that letter to the selection point, then sets focus back at the
selection point? Is that even possible, since when the butotn is clicked that becomes the new
selection point? I guess I can keep track of previous selection points in a timer...
Am I on the right track? Anything you'd do differently?
How could you use a timer for that. Bitmap buttons are fine. If you
can, perhaps you could use wxTextCtrl as the output window for your
"typed" text, and if so, you could just mainly use .WriteText() and it
will take care of the insertion points for you, inserting each letter
where you left off or where the user moved the cursor.
And since this is a whole lot of bitmap buttons that'd be nice to have moveable, should I put all
the buttons on their own panel? Woudl the panel then be moveable and hideable as a unit on my
frame? I've never made multiple panels, wondering if that's how it works.
Yes, group the buttons as a "keyboard" on a panel. You can certainly
move or hide panels in lots of ways: As Mike said, you can move the
panel if it is either in its own frame or if you use, e.g. the
AUI_DockingWindowMgr (see it in the demo). Also consider looking at
the Notebook control for "hiding" it in its own tab.
···
On Fri, Apr 11, 2008 at 2:43 AM, Alec Bennett <whatyoulookin@yahoo.com> wrote:
I don't know if you already solved the problem,
but for a win-mobile emulator I needed something similar,
so here is the solution I used.
I made capture of the keyboard from the M$ Device Emulator and put it in a png-file.
I catch the left key down event on the image,
calculate the position of the click in the image,
and send the result to windows with sendkeys.
Works like a charm (but probably only under windows.
Code is below (not all special keys are in there yet).
# determine the row and col index
x, y = event.GetPosition ()
row = y / 16
xfirst = x0 [ row ]
# top row has a little bit smaller keys
if row == 0 :
col = 1 + ( x - xfirst ) / 17
else :
col = 1 + ( x - xfirst ) / 18
col = max ( 0, col )
key = kar[row][col] #print event.GetPosition () ,row,col,str(ord(key))
# if key = 0, we need to determine a special key
if ord ( key ) == 0 :
if row == 4 :
if col == 11 : key = '{LEFT}'
# now send the key to windows
SendKeys.SendKeys ( key ,
with_spaces = True,
with_tabs = True )