Hi Alan, Thanks, very much, for your time answering my question. I ended up using global variables for all the attributes I had to share between the MainWindow class and the thread, and it worked. I am sure there are better alternatives, but since it was just a couple of attributes, the code looks ok. Some responses in line at [SM]
On Sun, Aug 11, 2013 at 12:05 PM, Alan Gauld <alan.ga...@btinternet.com>wrote: > On 09/08/13 16:50, SM wrote: > > Sorry I only just picked this up. > > > (ex: self.tab_fw = QtGui.QWidget(), self.tab_ann = QtGui.QWidget(), >> etc), its own textEdit window and its own progress bar widget. >> All the tabs are defined within this single class - they are not >> instances of the class, as the tabs are distinct from each other. All of >> that is working really well. >> > > OK, I'll assume the structure looks like > > MainGUIWindow > - Tab1 > - TextEdit1 > - ProgressBar1 > - any other widgets on tab1 > - Tab2 > - TextEdit2 > - ProgressBar2 > - any other widgets on tab2 > - Tab3 > - TextEdit3 > - ProgressBar3 > - any other widgets on tab3 > [SM] Yes > > And that both the TextEdit and progress bar widgets are part of > the Qt framework/library? So there are 3 distinct progress bar instances, > one per tab? [SM]: Yes, that is right. > > > an added feature, I am now asked to have a "progress bar" widget >> which appears when an operation is going on, to tell the user that >> he/she has to wait. >> > > Is this an extra (4th?) progress bar or is this the ones already described > as being in the tabs? > [SM] The latter. There are just 3 tabs and 3 progress bars > > Also, when you say "appears" do you mean its invisible until the operation > starts? Or is it visible but inactive (maybe greyed out?) [SM] Wrong choice of word on my part. I should have said, " widget which swings horizontally" > > > [SM]: Yes. I shouldn't say duplicated, but each tab has a different >> progress bar of its own. In the example, I was quoting the code for just >> on tab. The others will be implemented similarly. >> > > OK So I'm again going to assume: > > A total of 1 progress bar per tab. The "added feature" is what these bars > are addressing? [SM]: yes > > > So I am running two threads - first one is the progressbar >> widget which has a rectangular slab spinning sideways to >> indicate that the operation is going on. >> > > I usually expect a progress bar to indicate the percentage complete but > this sounds like its just a spinning eggshell activity indicator. Is that > correct? You have no progress value indication? [SM] Yes, it is more of a egg-whatever.... It just spins horizontally as opposed to showing the percentage of work done. That is part of the requirement. > > > The second thread is the one which is actually doing the operation. >> > > I have a flag that the second thread sets after the job is done > > OK, again I'll assume we are dealing with just an activity indicator not a > value display. [SM] yes > > > and stops spinning and gets out of the loop when the flag is set. >> I >> have that working as well. >> > > OK, Good the picture is building. > > > [SM]: I did start out with a timer. But due to my lack of experience >> with usage of timer in Python, the code I wrote was running sequentially >> > > That sounds like you tried to use a Python native timer. Normally in a GUI > the toolkit (Qt in this case) provides a timer event that triggers > via the normal event mechanism. You set the timer, the event arrives and > you do something then reset the timer for the next time round. > > I found this page that describes the Qt approach (which includes > multi-shot timers) and links to more detailed examples etc. > > http://qt-project.org/doc/qt-**4.7/timers.html#id-fd46b213-** > 376e-4636-a7d2-8ae899de1e11<http://qt-project.org/doc/qt-4.7/timers.html#id-fd46b213-376e-4636-a7d2-8ae899de1e11> > [SM] Thanks, very much, for the link. I will go over it. In my opinion, if the timer works, using it is less complicated than using threads. Thanks! -SM > > The code is in C++ but should translate easily to python and PyQt. > > HTH > > -- > Alan G > Author of the Learn to Program web site > http://www.alan-g.me.uk/ > > ______________________________**_________________ > Tutor maillist - Tutor@python.org > To unsubscribe or change subscription options: > http://mail.python.org/**mailman/listinfo/tutor<http://mail.python.org/mailman/listinfo/tutor> >
_______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor