in reply to Launch External App in Tk And Return

You need to either fork or use threads (depending perhaps on the OS you are using). Note though that Tk can get grumpy working in a forked/threaded environment if you are not careful.

Peruse the following node for related discussion: Re: Perl/Tk question about starting programs via a button and PerlTk on a thread...

True laziness is hard work
  • Comment on Re: Launch External App in Tk And Return

Replies are listed 'Best First'.
Re^2: Launch External App in Tk And Return
by ~~David~~ (Hermit) on Sep 29, 2010 at 23:18 UTC
    I tried using fork, but I don't really understand this. I am on Win, and I was under the impression the Tk was not threadsafe... I can try, though...

    Thanks, David

      Since you're using 'system', I presume that the external app in question can be launched via command prompt. In that case, you've got an easy solution. Just add "start " to the front of what you're sending into 'system'. This will tell Windows to run the rest of the command in a new "space" and will immediately return control back to your script.

      For example, if you were launching notepad, you could do it with the following line of code:

      system("notepad");

      That would cause the script to wait until notepad was closed. Instead, modify it to be like this:

      system("start notepad");

      You'll see a command prompt appear, notepad gets opened, the command prompt disappears, and your script continues on. Just apply this to your script/app code in launching the external app and you should be good to go.

      If you want to know more about the various options for the 'start' command, just open a command prompt and type start /? to see the help information.

        Thank you so much. This was easy and exactly what I was looking for. I am launching a Windows only app, so I don't need to worry about portability.