LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

View Poll Results: What's the ideal language to create a GUI front-end?
Python 4 25.00%
Ruby 2 12.50%
Perl/Tk 5 31.25%
Java 5 31.25%
Voters: 16. You may not vote on this poll

Reply
 
Search this Thread
Old 03-30-2007, 09:05 AM   #1
trashbird1240
Member
 
Registered: Sep 2006
Location: Durham, NC
Distribution: Slackware, Ubuntu (yes, both)
Posts: 463

Rep: Reputation: 31
GUI front-end for Perl script: opinions?


Dear Forum,

I still consider myself a novice in programming, even though I'm familiar with programming concepts. I've written a Perl script that takes statistical output and formats it for LaTeX. ONe of my colleagues expressed interest in using it on Windows, and suggested that I work up a way to do so. I'm the only one in my office that uses Linux, and most everybody else uses OS X.

Another friend of mine has just finished working up a rather elaborate GUI frontend in Java, so she's familiar with this subject. She suggested Java and that she would gladly help me with this.

The GUI would probably only consist of a dialog box, with an OK button and two boxes for the input file and the output file names. A splash screen would be fun but totally unnecessary.

Here's my level of programming skill:
*studied a little bit of Python, a little bit of C, a little bit of Scheme, enough Perl to write this program I'm already talking about.
*spend most of my days programming in Stata, a scripting language for a statistical software platform that is superficially similar to C
*I'm interested in Ruby, but have no compelling reason to study either Ruby or Python
*Have never written a GUI, or had any interest until now (I do most everything from the command line anyway)

My own opinions:
*I would rather not learn Java, as it seems like a deep subject; I would rather learn C first
*Ideally this GUI should function across platforms, although I'd be willing to tweak it to get it to go
*I would need an installer, too; these people are not fond of CLI

What should I use?
Joel

Last edited by trashbird1240; 03-30-2007 at 09:08 AM.
 
Old 03-30-2007, 10:06 AM   #2
weibullguy
ReliaFree Maintainer
 
Registered: Aug 2004
Location: Kalamazoo, Michigan
Distribution: Slackware-current, Cross Linux from Scratch, Gentoo
Posts: 2,703
Blog Entries: 1

Rep: Reputation: 219Reputation: 219Reputation: 219
Quote:
Originally Posted by trashbird1240
ONe of my colleagues expressed interest in using it on Windows, and suggested that I work up a way to do so. I'm the only one in my office that uses Linux, and most everybody else uses OS X.
Tell your colleague it would be easier to switch to Linux.

Quote:
Originally Posted by trashbird1240
Another friend of mine has just finished working up a rather elaborate GUI frontend in Java, so she's familiar with this subject. She suggested Java and that she would gladly help me with this.
This is the reason I voted for Java. If you choose something else that you're really not familiar with will you have support staff near by or will you need to use LQ? Something to think about. Your GUI is pretty simple so you wouldn't need to learn Java that deeply I would guess.

Or you could tell your Windows colleague to get R (with the GUI) and use the toLatex function.

Last edited by weibullguy; 03-30-2007 at 10:07 AM.
 
Old 03-30-2007, 11:10 AM   #3
trashbird1240
Member
 
Registered: Sep 2006
Location: Durham, NC
Distribution: Slackware, Ubuntu (yes, both)
Posts: 463

Original Poster
Rep: Reputation: 31
Quote:
Originally Posted by Arow
Tell your colleague it would be easier to switch to Linux.
He already told me he "wants to, but..." and that was without prompting. He's a smart guy, around here we call him "the world's top-ranked psychologist," (because he is, so it's not really a joke), but he still feels the pressure of the simple-minded software world.

Quote:
This is the reason I voted for Java. If you choose something else that you're really not familiar with will you have support staff near by or will you need to use LQ? Something to think about. Your GUI is pretty simple so you wouldn't need to learn Java that deeply I would guess.
Except that I actually know nothing about Java. There's plenty of people I could turn to with Java, but I don't know if that thoroughly justifies it, since I learned plenty of Perl without telling anybody what I was doing.

