in reply to TK positioning of elements

Adding a additional frames is the right idea!
Pack is the most commonly used frame manager and is a good idea.

I think that the thing that you are missing is that you can make a sub() that is a "gizmo factory". I made a simple re-formulation of your code below to demo this idea which produces the same output on my machine as your 2nd version of code. You can make a bit different thing than your %config and include the text to be displayed in that structure and of course modify the add_entry_window() subroutine. There is another post in this thread that describes a widget that does what you need for a labeled entry window. I would use the most simple widget possible.

But what I'm trying to say is that if you wanted 50 of these sort of lines in the GUI, make maybe an AoA and call one sub in a loop that creates them all!

use Tk; $numberOfDailyLogsToCopy = 5; $numberOfAuditLogsToCopy = 5; my $mainWindow = MainWindow->new( -title => "main window", ); add_entry_gizmo ( $mainWindow, \$numberOfDailyLogsToCopy, "Enter the number of daily log files to copy", ); add_entry_gizmo ( $mainWindow, \$numberOfAuditLogsToCopy, "Enter the number of audit log files to copy", ); MainLoop; sub add_entry_gizmo { my ($window, $text_var_ref, $label, ) = @_; my $frame = $window -> Frame( -borderwidth => 2, ) ->pack(-anchor =>'w'); $frame-> Entry( -textvariable =>$text_var_ref, -width => 2, )-> pack(-side => 'left' ); $frame -> Label( -text => $label, ) -> pack(-side => 'left' ); }

Replies are listed 'Best First'.
Solved: TK positioning of elements
by wwe (Friar) on May 25, 2010 at 08:09 UTC
    Thank you!

    @Christoph: this what I was looking for. I tried to add a "Label" to an entry widget but failed :-( because it's not supported!

    @Marshall: At the moment I only need to this 2 elements but I hope to remember your solution in case I write more complex GUI. This is a really cool trick to abstract the creation of elements using a sub.