Beefy Boxes and Bandwidth Generously Provided by pair Networks Frank
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

SamCG's scratchpad

by SamCG (Hermit)
on Oct 06, 2005 at 15:01 UTC ( #497953=scratchpad: print w/ replies, xml ) Need Help??

use Tk; use Tk::Menu; use strict; use MINE::Issues; use DBI; my $sample = shift; my $dbh; if (-e "H:/db/sqlite/$sample"){ $dbh = DBI->connect("dbi:SQLite2:dbname=H:/db/sqlite/$sample", "", + "", { RaiseError => 1, AutoCommit => 0 }); } else { $dbh = DBI->connect("dbi:SQLite2:dbname=H:/db/sqlite/$sample", + "", "", { RaiseError => 1, AutoCommit => 0 }); &create_sampledb($dbh); } my $main = MainWindow->new; my $mb = $main->Menu(-menuitems => &menubar_menuitems() ); $main->configure(-menu => $mb); ## name entry section my $lname = $main->Entry(-text =>'Last Name')->pack; my $fname = $main->Entry(-text =>'First Name')->pack; my $email = $main->Entry(-text =>'email')->pack; my $new_user = $main->Button(-text =>'Add User', -command=>sub{new_use +r($dbh, $lname, $fname, $email)})->pack; ## list users my @userlist; my $user_ref = &user_list($dbh); for (@$user_ref){ push @userlist, "$_->[1], $_->[2] ($_->[0])"; } my $u_list = $main->Listbox()->pack; $u_list->insert('end', @userlist); my $issue_desc = $main->Text(-height=>10, -width=>45)->pack; my $priority = $main->Entry(-text => 'High Medium Low')->pack; my $add_issue = $main->Button(-text=>'Add Issue', -command=>sub{new_is +sue($dbh, $issue_desc, $priority)})->pack; MainLoop; sub new_user { my ($db_ref, $l, $f, $e) = @_; my $ln = $l->get(); my $fn = $f->get(); my $em = $e->get(); add_user($db_ref, $fn, $ln, $em); } sub begin_prog{} sub menubar_menuitems { return [ map ['cascade', $_->[0], -tearoff=> 0, -menuitems => $_->[1]], # make sure you put the parens here because we want to # evaluate and not just store a reference ['~New', &new_menuitems()], ['~Help', &help_menuitems()], ]; } sub new_menuitems { # 'command', tells the menubar that this is not a label for a sub # menu, but a binding to a callback; the alternate here is 'cascade' # Try uncommenting the following code to create an 'Operations' sub # menu in the main 'File' menu. return [ # [qw/cascade Operations -tearoff 0 -menuitems/ => # [ # [qw/command ~Open -accelerator Ctrl-o/, # -command=>[\&OnFileOpen]], # [qw/command ~Save -accelerator Ctrl-s/, # -command=>[\&OnFileSave]], # ] # ], [qw/command ~User -accelerator Ctrl-u/, -command=>[\&OnFileOpen]], [qw/command ~Save -accelerator Ctrl-s/, -command=>[\&OnFileSave]], '', [qw/command E~xit -accelerator Ctrl-q/, -command=>[\&OnExit]], ]; } sub help_menuitems { return [ ['command', 'About', -command => [\&OnAbout]] ]; }
Log In?
Username:
Password:

What's my password?
Create A New User
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (7)
As of 2014-04-25 08:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (585 votes), past polls