For Programmers: Free Programming Magazines  


Home > Archive > PerlTk > June 2006 > Tk::ExecuteCommand giving error on close









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Tk::ExecuteCommand giving error on close
prishni

2006-06-17, 8:14 am


Hi All,

I am using Tk::ExecuteCommand to run a program in background from my
GUI.. ( I am on linux platform).
It works fine. When I click on cancel button of the TK::ExecuteCommand
Widget the called program exists.

However my problem is that if by chance I click on the close button (
situated on the top right hand corner) of the TK::Executecommand
widget.. the entire application (i.e the called program and the GUI) is
exited and I get the following message on my shell

"Can't locate object method "cancel" via package "Tk::After::Cancelled"
at /usr/lib/perl5/site_perl/5.8.7/i386-linux/Tk/Widget.pm line 492 "

Can anyone tell me if I am doing anything wrong or is there any trick
to catch this error...

thanks for you time to advice me

zentara

2006-06-17, 8:14 am

On 15 Jun 2006 02:49:33 -0700, "prishni" <gaur_charu@yahoo.com> wrote:
>
>I am using Tk::ExecuteCommand to run a program in background from my
>GUI.. ( I am on linux platform).
>It works fine. When I click on cancel button of the TK::ExecuteCommand
>Widget the called program exists.
>
>However my problem is that if by chance I click on the close button (
>situated on the top right hand corner) of the TK::Executecommand
>widget.. the entire application (i.e the called program and the GUI) is
>exited and I get the following message on my shell
>
>"Can't locate object method "cancel" via package "Tk::After::Cancelled"
>at /usr/lib/perl5/site_perl/5.8.7/i386-linux/Tk/Widget.pm line 492 "
>
>Can anyone tell me if I am doing anything wrong or is there any trick
>to catch this error...


You can manually kill the command on WM_DELETE_COMMAND,
but I think it's generally a harmless warning.

#!/usr/bin/perl -w
use Tk;
use Tk::ExecuteCommand;
use Tk::widgets qw/LabEntry/;
use strict;

my $mw = MainWindow->new;

my $ec = $mw->ExecuteCommand(
-command => '',
-entryWidth => 50,
-height => 10,
-label => '',
-text => 'Execute',
)->pack;

$ec->configure(-command => 'date; sleep 10; date; sleep 10; date;');

#prevents mw from closing
$mw->protocol('WM_DELETE_WINDOW' => sub {
$ec->kill_command;
exit;
});

$ec->execute_command;

MainLoop;



--
I'm not really a human, but I play one on earth.
http://zentara.net/japh.html
Petr Vileta

2006-06-17, 8:14 am

"prishni" <gaur_charu@yahoo.com> píse v diskusním príspevku
news:1150364973.911047.8110@r2g2000cwb.googlegroups.com...
>
> Hi All,
>
> I am using Tk::ExecuteCommand to run a program in background from my
> GUI.. ( I am on linux platform).
> It works fine. When I click on cancel button of the TK::ExecuteCommand
> Widget the called program exists.
>
> However my problem is that if by chance I click on the close button (
> situated on the top right hand corner) of the TK::Executecommand
> widget.. the entire application (i.e the called program and the GUI) is
> exited and I get the following message on my shell
>
> "Can't locate object method "cancel" via package "Tk::After::Cancelled"
> at /usr/lib/perl5/site_perl/5.8.7/i386-linux/Tk/Widget.pm line 492 "
>
> Can anyone tell me if I am doing anything wrong or is there any trick
> to catch this error...
>
> thanks for you time to advice me
>

Maybe you can use
$mw->OnDestroy(sub {kill_background_program;})
This method is called before all widgets are destroyed.

--

Petr Vileta, Czech republic
(My server rejects all messages from Yahoo and Hotmail. Send me your mail
from another non-spammer site please.)


Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com