Leon
unread,Jan 7, 2013, 3:07:02 AM1/7/13Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to wxpytho...@googlegroups.com
hi!
I have a Text entry field (TextCtrl).
I am waiting for a special character (Barcode scanning) at the end of the text entered.
The TextCtrl should be cleared after the special character "(" is entered.
The problem: the TextCtrl is cleared, but afterwards the special character is entered. So the TextCtrl does not stay empty!
Has anybody got an idea, what I am doing wrong?
Here my code:
self.textCtrl1 = wx.TextCtrl(id=wxID_FRAME2TEXTCTRL1, name='textCtrl1',
parent=self, pos=wx.Point(32, 32), size=wx.Size(100, 21), style=0,
value='textCtrl1')
self.textCtrl1.Bind(wx.EVT_CHAR, self.OnTextCtrl1Char)
def __init__(self, parent):
self._init_ctrls(parent)
def OnTextCtrl1Char(self, event):
key_pressed = event.GetKeyCode()
if key_pressed == 40:
product_id = self.textCtrl1.GetValue()
self.textCtrl1.Clear()
time.sleep(1) # <------- waiting does not help either
self.textCtrl1.SetValue('new Text')
event.Skip()