Quote:
Or you could tell your Windows colleague to get R (with the GUI) and use the toLatex function.
I'm not running the show, I'm just the star of it. They all know it would be better to do things my way, but they are stubborn and proud of their inefficient ways. If they did things my way, they'd have to stop saying "Who has time for all these meetings!"

BTW, the reason I wrote this program was to produce the kind of tables that we use here; they are quite different from what Stata or even R considers useful. There are many programs in Stata that will transfer things into TeX or LaTeX, but they only transform the output that Stata already produces, which is fairly useless to me. My program saves the time that I used to spend (and many of my colleagues still spend) of transcribing the results into a table. Most of them use Microsoft Word, but I think this may be a first step to convince them to try another option.

Joel
 
Old 03-30-2007, 11:16 AM   #4
taylor_venable
Member
 
Registered: Jun 2005
Location: Indiana, USA
Distribution: OpenBSD, Ubuntu
Posts: 892

Rep: Reputation: 40
Since you're already forcing them to have Perl on their machine, you might as well write it in Perl/Tk. It's cross platform, requires no installer, and has support in the default Perl bundle for whatever OS you want to run it on. Tk is also very simple to program, so you won't waste much time (though you wouldn't have to spend any time at all if those Windows weenies would just learn to type some text at the command-line).
 
Old 03-30-2007, 01:59 PM   #5
trashbird1240
Member
 
Registered: Sep 2006
Location: Durham, NC
Distribution: Slackware, Ubuntu (yes, both)
Posts: 463

Original Poster
Rep: Reputation: 31
So, better to force them to have Perl, rather than forcing them to have Perl, Ruby, Python and a computer built after 1994 (Java)? That would be rather oppressive ...

Joel
 
Old 03-30-2007, 02:11 PM   #6
KenJennings
LQ Newbie
 
Registered: Mar 2005
Location: FL, USA
Distribution: SuSE
Posts: 28

Rep: Reputation: 15
"None of the above" does not appear on your poll.
 
Old 03-30-2007, 02:21 PM   #7
trashbird1240
Member
 
Registered: Sep 2006
Location: Durham, NC
Distribution: Slackware, Ubuntu (yes, both)
Posts: 463

Original Poster
Rep: Reputation: 31
Quote:
Originally Posted by KenJennings
"None of the above" does not appear on your poll.
Is that object-oriented?
Joel
 
Old 03-30-2007, 03:06 PM   #8
trashbird1240
Member
 
Registered: Sep 2006
Location: Durham, NC
Distribution: Slackware, Ubuntu (yes, both)
Posts: 463

Original Poster
Rep: Reputation: 31
Just to clarify one thin about Perl/Tk: does the user (i.e., not me) need to have Perl/Tk installed?

Joel
 
Old 03-30-2007, 04:15 PM   #9
taylor_venable
Member
 
Registered: Jun 2005
Location: Indiana, USA
Distribution: OpenBSD, Ubuntu
Posts: 892

Rep: Reputation: 40
Quote:
Originally Posted by trashbird1240
Just to clarify one thin about Perl/Tk: does the user (i.e., not me) need to have Perl/Tk installed?
Yes, but Perl/Tk is part of almost all Perl distributions. For example, ActivePerl on Windows includes it, as do most Linux distros in their package system. AFAIK, only a few (for example, Debian) split it out into a separate package.
 
Old 03-30-2007, 04:57 PM   #10
paulsm4
Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
Perl/Tk is probably a great choice!

Hi -

Since you're comfortable with Perl; Perl/Tk would probably be an excellent choice. Additionally, anything you learn about Tk using the Perl interface would also be applicable to Python, Ruby or other open source languages you might wish to experiment with in the future.

