Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > error running a perl TK programme

Reply
Thread Tools

error running a perl TK programme

 
 
king
Guest
Posts: n/a
 
      11-05-2007
I have a script as below to be ran in windows.

But whenever I am running this i am getting an error #No -label at C:/
Perl/lib/Tk/Widget.pm line 256#.
Sometimes I am not getting this error also but I am not getting the
output window also. Even if its not showing any error but it also is
not showing the output window.
What can be the problem?
##########################################
#!\c\perl\bin
use strict;
use warnings;
use tk;

my $main=MainWindow->new();
$main->minsize(qw(250 250));
$main->title(" calculator ");
$main->configure (-background=>'cyan');



my $menu_bar=$main->Frame(-relief=>'groove', -borderwidth=>3, -
background=>'purple',)->pack('-side'=>'top', -fill=>'x');

my $file_mb=$menu_bar->Menubutton(-text=>'File', -
background=>'purple', -activebackground=>'cyan', -
foreground=>'white',)->pack(-side=>'left');
$file_mb->command(label=>'Exit', -activebackground =>'magenta',-
command=> sub{$main->destroy});
$file_mb->separator();

my $help_mb=$menu_bar->Menubutton(-text=>'Help', -
background=>'purple', -activebackground=>'cyan', -
foreground=>'white',)->pack(-side=>'right');
$help_mb->command(-Label=>'About', -activebackground=>'magenta',-
command=> \&about_txt);
$help_mb->command(-Label=>'Help', -activebackground=>'magenta',-
command=> \&help_txt);

$help_mb->separator();

my $top=$main->Frame(-background=>'cyan',)->pack(-side=>'top',-
fill=>'X');
my $left1=$top->Frame(-background=>'cyan',)->pack(-
side=>'left',pady=>9,padx=>;


my $t1=$left1->Label(-text=>'',-background=>'cyan')->pack();
my $t2=$left1->Label(-text=>'BUS',-background=>'cyan')->pack();
my $t3=$left1->Label(-text=>'DEVICE',-background=>'cyan')->pack();
my $t4=$left1->Label(-text=>'FUNCTION',-background=>'cyan')->pack();


my $left2=$top->Frame(-background=>'cyan',)->pack(-side=>'left',-
pady=>2,-padx=>15);
my $pre = $left2->Label (-text=>'Pretax',-background=>'cyan')->pack();
my $pre1=$left2->Label(-background=>'green', -width=>12, -
borderwidth=>2, -relief=>'sunken')->pack();
my $pre2=$left2->Label(-background=>'green', -width=>12, -
borderwidth=>2, -relief=>'sunken')->pack();
my $pre3=$left2->Label(-background=>'green', -width=>12, -
borderwidth=>2, -relief=>'sunken')->pack();


my $left3=$top->Frame(-background=>'cyan',)->pack(-side=>'left',-
pady=>2,-padx=>15);
my $post = $left3->Label (-text=>'posttax',-background=>'cyan')-
>pack();

my $post1=$left3->Label(-background=>'green', -width=>12, -
borderwidth=>2, -relief=>'sunken')->pack();
my $post2=$left3->Label(-background=>'green', -width=>12, -
borderwidth=>2, -relief=>'sunken')->pack();
my $post3=$left3->Label(-background=>'green', -width=>12, -
borderwidth=>2, -relief=>'sunken')->pack();


my $left4=$top->Frame(-background=>'cyan',)->pack(-side=>'left',-
pady=>2,-padx=>15);
my $tax = $left4->Label (-text=>'taxation',-background=>'cyan')-
>pack();

my $tax1=$left4->Label(-background=>'green', -width=>12, -
borderwidth=>2, -relief=>'sunken')->pack();
my $tax2=$left4->Label(-background=>'green', -width=>12, -
borderwidth=>2, -relief=>'sunken')->pack();
my $tax3=$left4->Label(-background=>'green', -width=>12, -
borderwidth=>2, -relief=>'sunken')->pack();


MainLoop();

#No -label at C:/Perl/lib/Tk/Widget.pm line 256
################################################## ##

 
Reply With Quote
 
 
 
 
Ben Morrow
Guest
Posts: n/a
 
      11-05-2007

Quoth king <(E-Mail Removed)>:
> I have a script as below to be ran in windows.
>
> But whenever I am running this i am getting an error #No -label at C:/
> Perl/lib/Tk/Widget.pm line 256#.


Something that often helps when you get a message of this sort is to run
your program with

perl -MCarp=verbose

.. This gives you a full stacktrace on (some) errors, so you can see
where in your script the problem is.

> Sometimes I am not getting this error also but I am not getting the
> output window also. Even if its not showing any error but it also is
> not showing the output window.
> What can be the problem?
> ##########################################
> #!\c\perl\bin


I'm not sure what you think this line is doing for you, but a #! line
that doesn't end in 'perl' is a bad idea. perl tries to do clever things
with it for you.

> use strict;
> use warnings;
> use tk;


Perl modules are case-sensitive. While this may work on a
case-insensitive filesystem in some cases, in many (such as use Strict)
it will not.

use Tk;

> my $main=MainWindow->new();


I would strongly recommend using

my $main = Tk::MainWindow->new();

instead. Tk really didn't ought to be messing about in other toplevel
namespaces.

<snip>
> my $file_mb=$menu_bar->Menubutton(-text=>'File', -
> background=>'purple', -activebackground=>'cyan', -
> foreground=>'white',)->pack(-side=>'left');
> $file_mb->command(label=>'Exit', -activebackground =>'magenta',-

^^^
Here is your problem. You want -label.

<snip>
> $help_mb->command(-Label=>'About', -activebackground=>'magenta',-

^^^
Here, again, you want -label. Hash keys (and thus Tk configuration
options) are case-sensitive as well.

Ben

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Trouble running Perl script from within a Perl script laredotornado@zipmail.com Perl Misc 4 07-29-2011 01:44 PM
Programme wants 32bit colour, error message David Computer Support 1 02-13-2007 09:36 PM
Changing the user account of aspnet_wp, stops the programme from running? chortler@fetchmail.co.uk ASP .Net 2 05-05-2005 12:54 PM
has anybody write bioinformatics programme with perl hugo Perl Misc 4 08-17-2004 11:01 AM
Perl Help - Windows Perl script accessing a Unix perl Script dpackwood Perl 3 09-30-2003 02:56 AM



Advertisments