#!/usr/bin/perl # written by zentara (zentara@zentara.net) # this script is free from any restrictions # I hope you find it useful # Feb,8,2004 use warnings; use strict; use Tk; use Tk::Pane; use Tk::JPEG; use Tk::HList; use Tk::ItemStyle; use Imager; use Tk::NoteBook; use File::Basename; use File::Path; use File::Copy; use Storable; use POSIX qw(strftime); use YAML; my %tabs; my $photo;#my $photo; my $nb;#my notebook, only 1 is created my $h; #my HList; my $key_sel = 'admin'; #current selected $key my $key_prev = 'admin'; #previous selection starts with admin my %info; my $entry; #name box my $entry1; #comment box my $colorbut; #IDcolor my $piclab; #picture label my $dialog; #toplevel window my $dmessage; #dialog message if(-e 'notebook.db'){ %info = %{retrieve('notebook.db')}; # direct to hash } #to see a dump of the db, just put an 1 as an arg to the script if(shift){print Dump(\%info);exit;} #setup tabbed categories and assign each a color #and listing priority in HoA #change these to what you want, and their color and order my %tabColors = ( Name => ['bisque', 1], Test_Scores => ['lightyellow', 2], Background => ['azure', 3], Classes => ['PeachPuff', 4], Sports => ['pink', 5], Problems => ['OldLace', 6], Awards => ['wheat1', 7], Other => ['khaki', 8], ); $SIG{__DIE__} = sub {&save_it(); exit}; $SIG{INT} = sub {&save_it(); exit}; my @exts = qw(.jpg .png .gif); # list allowed extensions if(! -e 'thumbs'){mkdir 'thumbs'; make_thumbs();} my @thumbs = ; my @thumbnails; #actual thumbnails, @thumbs are the filenames my $mw = MainWindow->new(-bg=>'black'); $mw->geometry('800x700+100+15'); $mw->bind('', [sub{&save_it(); Tk::exit;}] ); my $topframe = $mw->Frame(-height =>30, -background=>'black') ->pack(-fill=>'both', -expand=>1); my $leftframe = $mw->Frame( -width =>25, -background=>'black', )->pack(-side => "left", -anchor => "n", -fill=>'both', -expand=>1); my $mainframe = $mw->Frame(-background=>'black') ->pack(-side => "right", -anchor => "n", -fill=>'both', -expand=>1); #fill leftframe with thumbnails HList2(); #fill mainframe with default screen setup_pane(); $topframe->Button(-text => "Add New Entry", -bg=>'cyan3', -activebackground =>'cyan', -padx=>40, -relief=>'raised', -command => sub {&new_key})->pack(-side =>'left'); $topframe->Button(-text => "Delete Entry", -bg=>'thistle3', -activebackground =>'thistle1', -padx=>40, -relief=>'raised', -command => sub {&delete_key})->pack(-side =>'right'); $topframe->Button(-text => "Exit", -activebackground =>'snow', -padx=>40, -relief=>'raised', -command => sub {&save_it(); exit; })->pack(); #in case you want to play with the Up Down aroow keys in HList #$mw->focusFollowsMouse; #$h->bind('', [sub {&browseThis($h->info('selection') )}] ); MainLoop; sub HList2 { $h = $leftframe->Scrolled( 'HList', -header => 1, -columns => 2, -width => 20, -height => 60, -takefocus => 1, -background => 'steelblue', -foreground =>'snow', -selectmode => 'single', -selectforeground => 'pink', -selectbackground => 'black', -browsecmd => \&browseThis, )->pack(-side => "left", -anchor => "n"); $h->header('create', 0, -text => ' THUMBNAIL ', -borderwidth => 3, -headerbackground => 'steelblue', -relief => 'raised'); $h->header('create', 1, -text => ' ID ', -borderwidth => 3, -headerbackground => 'lightsteelblue', -relief => 'raised'); my $font = '-Adobe-Courier-Bold-O-Normal--*-120-*-*-*-*-*-*'; #sort entries with admin at top and no entry for default my @list = grep (!/admin/, sort keys %info); unshift @list,'admin'; foreach (@list){&add_key($_)} } ############################################################# sub setup_pane{ my $pane = $mainframe->Scrolled('Pane', Name => 'Main Display', -width => 1000, -height =>1000, -background => 'black', -scrollbars => 'osoe', -sticky => 'n', )->pack(-side => "left", -anchor => "n", -fill=>'both',-expand=>1); #default displayed image my $image = $mw->Photo(-file => $info{'admin'}{'pic'}) or die $!; $photo = $pane->Label(-image => $image, -background =>'black' )->pack(-side => 'top', -anchor => 'n', -fill => 'both', -expand => 1, ); $photo->bind('', sub {&update_pic_thumb }); #name entry box my $f1 = $pane->Frame(-background => 'black') ->pack(-side => 'top', -fill => 'both', -expand => 1,); my $f2 = $pane->Frame(-background => 'black') ->pack(-side => 'top', -fill => 'both', -expand => 1,); $f2->Label(-text=>"Name:",-background => 'black',-foreground => 'green') -> pack(-side => 'left', -anchor => 'n'); $entry = $f2->Entry(-textvariable => \$info{$key_sel}{'name'}, -width =>30, ) ->pack(-side => 'left', -anchor => 'n'); $entry->configure(-state => 'disabled'); #prevent admin name change $entry->bind('