[wxpython-users] any tips on doing an on-screen keyboard?
Mike Driscoll
mdriscoll at co.marshall.ia.us
Fri Apr 11 07:14:47 PDT 2008
Alec Bennett wrote:
> 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:
bitmapBtn = wx.BitmapButton(self, wx.ID_ANY,
wx.BitmapFromImage(imgFile), name='A')
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
More information about the wxpython-users
mailing list