http://www.perlmonks.org?node_id=332806


in reply to Re: Re: Pl/Tk
in thread Pl/Tk

I think it makes it make more "sense" to some programmers who might not know GUIs that well...
I am sure just as many don't like the magic involved ;-)

use Tk; my $v = 'one'; my $t = new MainWindow; my $e = $t->Entry(-textvariable=>\$v)->pack(); my $b = $t->Button(-text=>'Clear', -command=>sub{$v=""})->pack(); MainLoop();

Replies are listed 'Best First'.
Re: Re: Re: Re: Pl/Tk
by graff (Chancellor) on Mar 01, 2004 at 07:22 UTC
    it make more "sense" to some programmers who might not know GUIs that well...

    It can also make more sense to programmers who know GUIs all too well, and who prefer to keep their data-related variables/logic separate from their widget-specific variables/logic.

    And some programmers have additional reasons, involving the use of arrays and hashes to structure the data (and the GUI) in a maintainable fashion. It really can be more sensible to clear a bunch of Entry widgets by iterating over a set of scalar strings -- e.g.:  $_="" for (@ary); -- rather than calling the "delete()" method on a bunch of widgets...

      I was responding to a Tk newbie, offering a common solution.
      I also said others might want a diff option (kinda implied it anyway ;-).
      I didn't suggest using delete().
      I appreciate the advice, but the original poster is who I was trying to help by offering an option, they are free to read the advice of all posters and choose what they like ;-)
      I like that aspect of perlmonks!!!
Re: Re: Re: Re: Pl/Tk
by mawe (Hermit) on Mar 01, 2004 at 07:32 UTC
    Ah, that's new for me (obviously :-)). Thank you!