What are good interactive GUI builder packages for Perl?

前端 未结 11 1043
你的背包
你的背包 2020-12-19 01:03

I\'d like to write some interactive GUIs in Perl. I\'ve used TclTk but it looks dated. I\'ve written QT code for C++, but the PerlTk module hasn\'t had a release in several

11条回答
  •  春和景丽
    2020-12-19 02:08

    Gtk2 has glade2 which can write out an XML file usable by Gtk2::GladeXML. Here is an example of how to bundle the XML with the app in the same file.

    I misread the question at first. I thought you wanted a GUI editor for making GUIs (which is what glade2 is). You can also create GUIs using Gtk2 without glade2:

    #!/usr/bin/perl
    
    use strict;
    use warnings;
    use Gtk2;
    
    Gtk2->init;
    
    my $window = Gtk2::Window->new;
    my $vbox   = Gtk2::VBox->new;
    my $label  = Gtk2::Label->new("Hello World");
    my $button = Gtk2::Button->new("Press me");
    
    $window->add($vbox);
    $vbox->add($label);
    $vbox->add($button);
    
    $window->set_default_size(200, 200);
    $window->signal_connect(
        destroy => sub {
            Gtk2->main_quit;
        }
    );
    
    my $i = 0;
    $button->signal_connect(
        clicked => sub {
            $label->set_text("button pressed " . ++$i . " times");
        }
    );
    
    $window->show_all;
    
    Gtk2->main;
    

提交回复
热议问题