如何在不使用子窗口的情况下调用另一个 Tk 窗口?
我正在制作 GUI(登录窗口)。 当密码正确时,登录窗口必须调用其他窗口。 PerlTk 有没有办法调用另一个窗口而不是使用子窗口?
use strict;
use Tk;
my $mw = MainWindow->new;
$mw->geometry("300x150");
$mw->configure(-background=>'gray',-foreground=>'red');
$mw->title("PLEASE LOGIN");
my $main_frame=$mw->Frame(
-background=>"gray",-relief=>"ridge",)->pack(-side=>'top',-fill=>'x');
my $left_frame=$main_frame->Frame(
-background=>"gray")->pack(-side=>'left',-fill=>'x');
my $bottom_frame1=$mw->Frame(
-background=>"gray")->pack(-side=>'bottom',-fill=>'x');
my $right_frame1=$mw->Frame(
-background=>"gray")->pack(-side=>'left',-fill=>'x');
my $button=$bottom_frame1->Button(-text=>"OK",-command=>\&push_button);
$button->pack(-side=>'left');
my $cancel=$bottom_frame1->Button(-text=>"CANCEL",-command=>sub{$mw->destroy});
$cancel->pack(-side=>'right');
my $entry2=$mw->Entry(-width=>20,-relief=>"ridge")->place(-x=>100,-y=>75);
sub push_button{
...
}
my $mw=MainWindow->new;
$mw->geometry("900x690");
I am making GUI (login window). When the password is correct, the login window must call other window. Is there a way in PerlTk to call another window rather than using subwindow?
use strict;
use Tk;
my $mw = MainWindow->new;
$mw->geometry("300x150");
$mw->configure(-background=>'gray',-foreground=>'red');
$mw->title("PLEASE LOGIN");
my $main_frame=$mw->Frame(
-background=>"gray",-relief=>"ridge",)->pack(-side=>'top',-fill=>'x');
my $left_frame=$main_frame->Frame(
-background=>"gray")->pack(-side=>'left',-fill=>'x');
my $bottom_frame1=$mw->Frame(
-background=>"gray")->pack(-side=>'bottom',-fill=>'x');
my $right_frame1=$mw->Frame(
-background=>"gray")->pack(-side=>'left',-fill=>'x');
my $button=$bottom_frame1->Button(-text=>"OK",-command=>\&push_button);
$button->pack(-side=>'left');
my $cancel=$bottom_frame1->Button(-text=>"CANCEL",-command=>sub{$mw->destroy});
$cancel->pack(-side=>'right');
my $entry2=$mw->Entry(-width=>20,-relief=>"ridge")->place(-x=>100,-y=>75);
sub push_button{
...
}
my $mw=MainWindow->new;
$mw->geometry("900x690");
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您只想要单独的 MainWindows 吗? 一旦构建了每个主窗口,就构建了各种小部件来引用正确的变量。 这是一个简短的程序,其中一个主窗口中有一个按钮,另一个主窗口中有一个按钮按下计数器:
Do you just want separate MainWindows? Once you construct each MainWindow, you construct the various widgets to reference the right variables. Here's a short program that has a button in one MainWindow and a button-press counter in the other MainWindow: