in reply to Re: Making a TK GUI in a thread
in thread Making a TK GUI in a thread

Thanks for the help... actualy I continue to have problems... what I really wanted to do was display a loading screen while my program did its various
operations, then finally display the main gui. My plan was showing an initial gui, loading the stuff, destroying
the gui and loading the final gui, but I continue to get
spool errors... check it out

use strict;
use Thread::Use;
use threads;
use threads::shared;
my $u; share ($u);

my $load_gui = threads->create("loading_screen");

my $counter;

#Simulate program loading
while ($counter < 3) {
sleep($counter);
$counter++;
}
$u = 1;#destroy loading screen
$load_gui->join;

#Load the final gui
my $load_gui2 = threads->create("loadGui");

#keep program fom ending
while (1) {
sleep(1);
print "cav\n";
}


##GUIS###########################

sub loading_screen {
useit Tk;
my $main = MainWindow->new;
$main->repeat(100 => sub {if ($u){$main->destroy}});

# Add a Label and a Button to main window
$main->Label(-text => 'Loading!')->pack;
Tk->MainLoop;
}

sub loadGui {
useit Tk;
my $main = MainWindow->new;

# Add a Label and a Button to main window
$main->Label(-text => 'Main Gui')->pack;

# Spin the message loop
Tk->MainLoop;
}

Replies are listed 'Best First'.
Re: Re: Re: Making a TK GUI in a thread
by PodMaster (Abbot) on Sep 19, 2003 at 04:29 UTC
    You don't need threads to throw up a splash screen. See Tk::Splashscreen - display a Splashscreen during program initialization.

    MJD says "you can't just make shit up and expect the computer to know what you mean, retardo!"
    I run a Win32 PPM repository for perl 5.6.x and 5.8.x -- I take requests (README).
    ** The third rule of perl club is a statement of fact: pod is sexy.