error running a perl TK programme

Discussion in 'Perl Misc' started by king, Nov 5, 2007.

  1. king

    king Guest

    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=>8);


    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
    ####################################################
    king, Nov 5, 2007
    #1
    1. Advertising

  2. king

    Ben Morrow Guest

    Quoth king <>:
    > 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
    Ben Morrow, Nov 5, 2007
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    2
    Views:
    373
    Scott Allen
    May 5, 2005
  2. Nobber

    Diary Programme?

    Nobber, Nov 18, 2005, in forum: Java
    Replies:
    2
    Views:
    418
    Monique Y. Mudama
    Nov 18, 2005
  3. HAK
    Replies:
    0
    Views:
    331
  4. melledge
    Replies:
    0
    Views:
    614
    melledge
    Mar 9, 2005
  5. hugo
    Replies:
    4
    Views:
    107
    Chris Cole
    Aug 17, 2004
Loading...

Share This Page