tkhp16c

tkhp16c is an RPN calculator we used for a splash screen example in Chapter 15. See Figure 15-6.

package Tk; use Tk::bindDump; # M A I N package main; use Tk; use Tk::MacProgressBar; use Tk::Splashscreen; use Tk::widgets qw/Compound ROText/; use subs qw/build_button_rows build_calculator build_help_window end splash/; use strict; my $mw = MainWindow->new; $mw->withdraw; $mw->title('Hewlett-Packard 16C Computer Scientist RPN Calculator'); $mw->iconname('HP 16C'); $mw->configure(-background => $GRAY_LIGHTEST); my $splash = splash; # build Splashscreen $splash->Splash; # show Splashscreen build_help_window; build_calculator; $MAC_PB->set($MAC_PB_P = 100); $splash->Destroy; # tear down Splashscreen $mw->deiconify; # show calculator MainLoop; # Miscellaneous subroutines. sub build_button_rows { my ($parent, $button_descriptions) = @_; foreach my $row (@$button_descriptions) { my $frame = $parent->Frame(-background => $GRAY_LIGHTEST); foreach my $buttons (@$row) { my ($p1, $p2, $p3, $color, $func) = @$buttons; $frame->Key( topl => $p2, -butl => $p1, -botl => $p3, -background => $color, -command => $func, ); } $frame->pack(qw/-side top -expand 1 -fill both/); $MAC_PB->set($MAC_PB_P += 10); } } # end build_button_rows sub build_calculator { &on; &on; # on/off kluge to initialize HP stack # LED display, help button, and HP logo. my $tf = $mw->Frame(-background => $SILVER); $tf->pack(qw/-side top -fill both -expand 1/); $tf->Label( -relief => 'sunken', -borderwidth => 10, -background ...

Get Mastering Perl/Tk now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.