Here's a tutorial that might help increase your comfort/confidence level:
http://www.perl.com/pub/a/2001/03/gui.html

From the same site, here's another alternative you might want to look at:
http://www.perl.com/pub/a/2001/09/12/wxtutorial1.html

'Hope that helps .. PSM

PS:
Here is one other Perl/Tk tutorial you might like:
http://www.bin-co.com/perl/perl_tk_t...ello_world.php

Last edited by paulsm4; 03-30-2007 at 05:02 PM.
 
Old 04-01-2007, 07:41 PM   #11
cyb0rg777
Member
 
Registered: Dec 2004
Location: ~
Distribution: Debian
Posts: 143
Blog Entries: 8

Rep: Reputation: 15
Here is a perl/tk script I wrote a few months ago.I just started using perl so it could probably be improved.I just took a bunch of examples and put them together really.
It is for converting ascii text to binary or hex and back again.
Later I may add more features such as encryption or morse code.
It's fun to play with.
Code:
#!/usr/bin/perl -w
use Tk;
use strict;

my $box;
my $dataout;
my $datain;
my $from='ascii';
my $to='bin';
my $mw = new MainWindow;
my $tin =$mw->Text(-background =>'white')->pack();
my $fromradio;
my $toradio;
my $fromascii=$mw->Radiobutton(-command=>\&notsameto ,-variable=>\$fromradio,-value=>1,-text=>'ascii');
my $fromhex=$mw->Radiobutton(-command=>\&notsameto,-variable=>\$fromradio,-value=>2,-text=>'hex');
my $frombin=$mw->Radiobutton(-command=>\&notsameto,-variable=>\$fromradio,-value=>3,-text=>'bin');
my $toascii=$mw->Radiobutton(-state=>'disabled',-variable=>\$toradio,-value=>1,-text=>'ascii');
my $tohex=$mw->Radiobutton(-state=>'disabled',-variable=>\$toradio,-value=>2,-text=>'hex');
my $tobin=$mw->Radiobutton(-state=>'disabled',-variable=>\$toradio,-value=>3,-text=>'bin');

$fromascii->pack(-side=>'left');
$frombin->pack(-side=>'left');
$fromhex->pack(-side=>'left');
$toascii->pack(-side=>'right');
$tobin->pack(-side=>'right');
$tohex->pack(-side=>'right');

$tin->delete('1.0','end');
$tin->insert('end','test');


my $response = $mw -> Button(-text=>"Convert",-command => \&convert)->pack();

MainLoop;

sub notsameto{
if($fromradio==1){
	$toascii->configure(-state=>'disabled');
	$tobin->configure(-state=>'normal');
	$tohex->configure(-state=>'normal');
	return;
	}
if($fromradio==2){
	$tohex->configure(-state=>'disabled');
	$tobin->configure(-state=>'normal');
	$toascii->configure(-state=>'normal');
	return;
	}
if($fromradio==3){
	$tobin->configure(-state=>'disabled');
	$tohex->configure(-state=>'normal');
	$toascii->configure(-state=>'normal');
	return;
	}
}


sub b2ascii
{
my $l=length $_[0];
my $a=+pack "B$l",$_[0];
return $a;
}

sub a2hex
{
    (my $str = shift) =~ s/(.|\n)/sprintf("%02lx", ord $1)/eg;
    return $str;
}
sub h2ascii
{
    (my $str = shift) =~ s/([a-fA-F0-9]{2})/chr(hex $1)/eg;
    return $str;
}

sub a2bin
{
        my $l=(length $_[0])*8;
        my $a=+unpack "B$l",$_[0];
        return $a;
}

