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:
self.window2.transferArea.AppendText(it)
and i bind it to check-box:
if self.cb1.GetValue():
task = SearchThread()
task.start()
if self.cb2.GetValue():
pass
if self.cb3.GetValue():
pass
if self.cb4.GetValue():
pass
if self.cb5.GetValue():
pass
if self.cb6.GetValue():
pass
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:
wx.CallAfter(self.window2.transferArea.AppendText(it))
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 :)