Do you know where your variables are? | |
PerlMonks |
Re: Verbose Tk Codeby kcott (Archbishop) |
on Mar 01, 2021 at 12:38 UTC ( [id://11128950]=note: print w/replies, xml ) | Need Help?? |
Me again :-) I had multiple interruptions when composing my original response, "Re: Verbose Tk Code"; I think I finally posted it three or four hours after starting it. I kept thinking that I'd missed something but couldn't tell what that was. Now I see it was the 'with ($left1) {...}' pseudocode. Firstly, a couple of notes. I wouldn't use spaces for padding text; there are a number of '*pad*' options that would be a better choice, also look for other options, such as '-anchor' and '-sticky', which may be useful. If you want to align widgets vertically, grid() is a better choice than pack(); I don't know if that was your intent here. Using my earlier suggestions, and the notes above, your pseudocode could be implemented as simply as:
If you haven't used the option database, add "-background => 'cyan'" to the line above. You'll probably want some pack options like "-padx => 5, -anchor => 'w'" (but that's a complete guess as I don't know what layout you're aiming for). As a more general solution, where you perhaps have complicated options and wanted to store the objects created for later use, something along these lines:
That's obviously very rough and incomplete but hopefully gives you an idea. See also the Widget Demo. The Radiobutton example has a number of blocks of code along the same lines as I have here. — Ken
In Section
Seekers of Perl Wisdom
|
|