Hi all,
i have a Tk-program with a start-button and a stop-button to start or stop a pipe to an external programm. The start-botton works fine and start the pipe for the external-program. But if i click on the stop-button the program is hanging.
I dont know how i can stop the pipe over the stop-button without hanging the program. The goal is to start or stop the pipe on every click on the certain button. May be anybody has an idea? It would be very very nice...
use Tk;
#================================================
# Main-Window
#================================================
$HF = new MainWindow (-title => "Main-Window");
$HF->geometry('100x100');
#==================================================
# Buttons
#==================================================
$BtnStart = $HF->Button
(
-text=>"START",
-command => \&ext,
-borderwidth => 2,
-relief => raised,
)->pack();
$BtnStop = $HF->Button
(
-text=>"STOP ",
-command => sub{close (FH);$HF->update();},
)->pack();
#================================================
# Tk-End
#================================================
MainLoop();
#================================================
# SUB-Programs
#================================================
sub ext
{
#xxxx Pipe to the external programm
open(FH, "c:\\extern.exe |");
while($tp=<FH>)
{
print "\n$tp";
$HF->update();
}
}
best regards, michbach
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.