Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

Problem with TK::ErrorDialog
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


Report this thread to moderator Post Follow-up to this message
Old Post
Pit
03-20-08 01:08 PM


Re: Problem with TK::ErrorDialog
On 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

Report this thread to moderator Post Follow-up to this message
Old Post
zentara
03-20-08 01:08 PM


Re: Problem with TK::ErrorDialog
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');
}

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


Report this thread to moderator Post Follow-up to this message
Old Post
Pit
03-25-08 01:07 PM


Re: Problem with TK::ErrorDialog
On 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

Report this thread to moderator Post Follow-up to this message
Old Post
zentara
03-26-08 12:16 AM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

PerlTk archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 07:53 AM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.