Re: Feedback for programming a UI in Perl
by james28909 (Deacon) on Aug 29, 2016 at 00:43 UTC
|
If you have already dove into Wx, I would suggest sticking with it. once you learn the syntax it is actually pretty easy to use. Im sure everyone will have their own opinion though! | [reply] |
|
|
code snips welcome:
- two or more panels
- if a trigger is on, text green, off, text red
- display small image
If you're recommending one UI distribution over another, for this thread, I'd like real-world examples as to why. Particularly, situations where documentation of any dist excels beyond others.
| [reply] |
|
|
I usually use Tk or a local webserver. If you want to see how Tk works and how its code looks like, intall it and run widget . I don't know what you mean by "panel" or "trigger", so I can't show you the snippets.
($q=q:Sq=~/;[c](.)(.)/;chr(-||-|5+lengthSq)`"S|oS2"`map{chr |+ord
}map{substrSq`S_+|`|}3E|-|`7**2-3:)=~y+S|`+$1,++print+eval$q,q,a,
| [reply] [d/l] [select] |
|
|
| [reply] |
|
|
#!/usr/bin/perl
# http://perlmonks.org/?node_id=1170638
use strict;
use warnings;
use Tk;
use Tk::JPEG;
use Image::Size;
my $file = '../smalltux.gif';
my ($w, $h) = imgsize($file);
my $mw = new MainWindow;
my $one = $mw->Frame()->pack;
my $labelone = $one->Label(-text => 'Panel One', -fg => 'red',
)->pack(-side => 'left');
$one->Button(-text => 'On',
-command => sub { $labelone->configure(-fg => 'green')},
)->pack(-side => 'left');
$one->Button(-text => 'Off',
-command => sub { $labelone->configure(-fg => 'red')},
)->pack(-side => 'left');
my $c = $mw->Canvas(-width => $w, -height => $h )->pack();
my $im = $c->Photo(-file =>$file);
$c->createImage(0, 0, -image => $im, -anchor => 'nw');
my $two = $mw->Frame()->pack;
my $labeltwo = $two->Label(-text => 'Panel One', -fg => 'red',
)->pack(-side => 'left');
$two->Button(-text => 'On',
-command => sub { $labeltwo->configure(-fg => 'green')},
)->pack(-side => 'left');
$two->Button(-text => 'Off',
-command => sub { $labeltwo->configure(-fg => 'red')},
)->pack(-side => 'left');
MainLoop;
| [reply] [d/l] |
|
|
|
|
|
|
|
|
|
|
|
|
|
I too, usually use Tk. There is a simple GU code generator for it called vptk that I also use. Also, I created a menu builder "super widget".
Also, I've heard good things about the WxWidgets GTK toolkit and the Glade GUI builder for it (there are modules for generating Perl code from Glade description files). Not yet tried it.
Update: I meant GTK, not WxWidgets.
| [reply] |
Re: Feedback for programming a UI in Perl
by Anonymous Monk on Aug 29, 2016 at 01:59 UTC
|
UI platforms differ only by the widgets they offer and what they look like
another differentiating criteria is supported platforms, and if binaries are available (ie how easy it is to build or get it running)
what you're looking for is trivial functionality any software called a "UI platform" supports
choosing by looks is easy/popular option, as is choosing by platform/build/binaries
| [reply] |
Re: Feedback for programming a UI in Perl
by nikosv (Deacon) on Sep 01, 2016 at 17:25 UTC
|
I've gone with Tk for making a Win32 based GUI application,although most code is platform agnostic.It uses a queue of threads on the background so the the main UI thread does not freeze.The Windows specific part is that it uses Kernel events to sync i.e pause and resume the background thread when clicking on the "Pause/Resume" button in the UI.
The 'exe' is packaged with Par::Packer so it is portable and runs everywhere without installation.
I'm hosting it on Launchpad so you can take a look;well why not even contribute to it ?
Unrar Extract and Recover on Launchpad
If you're looking for the binary distribution, it can be directly downloaded from
UERSetup
| [reply] |
|
|
Thanks nikosv, I've decided to stick with Wx after learning the ropes using the Wx::Demo mentioned already, but I will take a look at what you've got as I'm interested in the threading aspect that prevents main window blocking.
If it appears useful, I'll replicate it in Wx. My time's pretty limited lately working on my own electronics projects (code and hardware), so I can't say I'll be able to contribute, but who knows. I go off on tangents creating patches/PRs for random projects frequently, even when that was the farthest thing from my mind :)
| [reply] [d/l] |
|
|
| [reply] |