Hello, i'm back with new question :)

So i found how to make non-blocking gui with threading:

class SearchThread(threading.Thread):
    def __init__(self):
        super(SearchThread, self).__init__()

        self.window = frame.panel_one
        self.window2 = frame.panel_two

    def run(self):
        seit = self.window.inputArea.GetValue()
        se = self.window.engine.filest(seit)
        for it in se:

and i bind it to check-box:

if self.cb1.GetValue():
       task = SearchThread()
    if self.cb2.GetValue():
    if self.cb3.GetValue():
    if self.cb4.GetValue():
    if self.cb5.GetValue():
    if self.cb6.GetValue():

how You can see i have multiple check-boxes, but problem is that how to bind other threads to other check-boxes to run properly? Do i need to create new thread classes to make it work , because then i overwrite run() method on class is just can handle on function from my other file. i tried threading.Thread(target=My function), but then my GUI freezes, stops being non-blocking.

So how to make it work? What to do to have multiple threads on ? Example if i check let say third and forth check-boxes and press search, program will initiate just those threads(every thread will have different functionality, but it will return same type of information(list)).

Second question is it proper way to appendtext to textctrl like i did in run() method? or maybe there is some other way to append whole list in one go?

I red about wx.callafter, wx.postevent, wx.calllater, and i think if i run multiple threads at once and i'll not use let say wx.callafter i can get in trouble :D but in other hand then i tried to :

def run(self):
        seit = self.window.inputArea.GetValue()
        se = self.window.engine.filest(seit)
        for it in se:

It appends text on screen but give me error code too

Traceback (most recent call last):
  File "C:\Python27\lib\site-packages\wx-2.8-msw-unicode\wx\_core.py", line 14640, in <lambda>
    lambda event: event.callable(*event.args, **event.kw) )
TypeError: 'NoneType' object is not callable

I'm bit(very :D) confused with all of the threading.. Yes i red all the articles i found, and You guys suggested me. But still.. What is the easiest way to learn it? wrote much more code? trial-and-error method? :)

I really need Your help :)

5 Years
Discussion Span
Last Post by Creatinas

It is common practice to put button to start search if you are not doing incremental search while user is typing. You react to button event, not checking if user typed to inputs. It should not matter if callback function blocks until search is ready. Usually with gui you have other problem, that you want to stop entering the callback again while search is incomplete. For that purpose you could change the text of button to searching and disable it or to Cancel and do logic for interupting the search in that case.

Getting the program to actually update the window while in tight loop usually does need some tricks depending on GUI used.

Actually I am newbie on this aspect myself, and would like to learn to do text streaming in text area and progress bar moving same time. Usually you would not let user to do same time another search, at least of same type. If your searches are mutually exclusive and not simultanous, you should use actually radio button group or menu with one search button to start search.

Edited by pyTony: n/a


Thansk for reply, Yes i will disable search button until search process is going or user will stop it with stop button.

those cb1 to cb2 is checkboxes, and if statement check if it is checked or not, and if it is checked it should start thread related to that checkbox.

But how to create new threads and bind them to checkboxes, but still let GUI be non-blocking? :)

This article has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.