why not just re-grid the same widget again? That will
give you what you want.
gridForget doesn't destroy your widget. It just unmaps
it from the window. To remap it, grid it again.
--- Henry Merryweather
<henry.merryweather@xxxxxxxxxxxxxx> wrote:
> I want to selectively hide and then recall widgets
> and when I recall the
> widget it would be good if the widget was exactly
> the same as when it was
> hidden.
>
> gridForget hides the widget. However, I cannot see
> a way of simply
> recalling the widget with its contents the same as
> when it was ?forgotten?.
>
>
>
> I tested this with the Perl code below and attached.
> This gives two columns
> where each column is:
>
> 1. an Entry box at the top
> 2. a Button to remove the Entry box at the top
> 3. a Button to recall the Entry box at the top.
>
>
>
> In both cases, the Button is recalled by using the
> same widget definition as
> used when the GUI was created (but without setting
> the contents of the Entry
> box). This seems to have the effect (as expected)
> of overwriting the
> original definition so that the contents (when the
> widget is ?forgotten?)
> are lost. To overcome this:
>
> 1. I saved the contents of the Entry widget before
> using gridForget for
> the first column - in sub forget_CellA_cb;
> 2. I retrieved the contents of the Entry widget
> after using gridForget
> but before using the re-definition for the second
> column ? in sub
> recall_CellB_cb.
>
>
>
> Both worked. This also showed that the contents of
> the second Entry box
> were available even though this had been forgotten.
>
>
>
> The question is, is there a way of recalling the
> ?forgotten? widget with its
> contents intact without any additional code?
>
>
>
> # this tests the forget for a grid widget
>
>
>
> use Tk;
>
> use strict "vars";
>
>
>
> my ($mw_Main, );
>
> my ($CellA_Entry, $CellB_Entry, $CellC_Entry);
>
> my ($CellA_Text, $CellB_Text, $CellC_Text);
>
>
>
> #=====================================
>
> #
>
> # forget call backs
>
> #
>
> #=====================================
>
>
>
> sub forget_CellA_cb() {
>
>
>
> $CellA_Text = $CellA_Entry->get();
>
> $CellA_Entry->gridForget();
>
>
>
>
>
> }
>
>
>
> sub forget_CellB_cb() {
>
>
>
> $CellB_Entry->gridForget();
>
>
>
> }
>
>
>
> #=====================================
>
> #
>
> # recall call backs
>
> #
>
> #=====================================
>
>
>
> sub recall_CellA_cb() {
>
>
>
> $CellA_Entry = $mw_Main->Entry(-width => 6)->grid(
> -row => 0, -column => 0);
>
> $CellA_Entry->configure(-text => $CellA_Text);
>
> }
>
>
>
> sub recall_CellB_cb() {
>
>
>
> my $CellB_OldText;
>
>
>
> $CellB_OldText = $CellB_Entry->get();
>
>
>
> $CellB_Entry = $mw_Main->Entry(-width => 6)->grid(
> -row => 0, -column => 1);
>
> $CellB_Entry->configure(-text => $CellB_OldText);
>
> }
>
>
>
>
#===========================================================================
> ===
>
> #
>
> # sub gui-set
>
> #
>
> # this sets up a gui with Entry boxes, forget
> buttons and recall buttons
>
>
>
>
#===========================================================================
> ====
>
>
>
> sub gui_set() {
>
>
>
> $mw_Main = MainWindow->new;
>
>
>
> $CellA_Entry = $mw_Main->Entry(-width => 6, -text =>
> 'AAA')->grid(-row => 0,
> -column => 0);
>
> $CellB_Entry = $mw_Main->Entry(-width => 6, -text =>
> 'BBB')->grid(-row => 0,
> -column => 1);
>
>
>
>
>
> $mw_Main->Button(-text => "Forget Entry Box at Top",
> -command =>
> \&forget_CellA_cb)->grid(-row => 1, -column => 0);
>
>
>
> $mw_Main->Button(-text => "Forget Entry Box at Top",
> -command =>
> \&forget_CellB_cb)->grid(-row => 1, -column => 1);
>
>
>
>
>
> $mw_Main->Button(-text => "Recall Entry Box at Top",
> -command =>
> \&recall_CellA_cb)->grid(-row => 2, -column => 0);
>
>
>
> $mw_Main->Button(-text => "Recall Entry Box at
> Top",-command =>
> \&recall_CellB_cb)->grid(-row => 2, -column => 1);
>
>
>
>
>
> MainLoop;
>
>
>
> }
>
>
>
>
>
> ############## in line code
> #########################
>
>
>
> gui_set()
>
>
>
>
>
>
>
> Best regards
>
>
>
> Henry Merryweather
>
>
>
> Telephone: +44 (0) 1225 859051
>
> Web: HYPERLINK
>
"http://www.merryweathersolutions.co.uk"www.merryweathersolutions.co.uk
>
>
>
>
> No virus found in this outgoing message.
> Checked by AVG Free Edition.
> Version: 7.5.485 / Virus Database: 269.13.15/1002 -
> Release Date: 11/09/2007
> 17:46
>
>
> >
--++**==--++**==--++**==--++**==--++**==--++**==--++**==
> ptk mailing list
> ptk@xxxxxxxxxxxxxxxxxx
> https://mailman.stanford.edu/mailman/listinfo/ptk
>
>
____________________________________________________________________________________
Shape Yahoo! in your own image. Join our Network Research Panel today!
http://surveylink.yahoo.com/gmrs/yahoo_panel_invite.asp?a=7
--++**==--++**==--++**==--++**==--++**==--++**==--++**==
ptk mailing list
ptk@xxxxxxxxxxxxxxxxxx
https://mailman.stanford.edu/mailman/listinfo/ptk
|