我一直在做Perl/GTK開發幾年,現在知道你在說什麼。 Gtk2 :: Ex :: FormFactory是一個整潔的模塊,但實際上並不是我的東西,對於構建複雜的Perl/GTK應用程序絕對不是必需的。 Perl/GTK中的所有小部件(包括Windows)都支持show/hide方法。另外,您可以根據需要設置多個頂層窗口,只需根據需要顯示和隱藏即可。下面是在多個窗口之間切換的簡單示例:
#!/usr/bin/perl
use Glib qw/TRUE FALSE/;
use Gtk2 '-init';
$window = Gtk2::Window->new('toplevel');
$window->signal_connect(delete_event => sub { Gtk2->main_quit; });
$window->set_border_width(10);
$window->set_title("Window 1");
$window->set_position('center');
$button = Gtk2::Button->new("Switch to Window 2");
$button->signal_connect(clicked => sub {
$window->hide;
$window2->show;
});
$window->add($button);
$button->show;
$window2 = Gtk2::Window->new('toplevel');
$window2->signal_connect(delete_event => sub { Gtk2->main_quit; });
$window2->set_border_width(10);
$window2->set_title("Window 2");
$window2->set_position('center');
$button2 = Gtk2::Button->new("Switch to Window 1");
$button2->signal_connect(clicked => sub {
$window2->hide;
$window->show;
});
$window2->add($button2);
$button2->show;
$window->show;
Gtk2->main;