Beefy Boxes and Bandwidth Generously Provided by pair Networks Ovid
We don't bite newbies here... much
 
PerlMonks  

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).


Comment on Re: Perl Tk Naming Convention
Select or Download Code
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;
    becomes
    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?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (4)
As of 2014-04-20 20:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (487 votes), past polls