use strict; use warnings; use Tk; use Tk::DialogBox; use Tk::Listbox; my $mw = MainWindow->new (); my %starData; my @params = ($mw, \%starData, ); $mw->Button (-text => 'Known star', -command => [\&knownStar, @params])->pack (); $mw->Button (-text => 'New star', -command => [\&newStar, @params])->pack (); $mw->Button (-text => 'List stars', -command => [\&listStars, @params])->pack (); $mw->Button (-text => 'Quit', -command => [\&quit, @params])->pack (); MainLoop (); sub knownStar { my ($mw, $starData) = @_; my @stars = map {[split ',']} split "\n", <[0]} @stars; my $dlg = $mw->DialogBox ( -title => 'Select known star', -default_button => 'OK', -buttons => ['OK', 'Cancel'], ); my $listbox = $dlg->add ('Listbox', -listvariable => \@names, -selectmode => 'single' )->pack (); return if $dlg->Show () eq 'Cancel'; my @sel = $listbox->curselection (); return unless @sel; print "@{$stars[$sel[0]]}\n"; $starData->{$sel[0]} = $stars[$sel[0]]; } sub newStar { my ($mw, $starData) = @_; # Generate new star data here } sub listStars { my ($mw, $starData) = @_; } sub quit { my ($mw, $starData) = @_; # Save handling here if required exit; }