# This is the script my $gui=FP_GUI->new(); # Create main window $gui->menubar(); # Create menu bar MainLoop(); ########## # And this is the module sub new { # Create main window my $class=shift; my $mw=MainWindow->new(-title => 'Get Patents'); $mw->minsize(qw(500 300)); $mw->configure(-bg=>'ivory'); $mw->fontCreate('lbl', -family=>'arial', -size=>'10', -weight=>'bold' ); my $self={mw=>$mw, # Main window status=>'Ready', # Status of program search_entry=>'', # Pointer to search entry field pat_or_sub=>'Both - Pending and Issued', # search for patents or submissions or both strict=>0, # Search based on exact string match class_search=>0, # Include class in results pat=>'All are retrieved regardless of year', # Search based on specific years, or all years years=>'', # Pointer to years to search field percent_done=>0 # Percent done in progress bar }; return bless $self, $class; } sub menubar { # Create menubar my $self=shift; my $mw=$self->{mw}; my $menubar = $mw->Menu(-menuitems => &_menubar_menuitems($self) ); $mw->configure(-menu => $menubar); $mw->bind( "" => \&_quit); $mw->bind( "" => \&_save_defaults($self)); $mw->bind( "" => \&_show_help); } sub _quit { exit 0; } sub _save_defaults { # Save all search parameters my $self=shift; open FH, ">pto search defaults.txt" or die($!); my $search_terms=$self->{search_entry}->get; print FH "Terms\t$search_terms\n"; print FH "Get\t$self->{pat_or_sub}\n"; print FH "Strict\t$self->{strict}\n"; print FH "Class\t$self->{class_search}\n"; print FH "Search by\t$self->{pat}\n"; my $year_string=$self->{years}->get; print FH "Years\t"; print FH "$year_string\n" if ($year_string); close FH; $self->{status}="Search values saved"; } sub _show_help { system('help.html'); } sub _menubar_menuitems { # Menubar items my $self=shift; return [ map ['cascade', $_->[0], -tearoff=> 0, -menuitems => $_->[1]], ['~File', &_file_menuitems($self)], ['~Help', &_help_menuitems()], ]; } sub _file_menuitems { # File menu items my $self=shift; return [ [("command", "~Save Search Parameters", "-accelerator", "Ctrl-s"), -command=>[\&_save_defaults($self)]], '', [qw/command ~Quit -accelerator Ctrl-q/, -command=>[\&_quit]], ]; } sub _help_menuitems { # Help menu items return [ ['command', 'Help', -command => [\&_show_help]] ]; }