how to get a change in value of a textCtrl to interrupt a long process based on the textCtrl's previous value

Attached is the code for a simple dialog that takes an input name . As the name is being entered on each keystroke the name is checked for similar names using fuzzywuzzy partial matching. This process takes some time and prevents the next key entry.
Q1) How can I get the nameMatch routine to allow further key entry.

In the example code I have added a keyPress counter. The number of key presses is shown in the second textCtrl.

Q2) Why is the display of the keyPress counter not immediate even though it is called before the nameMatch routine

CHANDRA KUSUMA SCHOOL, Perumahan Cemara Asri, Blok O, Jl. Cemara, Deliserdang 20371, Medan, North Sumatra, Indonesia

Phone : 061 661 6765 or 061 661 6779 Fax : 061 661 3280

FILE ATTACHMENTS:

Please be aware that The Chandra Kusuma School uses OpenOffice.org. Therefore any attachments may be in OpenOffice.org formats. You can download OpenOffice.org free from OpenOffice.org. It is open-source and the files it creates are not only smaller than the equivalent MS Office file, but also considerably less likely to contain malicious code. Wherever possible Chandra Kusuma School encourages the use of Open-Source software. We believe that in the spirit of education, students should leave school not only with an education, but also unrestricted access to the tools they have learnt to use. For more information on open source software visit the Free Software Foundation at www.fsf.org

DISCLAIMER:

This email is intended solely for the addressee. It may contain private and confidential information. If you are not the intended addressee, please take no action based on it nor show a copy to anyone. In this case, please reply to this email to highlight the error, or contact info@ChandraKusuma.com

Opinions and information in this email that do not relate to the official business of Chandra Kusuma School shall be understood as neither given nor endorsed by our school.

Chandra Kusuma School has taken steps to ensure that this email and any attachments are virus-free, but we do advise that the recipient should check that the email and its attachments are actually virus free. This is in keeping with good computing practice. We accept no responsibility for any damage or loss of data that may result in opening content sent from Chandra Kusuma School.

matchName.py (1.98 KB)

A1: Any long-running process should be run in a separate thread than the GUI. Look at the threading module. You can communicate with the thread with a callback, queue, or pubsub.

A2: Simply changing a GUI elements value does not get it displayed immediately. There are other events in the event queue
that will redraw the screen but they won’t execute until you finish processing the current event. There may be a call to allow
other events to process, but I don’t recall what it is, and that’s probably not the best solution anyway…

···

On Wednesday, January 7, 2015 8:38:09 PM UTC-5, apw...@chandrakusuma.com wrote:

Attached is the code for a simple dialog that takes an input name . As the name is being entered on each keystroke the name is checked for similar names using fuzzywuzzy partial matching. This process takes some time and prevents the next key entry.
Q1) How can I get the nameMatch routine to allow further key entry.

In the example code I have added a keyPress counter. The number of key presses is shown in the second textCtrl.

Q2) Why is the display of the keyPress counter not immediate even though it is called before the nameMatch routine

CHANDRA KUSUMA SCHOOL, Perumahan Cemara Asri, Blok O, Jl. Cemara, Deliserdang 20371, Medan, North Sumatra, Indonesia

Phone : 061 661 6765 or 061 661 6779 Fax : 061 661 3280

FILE ATTACHMENTS:

Please be aware that The Chandra Kusuma School uses OpenOffice.org. Therefore any attachments may be in OpenOffice.org formats. You can download OpenOffice.org free from OpenOffice.org. It is open-source and the files it creates are not only smaller than the equivalent MS Office file, but also considerably less likely to contain malicious code. Wherever possible Chandra Kusuma School encourages the use of Open-Source software. We believe that in the spirit of education, students should leave school not only with an education, but also unrestricted access to the tools they have learnt to use. For more information on open source software visit the Free Software Foundation at www.fsf.org

DISCLAIMER:

This email is intended solely for the addressee. It may contain private and confidential information. If you are not the intended addressee, please take no action based on it nor show a copy to anyone. In this case, please reply to this email to highlight the error, or contact info@ChandraKusuma.com

Opinions and information in this email that do not relate to the official business of Chandra Kusuma School shall be understood as neither given nor endorsed by our school.

Chandra Kusuma School has taken steps to ensure that this email and any attachments are virus-free, but we do advise that the recipient should check that the email and its attachments are actually virus free. This is in keeping with good computing practice. We accept no responsibility for any damage or loss of data that may result in opening content sent from Chandra Kusuma School.

apwatts@chandrakusuma.com wrote:

Attached is the code for a simple dialog that takes an input name . As
the name is being entered on each keystroke the name is checked for
similar names using fuzzywuzzy partial matching. This process takes
some time and prevents the next key entry.
Q1) How can I get the nameMatch routine to allow further key entry.

This is a tricky problem. Think for a moment how you would solve this
if you had people in a room. One person would have to be listening for
new keystrokes -- he's the GUI person. When he sees a new key, he would
pass it off to the "searcher". If the searcher gets a hit, he'd pass
the hit back off to the person drawing the GUI.

But if a keystroke comes in while the searcher is still looking, the GUI
person would have to interrupt the searcher and say "stop looking for
what you were looking for, and look for this instead".

Once you think about it that way, you can start to see how you'd have to
implement it. Each person becomes a thread. You would need to have a
searcher thread, and the GUI thread will send it requests, but you need
a way to interrupt the searcher thread if a new keystroke comes in while
a search is going on. That's tricky, although it can certainly be done.

···

--
Tim Roberts, timr@probo.com
Providenza & Boekelheide, Inc.