Workaround for Invalid Textctrl carriage return event in Wxpython

Source: Internet
Author: User
This article describes a workaround for invalid Textctrl carriage return events in Wxpython. Share to everyone for your reference, as follows:

Today, using Wxptyhon's Textctrl control to develop the client encountered a problem, according to the logic of the HTML form, we should submit the query in Textctrl, but Wxpython Textctrl is very strange, Get in the car. Jump to the next control like tab action. In this case, to complete the query, either the mouse click the button, or you need to press two or more than two times.

Google, no answer, but got some useful information:

Types of events supported by Textctrl:

Evt_text: The text is changed by the user's input or by using SetValue () in the program to generate the event.

evt_text_enter: This event occurs when the user presses the ENTER key in a wx.te_process_enter-style text control.

Evt_text_url: If the Wx.te_rich or WX.TE_RICH2 style is set on a Windows system, and the Wx.te_auto_url style is set, The event is triggered when a mouse event occurs on a URL within a text control.

Evt_text_maxlen: If the maximum length of the control is specified with Setmaxlength (), the event is triggered when the user tries to enter a longer string.

For example, a warning message is displayed to the user.

Add Wxptyon Demos example, finally realized the solution:

1. When declaring an instance, you need to add a style property, such as:

Wx. Textctrl (Self,style=wx.te_process_enter)

2. Enter event for binding Textctrl

At first I used a button-like binding, and the results didn't work.
Copy the Code code as follows:

Self.element_panel.searchInput.Bind (WX. Evt_text_enter, Self.onsearch)

The correct way to declare it should be:
Copy the Code code as follows:

Self. Bind (WX. Evt_text_enter, Self.onsearch, Self.element_panel.searchInput)

Then declare the corresponding method in frame or panel to handle it.

More interested in Python related content readers can view this site topic: "Python data structure and algorithm tutorial", "Python Socket Programming Skills Summary", "Python function Tips Summary", "Python string manipulation Skills summary", " Python Introductory and Advanced Classic tutorials and Python file and directory Operations Tips Summary

I hope this article is helpful for Python program design.

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.