in reply to Re^3: Tk and Threads
in thread Tk and Threads

Pausing and resuming is great. But what I need is a restart.

Replies are listed 'Best First'.
Re^5: Tk and Threads
by BrowserUk (Patriarch) on Dec 22, 2010 at 11:04 UTC
    But what I need is a restart.

    What do you mean by "a restart"?

    Do you mean abandon the thread regardless of what it is doing and start a new one?

    Or, undo everything the thread has done to this point and have it start over?

    In short. What are you trying to achieve?

    And please don't start repeating your talk about IDLE & WORK states, because without definition in concrete terms of what actual happens when a transition from one state to the other occurs, they are nothing more than meaningless words!


    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.

      With a restart I mean undoing everything the thread has done and then starting it again.

      I have a TK Gui. The user is pressing the start button. Then a long action is started (in a thread). There is also a cancel button. If the user is pressing the cancel button then the long action shall be stopped immediately. Everything what has been done until now shall be undone (e.g. deleting a file which was created by this thread). When the user then again is pressing the start button the long action shall be started again. Because there are a lot of other GUI-Elements which contain information for the thread a new pressing of the start button has to give this information to thread.

        I've shown you how to signal from buttons on your Tk gui to your threads.

        What happens when those signals are received is just a matter of programming.

        If you need to delete a file...program the signal handler code to delete the file.

        Need then to start the thread over, create a new thread and abandon this one.


        Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
        "Science is about questioning the status quo. Questioning authority".
        In the absence of evidence, opinion is indistinguishable from prejudice.