in reply to Re: Perl Tk Naming Convention
in thread Perl Tk Naming Convention

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

Replies are listed 'Best First'.
Re^3: Perl Tk Naming Convention
by arkturuz (Curate) on Jan 13, 2010 at 15:57 UTC
    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.