Hi Everybody!
I want to know how can I cancel and resume an event like wx.EVT_CHAR.
I am writing a code to show just some numbers and I want to avoid, for instance, the number ‘8’.
···
–
André Rodrigues da Cruz
Hi Everybody!
I want to know how can I cancel and resume an event like wx.EVT_CHAR.
I am writing a code to show just some numbers and I want to avoid, for instance, the number ‘8’.
–
André Rodrigues da Cruz
André Rodrigues da Cruz wrote:
Hi Everybody!
I want to know how can I cancel and resume an event like wx.EVT_CHAR.
I am writing a code to show just some numbers and I want to avoid, for instance, the number '8'.--
André Rodrigues da Cruz
In your event handler, you would do something like this:
<code>
keycode = event.GetKeyCode()
if keycode == WXK_NUMPAD8:
pass
event.Skip()
</code>
Notice that I just call "pass" if the user presses the "8" button.
See the docs for more info on KeyEvents: wxPython API Documentation — wxPython Phoenix 4.2.2 documentation
-------------------
Mike Driscoll
Blog: http://blog.pythonlibrary.org
Python Extension Building Network: http://www.pythonlibrary.org
Hello,
Hi Everybody!
I want to know how can I cancel and resume an event like wx.EVT_CHAR.
I am writing a code to show just some numbers and I want to avoid, for instance, the number ‘8’.
or something like the following could also be done (untested)
(Assuming you use Unicode version of wxPython)
def OnChar(self, evt):
key = evt.GetUnicodeKey()
evtchr = unichr(key)
if evtchr not in list_of_chars_to_avoid:
evt.Skip() # Let the event be processed so the character will be put in the control
else:
pass # Do nothing, will prevent the character from getting through through
On 8/6/08, André Rodrigues da Cruz andrercruz@gmail.com wrote:
–
André Rodrigues da Cruz
wxpython-users mailing list
wxpython-users@lists.wxwidgets.org
Ok Guys!
It worked!
Thank you!
2008/8/6 Cody Precord codyprecord@gmail.com
Hello,
On 8/6/08, André Rodrigues da Cruz andrercruz@gmail.com wrote:
Hi Everybody!
I want to know how can I cancel and resume an event like wx.EVT_CHAR.
I am writing a code to show just some numbers and I want to avoid, for instance, the number ‘8’.
- You can create and assign a Validator to the control (see demo)
or something like the following could also be done (untested)
(Assuming you use Unicode version of wxPython)
- mytxtctrl.Bind(wx.EVT_CHAR, self.OnChar)
def OnChar(self, evt):
key = evt.GetUnicodeKey()
evtchr = unichr(key)
if evtchr not in list_of_chars_to_avoid:
evt.Skip() # Let the event be processed so the character will be put in the control
else:
pass # Do nothing, will prevent the character from getting through through
–
André Rodrigues da Cruz
wxpython-users mailing list
wxpython-users@lists.wxwidgets.org
wxpython-users mailing list
–
André Rodrigues da Cruz