How do I respond to text events

There are a handful of command events generated by wx.TextCtrl widgets that you may want to use. All of these events are bound to the text widget in question, so you need to pass it to the Bind method to catch the event, as in the following:

frame.Bind(wx.EVT_TEXT, frame.OnText, text)

Table 7.8 describes these command events.

Table 7.8 Events of wx.TextCtrl

Event

Description

EVT_TEXT

Generated when the text in the control changes. This event is generated both in response to user input, and to the programmatic change via the SetValue() method.

EVT_TEXT_ENTER

Generated when the user presses Enter in a text control with the wx.te_process_enter style set.

EVT_TEXT_URL

If on a Windows system, and wx.te_rich or wx.te_rich2 is set, and wx.TE_AUTO_URL is also set, then this event is triggered when a mouse event occurs over a URL within the text control.

EVT_TEXT_MAXLEN

If a maximum length is specified for the control using SetMaxLength(), then this event is triggered when the user attempts to enter a string longer than the maximum length. You might use this, for example, to display a warning message to the user.

Next, let's discuss controls that are designed primarily to take mouse input. The simplest of these is a button.

Was this article helpful?

0 0

Post a comment