Code Comments
Programming Forum and web based access to our favorite programming groups.Hi Folks, I've a problem with the Tk::ErrorDialog in a Tk-programm. If an error occurs in package main, the Dialog-box doesn't displayed. The error is only shown on console. if the error occurs in a package under main, the dialogbox will be shown. What's to do ? Thanks Pit -- Message posted using http://www.talkaboutprogramming.com...ng.com/faq.html
Post Follow-up to this messageOn Thu, 20 Mar 2008 05:17:20 -0500, "Pit" <pharrendorf@am-soft.de> wrote: >Hi Folks, > >I've a problem with the Tk::ErrorDialog in a Tk-programm. > >If an error occurs in package main, the Dialog-box doesn't displayed. The >error is only shown on console. >if the error occurs in a package under main, the dialogbox will be shown. > >What's to do ? > >Thanks >Pit Can you make a small program that demonstrates this? -- I'm not really a human, but I play one on earth. http://zentara.net/japh.html
Post Follow-up to this messagehere is a small programm to demonstrate it.
use strict;
use Tk;
use Tk::ErrorDialog;
my $mw = MainWindow->new();
$mw->geometry("900x600+100+100");
my $frame = $mw->Frame()->pack(-expand => 1, -fill => 'both');
my $button = $frame->Button(-text => "make new button",
-command => \&_do,
)->pack();
$mw->update();
&_do();
MainLoop;
sub _do
{
my $new_button = $frame->Button(-text => "new button",
)->pack(side => 'top');
}
the error occurs in the subroutine _do because missing the hyphen before
side.
If the subroutine is called by clicking the button, the errordialog is
shown.
If the subroutine is called by the function call the error is only shown
on the console.
The real error in my program of course isn't the missing hyphen but an
error in a dbh-statement i.e in a select statement to read a database
table.
Thanks
Pit
--
Message posted using http://www.talkaboutprogramming.com...ng.com/faq.html
Post Follow-up to this messageOn Tue, 25 Mar 2008 04:34:22 -0500, "Pit" <pharrendorf@am-soft.de>
wrote:
>here is a small programm to demonstrate it.
>
>use strict;
>use Tk;
>use Tk::ErrorDialog;
>
>my $mw = MainWindow->new();
>$mw->geometry("900x600+100+100");
>
>my $frame = $mw->Frame()->pack(-expand => 1, -fill => 'both');
>my $button = $frame->Button(-text => "make new button",
> -command => \&_do,
> )->pack();
>
>$mw->update();
>&_do();
>
>MainLoop;
>
>sub _do
>{
> my $new_button = $frame->Button(-text => "new button",
> )->pack(side => 'top');
# I had to add this to get an error on linux
my $x = 0;
my $y = 1/$x;
>}
>
>the error occurs in the subroutine _do because missing the hyphen before
>side.
>If the subroutine is called by clicking the button, the errordialog is
>shown.
>If the subroutine is called by the function call the error is only shown
>on the console.
>
>The real error in my program of course isn't the missing hyphen but an
>error in a dbh-statement i.e in a select statement to read a database
>table.
>
>Thanks
>Pit
I didn't get any error from your original code( except a missing -side).
So I added a divide by zero error to force it.
When called from &_do(), it errored to the commandline, and the program
crashed. But if I commented out &_do(), Tk would compile, and the
ErrorDialog worked.
My guess is that &_do() is an error caught by the Perl compiler, and it
stops compilation; but when called by a Tk button, the compile time
check of the callback isn't done, until the Button is pressed.
Some internals person may know more than me on how the Perl compiler
works, but I seem to remember there are differences in checking subs
for errors , if they are callbacks versus a regular sub.
There might be some better explanation in "perldoc perlcompile", or
someone on Perlmonks may know the gory details. :-)
zentara
--
I'm not really a human, but I play one on earth.
http://zentara.net/japh.html
Post Follow-up to this messagePowered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.