Keyboard input magnetic stripe reader and wxPython

B

Brian

This probably has a simple answer:
I need to capture data from a magnetic stripe reader, which is fed
through the keyboard port. I want to use wxPython for the application
(under Windows). I can read this data in a text control, but only if
the text control has the focus.

Ideally, I'd use a text control that could be made invisible, and that
could be forced to have the focus programmatically. That way I could
use the other text control methods, and not have to write these
methods from scratch.

In other words, does a method exist in wxPython that will let me catch
keyboard characters 'on demand' and store them in a string buffer?

If you're curious, the application is a museum kiosk, where visitors
will be able to swipe their credit cards, driver's licenses, etc., and
see what information is stored there. I'd like to build this from as
many high-level objects as possible.

Thanks,
Brian
 
R

Roger Binns

Brian said:
If you're curious, the application is a museum kiosk, where visitors
will be able to swipe their credit cards, driver's licenses, etc., and
see what information is stored there. I'd like to build this from as
many high-level objects as possible.

I had a play with one of those once. It was amazing what was on all
my cards. However it turned out that my MCI calling card crashed
the unit, and it took 4 hours for them to get it back up again!

Anyway the answer to your question is to call SetFocus on your
window/control. (See the documentation for wxWindow.SetFocus).
You can use EVT_KILL_FOCUS to be notified when losing focus
and grab it back again. As for having an invisible control,
I would recommend just making it one pixel by one pixel
and setting the foreground colour to be the same as the
background colour.

Roger
 
B

Brian

This probably has a simple answer:

Yes it does!
From the parent wxWindow of wxTextCtrl...

text1=wxTextCtrl(....etc....)
text1.SetFocus()
text1.Hide()

-Brian
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top