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

Thank you

This was the information I needed. I have to do the cleanup, the abandon and the creation of the new thread in the signal handler.

Sorry for my confusing answers and my IDLE And WORK states (Now I'll never talk again about these meaningless states). I thought that it is not allowed to create a new thread after Tk was started because this would then make the SW unstable and possibly crashing. That was the reason why I asked and asked again.

But if you say that it is ok to do it in the signal handler then it is easy and I know what I have to do.

Replies are listed 'Best First'.
Re^9: Tk and Threads
by BrowserUk (Patriarch) on Dec 22, 2010 at 12:51 UTC
    I thought that it is not allowed to create a new thread after Tk was started because this would then make the SW unstable and possibly crashing

    When you create a new thread, it gets a copy of the state of the thread it is created from.

    If you create your work thread before creating your tk gui, it does contain any of the gui stuff.

    If you then create another new thread from within that first thread, it also will not have any of the tk stuff that you created in the main thread after you started the work thread.


    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.
      If you then create another new thread from within that first thread, it also will not have any of the tk stuff that you created in the main thread after you started the work thread.

      It sounds good, but I wonder what sort of memory gains would occur, with that initial thread repawning itself ad infinitum?


      I'm not really a human, but I play one on earth.
      Old Perl Programmer Haiku ................... flash japh
        with that initial thread repawning itself ad infinitum?

        On Windows, none. On *nix, from previous threads it appears that the implementations leaks a few k for each new thread.

        But unless the OP is intending that the buttons on this Tk gui be used as those on a gmaes controller in a first person shoot'em up, even the *nix leak is unlikely to be a big problem.


        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.
Re^9: Tk and Threads
by zentara (Cardinal) on Dec 22, 2010 at 12:49 UTC
    I thought that it is not allowed to create a new thread after Tk was started because this would then make the SW unstable and possibly crashing.

    You are right to continue believing that.

    Alot of what BrowserUk says may be true, on Windows, which he uses. But on linux, threads work a bit differently.

    Of course, on Gtk2, you can create them after gui init. ;-)


    I'm not really a human, but I play one on earth.
    Old Perl Programmer Haiku ................... flash japh
      Alot of what BrowserUk says may be true, on Windows, which he uses.

      Care to tell me which bits of what I say might not be true on windows?

      But on linux, threads work a bit differently.

      With the notable exception of the *nix implementation leaking memory like sieve when the Windows implementation doesn't, can you demonstrate any other platform dependant differences?


      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 the notable exception of the *nix implementation leaking memory like sieve when the Windows implementation doesn't, can you demonstrate any other platform dependant differences?

        That's the one I'm talking about!! And it's very very important. :-)


        I'm not really a human, but I play one on earth.
        Old Perl Programmer Haiku ................... flash japh