Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: Splash screen increasing load time

by zentara (Archbishop)
on Dec 22, 2012 at 12:35 UTC ( #1010012=note: print w/ replies, xml ) Need Help??


in reply to Splash screen increasing load time

Here is a home-rolled splash for anyone looking.

#!/usr/bin/perl use warnings; use strict; use Tk; my $mw = new MainWindow; $mw->withdraw; #make it not visible my $init_value = ''; my $countdown = 10; my $tl = $mw->Toplevel(-bg=>'lightyellow' ); $tl->withdraw; $tl->overrideredirect(1); $tl->title("Splash"); #centers window CenterWindow($tl, 300, 200); my $message = " My Cool App FooBaz Corp Someplace, Somewhere Click a button to continue"; $tl->Label(-text=>$message)->pack(-pady =>10); $tl->Label(-textvariable=>\$countdown)->pack(); my $tlbframe = $tl->Frame()->pack(-expand => 1, -fill =>'x'); $tlbframe->Button(-text => "Option1", -command=> \&option1) ->pack(-side =>'left',-padx=>5); $tlbframe->Button(-text => "Option2", -command=> \&option2) ->pack(-side =>'left',-padx=>5); $tlbframe->Button(-text => "Exit", -command=> sub { do_quit(-3)} ) ->pack(-side =>'right',-padx=>5); $tl->deiconify(); my $tltimer = $mw->repeat(1000, sub{ $countdown--; if($countdown == 0){ do_quit(-1) } }); MainLoop; ######################################################### sub option1{ $tltimer->cancel; $tl->withdraw; $tl->destroy; my $rb = 'first button'; my $rb1 = $mw->Radiobutton(-text => "Button One", -value => 'button1', -variable => \$rb)->pack; my $rb2 = $mw->Radiobutton(-text => "Button Two", -value => 'button2', -variable => \$rb)->pack; my $b1 = $mw->Button(-text => 'Show', -command => [ \&showRB, \$rb +])->pack; $mw->Button(-text=>'Exit', -command=> sub{ do_quit(-10); })->pack(); CenterWindow($mw, 500, 500); $mw->deiconify; my $tltimer = $mw->after(15000, sub{ do_quit(-100) }); } ######################################################## sub option2{ $tltimer->cancel; $tl->withdraw; $tl->destroy; my $tFrame = $mw->Frame->pack( -side => 'top' ); my $bFrame = $mw->Frame->pack( -side => 'bottom' ); my $lFrame = $bFrame->Frame->pack( -side => 'left' ); my $rFrame = $bFrame->Frame->pack( -side => 'right', -fill => 'y' ) +; $tFrame->Label( -text => "Frame Packing Option2") ->pack( -side => 'top' ); my $count = 1; my $frame; while ( $count <= 19 ) { if ( $count % 2 ) { load_frame( $count, $rFrame ); } else { load_frame( $count, $lFrame ); } $count++; } $mw->Button(-text=>'Exit', -command=> sub{ do_quit(-20); })->pack( ); CenterWindow($mw, 500, 500); $mw->deiconify; my $tltimer = $mw->after(15000, sub{ do_quit(-200) }); } ######################################################### sub do_quit{ my $status = shift; print "exit_status-> $status\n"; exit $status; } ########################################################## sub CenterWindow { my($window, $width, $height) = @_; $window->idletasks; $width = $window->reqwidth unless $width; $height = $window->reqheight unless $height; my $x = int(($window->screenwidth / 2) - ($width / 2)); my $y = int(($window->screenheight / 2) - ($height / 2)); $window->geometry("=${width}x${height}+${x}+${y}"); } ############################################################# sub showRB { print "Arg list is @_\n"; my $state_ref = shift; my $state = $$state_ref; $mw->messageBox(-title => 'Status', -type => 'OK', -message => "Status is :$state:."); } ########################################################## + sub load_frame { my $count = shift; my $frame = shift; $frame->Radiobutton( -text => $count, -value => $count, -width => 10, )->pack; } __END__

I'm not really a human, but I play one on earth.
Old Perl Programmer Haiku ................... flash japh


Comment on Re: Splash screen increasing load time
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1010012]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (10)
As of 2015-07-06 07:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (70 votes), past polls