Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked

Re: Perl Tk Naming Convention

by arkturuz (Curate)
on Jan 13, 2010 at 15:24 UTC ( #817195=note: print w/replies, xml ) Need Help??

in reply to Perl Tk Naming Convention

The $blah_ part could also specify widget hierarchy. For example:
my $frame1 = Tk::Frame->new; my $frame1_btn_ok = Tk::Button->new;
When relocating $frame1_btk_ok to different frame you get $frame2_btn_ok. That's how I do it in Perl/Tk and Tcl/Tk ('.' being the separator here).

Replies are listed 'Best First'.
Re^2: Perl Tk Naming Convention
by zentara (Archbishop) on Jan 13, 2010 at 15:39 UTC
    I usually go with the hash approach, because it is then easier to modularize. So
    my $frame1 = Tk::Frame->new; my $frame1_btn_ok = Tk::Button->new;
    my %widget_hash; my $frame_count = 0; foreach my $count(1..10){ $widget_hash{$count}{ 'frame'} = $mw->Frame->new; $widget_hash{$count}{ 'ok_but'}= $widget_hash{$count}{ 'frame'}->Tk::Button->new; }

    The advantages of doing that way, is that you can easily use a variable in your hash strings, rather than trying to concantate strings into strings

    I'm not really a human, but I play one on earth.
    Old Perl Programmer Haiku
      I used hashes before (after seeing them in the source code ZooZ produces), but now I just stick to underscores. I rarely modify GUI after I'm done with it, so the hashes are not really necessary, I think. For some complex application, I think the hashes would be better approach after all.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://817195]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (4)
As of 2021-06-23 18:23 GMT
Find Nodes?
    Voting Booth?
    What does the "s" stand for in "perls"? (Whence perls)

    Results (121 votes). Check out past polls.