Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Only the run method is actually running in a diffrent thread. The problem with your code is that you try to start the thread more than one time (in the echo method). You should check if the thread is already started (look at self._stop) before starting.</p> <pre><code>def echo (self, arg=None, sep=' ', end='\n', rndcase=True, txtspeed=0.03, bnum=0, spsw=True): print cursave, self.cursor_invisible() # do you have to do all this ? # c0m4: Only if you need all of those to be accessible for the spin object when echo ends self.arg=arg self.sep=sep self.end=end self.rndcase=rndcase self.txtspeed=txtspeed self.bnum=bnum self.spsw=spsw pos=0 cmd, txt = [reset], [] spsw=True last_colour='' txtpos=0 if arg: # test if spinner is wanted and set the text position to be moved across a bit to allow for it if spsw is True: txtpos=4 self.start() </code></pre> <p>The last line if where the troubles start. It is not possible to start a thread more then once. Therefore you need to check if the thread is running before you restart it. Add something like </p> <pre><code>self.running = False </code></pre> <p>to your init method, and then set it in the run method</p> <pre><code>self.running = True </code></pre> <p>Then you can check the status of the object (thread running or not) like this:</p> <pre><code>if not self.running: self.start() </code></pre> <p>If you need to run the initial portion of run regardless, you should put that in a separate method, like this:</p> <pre><code>def resetThread(): self.pos = 0 </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload