I'm writing some Perl/TK code and I can't figure out how to
programmatically change the position of a sub frame. I can read and
change the size of the main window but I can't figure out how to read or
change the position of the sub frame. The plan is to be able to let the
user change the size of the window and position of the adjuster and save
the settings on exit so the app comes up in the same configuration the
next time they run it.
I've scoured "Learning Perl/TK", "Mastering Perl/TK", and Google and
haven't found a solution. Below is some code that demonstrates the
problem.
I'm using Perl v5.6.1, and TK 800.022.
Totally stumped,
keith
#!c:\perl\bin\perl.exe -w
use strict;
use Tk;
use Tk::Adjuster;
use Tk::ROText;
use Tk::Scrollbar;
my($main_window) = MainWindow->new();
$main_window -> title ("window test");
$main_window -> geometry ("500x525");
$main_window -> bind ('<Alt-Key-t>', \&TEST);
$main_window -> bind ('<Alt-Key-T>', \&TEST);
$main_window -> bind ('<Return>', \&TEST);
$main_window -> bind ('<Alt-Key-c>', \&CHANGE);
$main_window -> bind ('<Alt-Key-C>', \&CHANGE);
my $size = 'large';
my $frame1 = $main_window -> Frame (
-borderwidth => 1,
-relief => 'groove'
) -> pack (
-side => 'top',
-anchor => 'n',
-fill => 'x'
);
my $data_entry = $frame1 -> Entry (
-exportselection => 2,
) -> pack (
-side => 'left',
-fill => 'x',
-anchor => 'n',
-expand => 1
);
my $test_button = $frame1 -> Button (
-text => 'Test',
-command => \&TEST,
-underline => '0'
) -> pack (
-side => 'left',
-anchor => 'n'
);
$test_button -> bind ('<Return>', \&TEST);
my $frame2 = $main_window -> Frame (
-borderwidth => 2,
-relief => 'groove',
) -> pack (
-fill => 'both',
-expand => 1
);
my $listbox = $frame2 -> Scrolled (
"Listbox",
-scrollbars => 'se',
-selectmode => 'browse',
-background => 'white',
-takefocus => 1
);
$listbox -> pack (
-side => 'top',
-fill => 'x',
-anchor => 'n'
);
my $adjuster = $frame2 -> Adjuster (
) -> packAfter (
$listbox
);
my $text_box = $frame2 -> Scrolled (
"ROText",
-scrollbars => 'se',
-wrap => 'none',
-takefocus => 1
) -> pack (
-fill => 'both',
-expand => 1
);
MainLoop;
1;
sub TEST {
if ($size eq 'large') {
$main_window -> geometry ("400x400");
$size = 'small';
} else {
$main_window -> geometry ("500x525");
$size = 'large';
}
$main_window->update;
my $listbox_geometry = $listbox -> geometry;
print ("\nList Box Geometry = ", $listbox_geometry, "\n");
my $text_box_geometry = $text_box -> geometry;
print ("\nText Box Geometry = ", $text_box_geometry, "\n");
print ("\n=======================================\n");
}
sub CHANGE {
$listbox -> geometry ("200x140");
}
--
Keith R. Watson Georgia Institute of Technology
Systems Support Specialist IV College of Computing
keith.watson@xxxxxxxxxxxxx 801 Atlantic Drive NW
(404) 385-7401 Atlanta, GA 30332-0280
--++**==--++**==--++**==--++**==--++**==--++**==--++**==
ptk mailing list
ptk@xxxxxxxxxxxxxxxxxx
https://mailman.stanford.edu/mailman/listinfo/ptk
|