我有一个非常简单的 GUI,它与 postgresql 数据库交互。主机分为 4 个象限,每个象限有 4 个入口小部件。这是一个象限的示例代码
my $f_blue = $bottom_half->Frame(-bg=>'BLUE')-> pack(-side=>'left', -expand=>1, -fill=>'both');
$f_blue->Label(-text=>'BLUE', -bg=>'blue', -fg=>'white')->pack(-side=>'top');
my $blue_table = $f_blue->Table(-rows => 3,
-columns => 3,
-fixedrows => 1,
-fixedcolumns => 1,
-scrollbars => 'oo',
-relief => 'raised') -> pack(-side => 'top', -expand => 1, -fill=>'both');
$blue_table -> put(1,1,
$blue_table->Label(-text => 'Cs-137:'));
my $t_blue_cs137 = $blue_table->Entry(-selectbackground=>"blueviolet");
$blue_table -> put(1,2,$t_blue_cs137);
$blue_table -> put(1,3,
$blue_table->Label(-text => 'MBq'));
$blue_table -> put(2,1,
$blue_table->Label(-text => 'Tc-99m:'));
my $t_blue_tc99m = $blue_table->Entry(-selectbackground=>"blueviolet");
$blue_table -> put(2,2,$t_blue_tc99m);
$blue_table -> put(2,3,
$blue_table->Label(-text => 'MBq:'));
$blue_table -> put(3,1,
$blue_table->Label(-text => 'Tl-201:'));
my $t_blue_tl201 = $blue_table->Entry(-selectbackground=>"blueviolet");
$blue_table -> put(3,2,$t_blue_tl201);
$blue_table -> put(3,3,
$blue_table->Label(-text => 'MBq:'));
使用 GUI 输入数据时,我无法通过选项卡跳到下一个条目。有没有办法设置键绑定,所以我可以循环设置
`$t_blue_cs137` to be active
PRESS TAB
`$t_blue_tc99m` NOW ACTIVE
PRESS TAB
`$t_blue_tl201` NOW ACTIVE
PRESS TAB
Do the same with the next quadrant
`$t_red_cs137` in frame $f_red NOW ACTIVE
有没有办法在 perlTK 中做到这一点
我试过以下
$f_blue->bindtags( [ ($f_blue->bindtags)[$t_blue_cs137,$t_blue_tc99m,$t_blue_tl201] ] );
# fix the bindtags order so that widget events are
# processed before class events
$f_blue->bind("<Tab>", sub { $f_blue->focusNext; Tk->break; });
但是,这只能让我在每个子框架和 GUI 中的按钮之间切换