Thank you, this link was a great help. After some effort I got the example working. Here is my result (it may help successors):
use strict;
use warnings;
use Tkx;
my $mw = Tkx::widget->new(".");
Tkx::package_require('widget::dialog');
my $db = $mw->new_widget__dialog(
-title => 'MyTitle',
-type => "okcancel",
-modal => "local",
# -parent => $mw,
# -padding => 10,
-synchronous => 1,
);
$db->g_bind('<Key-Return>', sub { $db->close('ok'); });
my $f = $db->getframe();
my $yearval = 2012;
my $weekval = 16;
my $sel_fr = $db->new_ttk__frame;
my $ly = $sel_fr->new_ttk__label(-text => "Year");
my $lw = $sel_fr->new_ttk__label(-text => "Week");
my $y = $sel_fr->new_ttk__spinbox(
-textvariable => \$yearval,
-from => 2009, -to => 2014,
);
my $w = $sel_fr->new_ttk__spinbox(
-textvariable => \$weekval,
-from => 1, -to => 53,
);
$ly->g_grid(-row => 0, -column => 0);
$lw->g_grid(-row => 1, -column => 0);
$y->g_grid(-row => 0, -column => 1);
$w->g_grid(-row => 1, -column => 1);
$sel_fr->g_pack(-in => $f);
my $answer = $db->display;
if ($answer ne "ok") {exit};
This solution is acceptable, but not perfect. For some reason the dialog buttons stick to the right side of the window.
In the meantime I found an alternative at http://tktable.sourceforge.net/tile/doc/dialog.html. This module has more modern syntax (options instead of positional parameters), and also additional interesting options. Unfortunately I failed already at the 1st line, translating package require ttk::dialog from Tcl/Tk to Perl/Tkx. Hopefully one of you monks can help me along again.
Kind regards GUIfriend |