pyqt4 - QObject and QThread relations -
i have pyqt4 gui allows me import multiple .csv files. i've created loop goes through list of tuples have following parameters (filename + location of file, filename, bool,bool, set of dates in file)=tup. i've created several classes gui refers in order pull parameters off projects profile. let's call class profile(). have class has lot of functions based on formatting, such datetime, text edits,etc...let's call classmyformatting(). created qthread class created each file in list, , 1 called import_file(qthread). , lets class takes in few parameters __init__(self,tup).
my ideal goal able make independent instance of myformatting() , profile() import_file(qthread). trying head around on how utilize qobject capabilities solve this..but keep getting error thread being destroyed while still running.
for tup in importedlist: importfile = import_file(tup) self.connect(importfile,qtcore.signal('savedfile(pyqt_pyobject()'),self.printstuffpassed) importfile.start() i thinking of having 2 classes declared
myformatting(qobject): def __init__(self): qobject.__init__(self) def func1(self,stuff): dostuff def func2(self): morestuff profile(qobject): def __init__(self): qobject.__init__(self) def func11(self,stuff): dostuff def func22(self): morestuff and qthread:
import_file(qthread): def __init__(self,tup): qthread.__init(self) common_calc_stuff = self.calc(tup[4]) f = open(tup[0] + '.csv', 'w') self.tup = tup # thought of pulling instance thread self.mf = myformatting() self.mf_thread = qtcore.qthread() self.mf.movetothread(self.mf_thread) self.mf_thread.start() self.prof = profile() self.prof_thread = qtcore.qthread() self.prof.movetothread(self.prof_thread) self.prof_thread.start() def func33(self,stuff): dostuff self.prof.func11(tup[4]) def func44(self): morestuff def run(self): if self.tup[3] == true: self.func33 self.mf.func2 elif self.tup[3] ==false: self.func44 if self.tup[2] == true: self.prof.func22 self.emit(qtcore.signal('savedfile()',) am totally thinking of wrong way? how can keep of same structure have coding , still able implement multithreading , not have same resource tapped @ same time, think reason why qui keeps crashing? or how can make sure each instance of objects turned off don't interfere other instances?
Comments
Post a Comment