Home > Archive > PerlTk > October 2005 > Resetting program state
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Resetting program state
|
|
| Robert 2005-10-11, 6:58 pm |
| I have a simple little app that lest me reset a user. It has
radiobuttons to toggle which instance to reset the user in, an entry
area to put the users ID into and a reset button. It works like a
charm, except I can only reset one user and then I have to restart the
app to do another. Is there a way to reset its state without doing a
restart of the app?
Thanks for you time.
Robert
| |
| Josef Moellers 2005-10-11, 6:58 pm |
| Robert wrote:
> I have a simple little app that lest me reset a user. It has
> radiobuttons to toggle which instance to reset the user in, an entry
You mean like
o newborn
o toddler
o child
o teen
o twen
o grownup
Tsts "reset a user", what will be next: spawning users?
SCNR
Josef
--=20
Josef M=F6llers (Pinguinpfleger bei FSC)
If failure had no penalty success would not be a prize
-- T. Pratchett
| |
| Marc Dashevsky 2005-10-11, 6:58 pm |
| Robert <sigzero@gmail.com> writes in article %:
> I have a simple little app that lest me reset a user. It has
> radiobuttons to toggle which instance to reset the user in, an entry
> area to put the users ID into and a reset button. It works like a
> charm, except I can only reset one user and then I have to restart the
> app to do another. Is there a way to reset its state without doing a
> restart of the app?
You should be able to create an initialization routine that assigns
default values to all variables, including those that control the
radiobuttons and the entry. If you're not using -textvariable in
the entry, then you can do $entry->delete(0, 'end'). If there is
some other impediment, you'll have to provide a detailed description
of your "simple little app," including code.
--
Go to http://MarcDashevsky.com to send me e-mail.
(Reunion -- http://ClassicalHigh70.com)
| |
| Robert 2005-10-11, 6:58 pm |
| Funny man. Oh wait not really.
| |
| thundergnat 2005-10-11, 6:58 pm |
| Robert wrote:
> I have a simple little app that lest me reset a user. It has
> radiobuttons to toggle which instance to reset the user in, an entry
> area to put the users ID into and a reset button. It works like a
> charm, except I can only reset one user and then I have to restart the
> app to do another. Is there a way to reset its state without doing a
> restart of the app?
>
> Thanks for you time.
>
> Robert
>
Hmmm.
Somthing like this, perhaps?
#!/usr/bin/perl
use warnings;
use strict;
use Tk;
my $top = MainWindow->new;
my $selection;
my $row = 0;
my $frame1 = $top->Frame->pack;
for(qw/ useful knowledgable incomprehensible bogus CHEESE /)
{
$frame1->Radiobutton
(
-variable => \$selection,
-value => $_,
-text => $_,
)->grid(-row => $row, -column => 0, -sticky => 'w');
$row++;
}
my $frame2 = $top->Frame->pack;
my $user = $frame2->Entry
(
-width => 40,
)->pack;
$frame2->Button
(
-text => q/Do it!/,
-command => sub {response($user->get, $selection); $user->delete(0,'end');},
)->pack;
MainLoop;
sub response{
my ($username, $state) = @_;
print "Who??\n" and return unless defined $username and length $username;
print "$username thinks this answer was ", ($state ? $state : 'undefined'), ".\n";
undef $selection;
}
__END__
|
|
|
|
|