Perl Tk: long running callback loses GUI interactivity

A

andy

Hi,

I wonder if anyone can help me with a small perl Tk problem I have. I
am writing an automated test script for a digital radio system, when
the user has selected all the options for the test and hits GO in the
GUI the callback executes a long running script, when this happens the
Tk GUI is completley inactive until the call back is finished (which
can take hours). Ideally i'd still like the GUI to have some
interactivity, suck as a CANCEL button to stop the tests (currently I
have to do a Ctrl-C in the dos window to stop the test). Is there a
way to do this? I wasnt sure what search terms to look for when
investigating a solution.

Many thanks in advance,

Andy
 
S

sheinrich

GUI the callback executes a long running script, when this happens the
Tk GUI is completley inactive until the call back is finished (which
can take hours). Ideally i'd still like the GUI to have some

This is no issue with perl or tk. The implications are very much the
same with any language across all OSes.
You are apparently running a single process.

I don't know, but tk might have its build-in solutions for a rather
central point in gui functionality.
Else look up "IPC", "parallel" and "fork" in your favourite perl docs
and on CPAN.

You have multiple options to deal with user interaction.
- Your long lasting program might occasionally check for user input to
process.
- You can start an own process with fork() for the long routine and
can steer the child process by means of IPC (inter process
communication). Usually pipes or signals.

fork() is basically easy to use, if your system is supporting it. Try
one of the many examples and find out.

steffen
 
S

smallpond

This is no issue with perl or tk. The implications are very much the
same with any language across all OSes.
You are apparently running a single process.

I don't know, but tk might have its build-in solutions for a rather
central point in gui functionality.
Else look up "IPC", "parallel" and "fork" in your favourite perl docs
and on CPAN.

You have multiple options to deal with user interaction.
- Your long lasting program might occasionally check for user input to
process.
- You can start an own process with fork() for the long routine and
can steer the child process by means of IPC (inter process
communication). Usually pipes or signals.

fork() is basically easy to use, if your system is supporting it. Try
one of the many examples and find out.

steffen


fork() is a good solution. Have the parent return to MainLoop (which
is
what needs to be running for the GUI activity) while the child
executes
your long-running process. system() can be used to start a separate
process that will not interfere with MainLoop. Just be sure to call
it
with 'myprocess &' so it doesn't wait for completion.
--S
 
S

smallpond

fork() is a good solution. Have the parent return to MainLoop (which
is
what needs to be running for the GUI activity) while the child
executes
your long-running process. system() can be used to start a separate
process that will not interfere with MainLoop. Just be sure to call
it
with 'myprocess &' so it doesn't wait for completion.
--S

My mistake. Tk cannot call fork in a callback. If using fork
in a Tk program, call it before calling MainLoop.
system is OK, tho.
--S
 
Z

zentara

My mistake. Tk cannot call fork in a callback. If using fork
in a Tk program, call it before calling MainLoop.
system is OK, tho.
--S

Whoa, that is bad info. Tk can call fork anywhere it wants. You may be
confusing fork with the Tk thread safety problem.

zentara
 
B

Ben Morrow

Quoth zentara said:
Whoa, that is bad info. Tk can call fork anywhere it wants. You may be
confusing fork with the Tk thread safety problem.

The OP is on Win32, so they are equivalent (fork is implemented with
threads on Win32).

Ben
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,202
Messages
2,571,055
Members
47,658
Latest member
jaguar32

Latest Threads

Top