linuxkid has asked for the wisdom of the Perl Monks concerning the following question:
So, I have some code, that always errors, this is the error:No -label at C:/strawberry/perl/site/lib/Tk/Widget.pm line 256. Here is the code that does causes it, it gets annoying. I Updated the code listing on here.
Please ignore unwritten subs, I have to get the interface working, otherwise it won't matter.#!/usr/bin/perl ############################################# # Call List Manager, Copyright 2012 Sam # # Flint, linuxkid@linux.com. # # Licensed under the GNU GPLv3 # ############################################# # PMDF # # Version: 1.0 # # License: GNU GPLv3 # # Name: Call List Manager # # File: clm.pl # # Author: Sam Flint, linuxkid@linux.com # # Maintainer: Sam Flint, linuxkid@linux.com # # Commenting: verbose # ############################################# #Extensions Needed use Tk; use PDF::Reuse; use YAML::Tiny; use Tk::Tree; use Tk::ROText; use Tk::LabEntry; use Tk::Text; $iparse = YAML::Tiny->new(); $Mw = MainWindow->new(-title=> "Calling List Manager"); $menuitems = [ [Cascade => "File", -menuitems=> [ [Button => "~Open", -command=> \&open], [Button => "~Save", -command=> \&savefile], [Button => "Save ~As", -command=> \&saveas], #[Seperator => ""], [Button => "E~xit", -command=> \&exitprog], ] ], [Cascade => "Edit", -menuitems=> [ [Button => "Add Calle~r", -command=> \&acaller], [Button => "Add Calle~e", -command=> \&acallee], #[Seperator => ""], [Button => "Remove Caller", -command=> \&rcaller], [Button => "Remove Callee", -command=> \&rcallee], #[Seperator => ""], [Button => "~Generate Call Lists", -command=> \&generate], [Button => "~Mail Call Lists", -command=> \&mailout], #[Seperator => ""], [Button => "~Preferences", -command=> \&prefs], ] ], [Cascade => "Help", -menuitems=> [ [Button => "~About", -command=> \&about], [Button => "~Help", -command=> \&help], ] ] ]; $menubar = $Mw->Menu(-menuitems => $menuitems); $Mw->configure(-menu => $menubar); $wframe = $Mw->Frame()->pack(-side=>'top', -fill=>'both', -expand => 1 +); $tree = $wframe->Scrolled( 'Tree', -relief => 'flat', -scrollbars => 'osoe', -borderwidth => 0, -separator => '.', -drawbranch => 'true', -indicator => 'true', )->pack(-side => 'top', -fill => 'both', -expand => 1); $inf = $Mw->Frame()->pack(-side=> "top", -fill=> "x", -expand=> 1); $inf->Label(-text=> "Status:")->pack(-side=>'left', -expand=> 1); $inf->Label(-textvariable=> \$message)->pack(-side=>'left', -fill=>'x' +, -expand=> 1); $inf->Label(-text=> "Save State")->pack(-side=>'left', -fill=>'x',, -e +xpand => 1); $inf->Label(-textvariable=> \$savestate)->pack(-side=>'left', -fill=>' +x', -expand => 1); #openprefs(); MainLoop(); # main Subs $helptext = <<EOF; EOF sub ginf { $tree->info('selection'); } sub openfile { our $file = $Mw->getOpenFile(); our $data = $iparse->read($file) || $Mw->Dialog(-title=> "File Open + Error", -text=>"$!: Cannot Open File: $file!", -buttons=>["Ok"], -de +faultbutton=>"Ok", -bitmap=> "warning")->show();; our @list; our @callers; foreach (<FH>) { if ($type eq "caller") { $id = shift @fields; $phnum = shift @fields; $email = shift @fields; $address = shift @fields; $notes = shift @fields; $data->{$id}->{type} = 'caller'; $data->{$id}->{name} = $id; $data->{$id}->{phnum} = $phnum; $data->{$id}->{email} = $email; $data->{$id}->{addr} = $address; $data->{$id}->{notes} = $notes; push @list, $id; push @callers, $id; } elsif($type eq "callee") { $caller = shift @fields; $name = shift @fields; $phnum = shift @fields; $email = shift @fields; $address = shift @fields; $notes = shift @fields; $id = $caller.'.'.$name; $data->{$id}->{type} = 'callee'; $data->{$id}->{name} = $name; $data->{$id}->{phnum} = $phnum; $data->{$id}->{email} = $email; $data->{$id}->{addr} = $address; $data->{$id}->{caller} = $caller; $data->{$id}->{notes} = $notes; push @list, $id; } else { next; } } redotree(); } sub redotree { $tree->delete(0, 'end'); my $col = 0; foreach $node (@job_list) { $node_name = (split('.', $node))[-1]; $node_name = $node if ($node_name eq ''); $tree->add($node); $tree->itemCreate( $node, $col, -text => $node_name, -itemtype => 'text'); } $tree->autosetmode(); } sub savefile { $sfile = $file; $sfile ||= shift; $data->write($sfile); } sub saveas { savefile($Mw->getSaveFile()); } sub exitprog { savefile(); $Mw->Withdraw(); exit; } sub acaller { editentry("boogie", "new", "caller"); } sub acallee { editentry("boogie", "new", "callee"); } sub rcaller { } sub rcallee { } sub generate { } sub mailout { } sub prefs { } sub about { $tlw = $Mw->Toplevel(-title=> "About"); $info = $tlw->ROText()->pack(-side => 'top', -fill => 'both', -expa +nd => 1); $info->insert('end', "Calling List Manager, Copyright, 2012 Sam Fli +nt.\n"); $info->insert('end', "Version 1.0\n"); $info->insert('end', "Registered to $conf->{registered}\n"); $tlw->Button(-text=> "Ok", -command=> sub { $tlw->withdraw })->pack +(); } sub help { $tlw = $Mw->Toplevel(-title=>"Help"); $info = $tlw->ROText()->pack(-side => 'top', -fill => 'both', -expa +nd => 1); $tlw->Button(-text=> "Ok", -command=> sub { $tlw->withdraw })->pack +(); $info->insert('end', $helptext); } sub editentry { $path = shift; $stat = shift; $type = shift || $data->{$path}->{type}; if ($stat eq 'new') { $tlw = $Mw->Toplevel("New Entry"); if ($type eq "caller") { $tlw->LabEntry(-text=>"Name", -textvariable=>\$id)->pack(-fil +l=>'x'); $tlw->LabEntry(-text=>"Phone Number", -textvariable=>\$phnum) +->pack(-fill=>'x'); $tlw->LabEntry(-text=>"Email", -textvariable=>\$id)->pack(-fi +ll=>'x'); $tlw->LabEntry(-text=>"Address", -textvariable=>\$id)->pack(- +fill=>'x'); $tlw->Text(-text=>"Name", -textvariable=>\$notes)->pack(-fill +=>'x'); $tlw->Button(-text=> "Ok", -command=> sub { $data->{$id}->{name} = $name; $data->{$id}->{type} = 'caller'; $data->{$id}->{phnum} = $phnum; $data->{$id}->{email} = $email; $data->{$id}->{addr} = $address; $data->{$id}->{notes} = $notes; })->pack(-fill=>'x'); } elsif($type eq "callee") { } else { $tlw->withdraw(); } } elsif($stat eq 'old') { $tlw = $Mw->Toplevel(-title=> "Edit Entry"); } else { redotree(); } } sub openprefs { open FH, "~/clm.conf"; bless our $conf; foreach (<FH>) { ($key, $value) = split /:/; $conf->{$key} = $value; } } __END__
--linuxkid
imrunningoutofideas.co.cc
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Code Review Time!
by davido (Cardinal) on Mar 14, 2012 at 23:13 UTC | |
by linuxkid (Sexton) on Mar 15, 2012 at 01:11 UTC | |
Re: Code Review Time!
by jwkrahn (Abbot) on Mar 14, 2012 at 22:54 UTC | |
by Anonymous Monk on Mar 15, 2012 at 08:35 UTC | |
| |
Re: Code Review Time!
by thundergnat (Deacon) on Mar 15, 2012 at 16:01 UTC | |
| |
Re: Code Review Time!
by zentara (Archbishop) on Mar 15, 2012 at 11:39 UTC |
Back to
Seekers of Perl Wisdom