Reputation: 6337
I am looking for a Perl GUI tool that is as simple as PySimpleGUI. PySimpleGUI claims to be a good choice for things like this:
Those are my requirements and because PySimpleGUI offers all that, I gave it a try for a project. I liked it. That prompted to to try to find something like it for Perl.
I'm running perl 5, version 30 on Linux with KDE.
So far I only found:
I was not able to get the examples to run, and the supplied documentation doesn't meet my requirements. (I will ask about my specific problems with GUIDeFATE in a separate question, but GUIDeFATE is not actively developed like PySimpleGUI.)
I have used Kdialog for bash scripts in the past and it is not what I have in mind.
Is there an equivalent of PySimpleGUI for Perl?
Upvotes: 4
Views: 400
Reputation: 3262
Here is Håkon's example using Tk
use feature qw(say);
use strict;
use warnings;
use Tk;
my $text= '';
my $window = tkinit();
$window->Label(-text =>'Some text on Row 1')->grid();
$window->Label(-text=>'Enter something on Row 2',
)->grid(
$window->Entry(-textvariable=> \$text)
);
$window->Button(-text=>'Ok',
-command=>sub{say "You entered $text"},
)->grid(
$window->Button(-text=>'Cancel',-command=>sub{Tk::exit})
);
$window->withdraw;
$window->Popup;
MainLoop;
Upvotes: 2
Reputation: 40768
I was not able to find anything like PySimpleGUI
in Perl. I think you need to build the gui based on the full api of the toolkit (and not a simplified version of the api like PySimpleGUI
). I know that the Gtk3
and Tk toolkits are actively used. There are also the Wx and QtCore4 toolkits, but these are less used and not actively maintained in my opinion.
Here is an example in Gtk3
:
use feature qw(say);
use strict;
use warnings;
use Gtk3 -init;
my $window = Gtk3::Window->new( 'toplevel' );
$window->signal_connect( destroy => sub { Gtk3->main_quit() } );
my $grid = Gtk3::Grid->new();
$window->add( $grid );
my $label1 = Gtk3::Label->new('Some text on Row 1');
$grid->attach($label1, 0,0,1,1);
my $label2 = Gtk3::Label->new('Enter something on Row 2');
$grid->attach($label2, 0,1,1,1);
my $entry = Gtk3::Entry->new();
$grid->attach($entry, 1,1,1,1);
my $button1 = Gtk3::Button->new('Ok');
$button1->signal_connect('clicked' => sub { say "You entered ", $entry->get_text( ) } );
$grid->attach($button1, 0,2,1,1);
my $button2 = Gtk3::Button->new('Cancel');
$button2->signal_connect('clicked' => sub { $window->destroy() } );
$grid->attach($button2, 1,2,1,1);
$window->set_position('center_always');
$window->show_all();
Gtk3->main();
Upvotes: 2