sub convert(){
if(!$toradio){return;}
$datain=$tin->get('1.0','end');
$tin->delete('1.0','end');
if ($fromradio==1){
    if ($toradio==3){$dataout=a2bin($datain);}
    if ($toradio==2){$dataout=a2hex($datain);}
    }
if($fromradio==2){
if($datain!~/[a-fA-F0-9]/)
    {
	$box = $mw->DialogBox( -buttons => ["OK"])->pack();
    return;
	}
	if($toradio==1){$dataout=h2ascii($datain);}
    if($toradio==3){$dataout=a2bin(h2ascii($datain));}
    }
if($fromradio==3){
    if ($datain!~/01/)
	{
	$box = $mw->DialogBox( -buttons => ["OK"])->pack();
    return;
	}
    if($toradio==1){$dataout=b2ascii($datain);}
    if($toradio==2){$dataout=a2hex(b2ascii($datain));}
    }
$tin->insert('end',$dataout);
return;
}
I don't want to debate personal preference ,but for me perl is more like c ,so it was easier to learn. And it's a script which I prefer over compiled language like java.

Last edited by cyb0rg777; 04-01-2007 at 09:38 PM.
 
Old 04-02-2007, 02:36 AM   #12
chrism01
Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.5, Centos 5.10
Posts: 16,239

Rep: Reputation: 2024Reputation: 2024Reputation: 2024Reputation: 2024Reputation: 2024Reputation: 2024Reputation: 2024Reputation: 2024Reputation: 2024Reputation: 2024Reputation: 2024
Logically, as above, if you're already using Perl to do the processing, (& therefore will have to install it anyway), you might as well go with Perl/Tk.
Potentially, if you fancy a server/client situation, write a web page in CGI Perl... Only need to keep 1 copy of code updated....
 
Old 04-02-2007, 06:32 AM   #13
wolfger
LQ Newbie
 
Registered: Oct 2006
Distribution: Ubuntu - Feisty Fawn
Posts: 25
Blog Entries: 3

Rep: Reputation: 15
I love Perl. Absolutely love it. And I fairly well loathe Java. But Perl/Tk as the "ideal language to create a GUI"??!? What are you people smoking? I find Perl/Tk to be moderately hideous, with no good WYSIWYG editors to assist in design. Yeah, sure, it's nice to work with a scripted language over a compiled language, but I'd take Java with a good IDE over Perl/Tk for GUI creation any day of the week.

That being said, it sounds like the task at hand could be much easier done with HTML/CSS and a web browser. For simple GUIs, it's all that's really needed.
 
Old 04-02-2007, 09:39 AM   #14
trashbird1240
Member
 
Registered: Sep 2006
Location: Durham, NC
Distribution: Slackware, Ubuntu (yes, both)
Posts: 463

Original Poster
Rep: Reputation: 31
Thanks for all the excellent and helpful replies.

I installed Perl/Tk on Friday. I thought that my distribution did not have it, since I got the following error:

Code:
Can't locate Tk.pm in @INC (@INC contains: /usr/lib/perl5/5.8.8/i486-linux /usr/lib/perl5/5.8.8 /usr/lib/perl5/site_perl/5.8.8/i486-linux /usr/lib/perl5/site_perl/5.8.8 /usr/lib/perl5/site_perl .) at tk line 2.
BEGIN failed--compilation aborted at tk line 2.
After running an example from a Perl/Tk tutorial.

So, then I installed Perl/Tk and got the same error message. I reckon @INC is a hash, but where is it and how would I edit it?

[edit: this is because I installed Tk from CPAN as a user, not as root; I have since corrected this and the trial script works]

Joel

Last edited by trashbird1240; 04-02-2007 at 10:13 AM.
 
  


Reply

Tags
perl, python, ruby


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Recommendations for perl script front-end ojaiguy Linux - General 3 07-03-2006 06:34 AM
Recommendations for perl script front-end ojaiguy Linux - Software 1 07-03-2006 04:03 AM
How to build front-end (GUI) satimis Programming 3 12-02-2004 01:25 AM
iwlist GUI front end? sjoeboo Linux - Wireless Networking 3 09-09-2004 10:25 PM


All times are GMT -5. The time now is 10:29 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration