Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

perl\tk $entry->configure(-show => 'NORMAL') ??? 1

Status
Not open for further replies.

NEVERSLEEP

Programmer
Apr 14, 2002
667
CA
hi
i was just wondering if any of u know how
to configure back a Entry widget 'show' ?
let me explain :
i have an entry box (no show option on declare)
then i 'protect' this field on user request
sub { $entry_widget->configure(-show => '*'); }
now all data entered in the $entry_widget are *
(but the value is 'retrivable' by ->get)
then i 'unprotect; this filed on user request
sub { $entry_widget->configure(-show => ...hummm??help?); }
does anyone know how to do this ? is it possible ?
how is there any other way to reach my goal ?

thanks a lot ---------------------------------------
wmail.jpg


someone knowledge ends where
someone else knowledge starts
 
There doesn't seem to be a way to do this. Here's a workaround.
Code:
use Tk;
$Main = MainWindow->new(); 
$Frame = $Main->Frame()->pack();
&BuildIt;
MainLoop();

sub BuildIt () {
    $Entry = $Frame->Entry()->pack;
    $Button1 = $Frame->Button(text=>'1', command=>\&Button1)->pack();
    $Button2 = $Frame->Button(text=>'2', command=>\&Button2)->pack();
}

sub Button1 () {
    $Entry->configure(-show, '*');
}

sub Button2 () {
    $Entry->packForget;
    $Button1->packForget;    
    $Button2->packForget;
    &BuildIt;
}
 
exellent example raider2001

i worked it around like this (thanks to u)

my $entry = $parent->Entry(...);
my $hide = $parent->Button(
...,
-command => sub { $entry->configure(-show => '*');}
);
my $show = $parent->Button(
...,
-command => sub {
$entry->packForget;
$entry->destroy
my $entry = $parent->Entry(...);
}
);
Mainloop; ---------------------------------------
wmail.jpg


someone knowledge ends where
someone else knowledge starts
 
here another one for u raider2001

i was wondering if it was possible to -state => 'disable'
a menu command ?

like in this example :
# ...
$mw->configure(-menu => my $mb = $mw->Menu);
my $mb_console = $mb->cascade(
-label =>'commands',
-tearoff => 0
);
$mb_console->command(
-label => 'Command 1',
-underline => 0
);
$mb_console->command(
-label => 'Command 2',
-underline => 1
);
# ...

in this piece of code how can i just disable command 1 ?
thanks ---------------------------------------
wmail.jpg


someone knowledge ends where
someone else knowledge starts
 
It is easy to disable a menu command. This is done by setting the state. Re-enabling the menu command is a little trickier. See example below:
Code:
use Tk;
my $MainW = MainWindow->new(); 
my $Menu = $MainW->Menu(-type => 'menubar');
$MainW->configure(-menu => $Menu);
$FileM = $Menu->cascade(-label => '~File', 
                        -tearoff => 0);
$FileM->command(-label => 'Find', 
                -state => 'disable');
$FileM->separator;
$FileM->command(-label => 'Quit', 
                -command => 'exit');
$Button = $MainW->Button(-text => 'Enable', -command => \&Enable);
$Button->pack();
MainLoop;

sub Enable() {
    $LogMenu = $FileM->cget('-menu'); 
    $LogMenu->entryconfigure('Find', -state=>'normal'); 
}
 
raider u rock !

can i abuse ?

how can i set a focus on a notebook page ?
command => sub { focus ? }
how can i set page2 as default
(that tk display him on top on start up)

in :
my $nb = $mw->NoteBook( ... )->pack( ... );
my $p1 = $nb->add('Page1', -label => 'page 01');
my $p2 = $nb->add('Page2', -label => 'Page 02');

thanks ---------------------------------------
wmail.jpg


someone knowledge ends where
someone else knowledge starts
 
... they wont let me give u stars (they say that its submited...) ---------------------------------------
wmail.jpg


someone knowledge ends where
someone else knowledge starts
 
Use 'raise' to put the desired page on tope like this:
$nb->raise('Page2');

If you have any more questions, please start a new thread. This makes it easier for people to find solutions by searching on thread titles.
 
star.gif
thanks raider2001 !
star.gif


i didn't wanted to start a new post :
1- leave place for other
(i find it anoying when a user post more than once the is question)
2- dosen't seems like alot of member know about tk ...
---------------------------------------
wmail.jpg


someone knowledge ends where
someone else knowledge starts
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top