Installing Eclipse, the Epic Perl plugin and my first Perl GUI program
Today I installed Eclipse IDE and the EPIC perl plugin. If you are learning a new programming language like me, you really need some kind of editor which has at least code coloring features. I remember once when I typed a piece of code from a book and I just couldn't get it to compile. I never finished this book because I spend a lot of time trying to find my mistake and I gave up on it in the end. A few years later I picked the book up again, but this time I had a little more experience and I typed the piece of code in a programming editor. This time I found the mistake almost immediately. There was a : where a ; should be.
IDE
Reading this text you really need to watch closely to see the difference between ;and: or ,and. when it is in code which is also new to you it's almost impossible to find. This was something I overlooked many times and in the editor it showed up immediately, because it had a different color and the line containing the error was marked.
To save myself some of these frustrating experiences I'm going to use an IDE this time.
Eclipse
My choice has fallen on the Eclipse IDE, I know there are many good perl editors out there and I don't have any knowledge about which is the best choice for what job. I do know the choice of editor is very personal and there are even people who use vi as a Perl IDE. My main reason for using Eclipse is because I've read about it on a forum and many people seemed to like it (and it's free). It seems to be a bit of overkill to write my very simple pieces of code in a full fledged IDE and I know it has some downsides too. Then again, I know sometimes code keeps on growing and IDE's often have a lot of benefits for big projects. I could write Perl code and execute it immediately on the command line. That would be an easy start, but I think it might be a good investment in the future to get used to an IDE, as I start my journey.
Installing Eclipse
Installing Eclipse is not too difficult, in Ubuntu I just selected it in the package manager and that was it.
Alternatively from the command line :
sudo apt-get install eclipse
I just went with all the defaults, to keep it simple.
Installing Epic plugin
Next step is installing Epic. Epic is a plugin for Eclipse which enables Perl development. To install the plugin start the IDE and select the workbench.
go to help menu
select software updates
select Find and install
Select search for new features to install
select New remote site
fill in any name you like (I named it Epic)
and the url:
http://e-p-i-c.sf.net/updates/testing
which I've got from the epic site. This is for the testing release, if you want to go for stable use this:
http://e-p-i-c.sf.net/updates/
next select the update site you just named and select finish.
Eclipse will start checking for updates immediately after the window closes.
After a while a new window pops up saying new updates are available, just check the plugin in this new window. And select next. That's it, now you can start perl projects in the IDE.
First Project
The downside to using a full IDE like this is that it's intended use is for big projects and that's why small programs still need a lot of extra stuff to work. You need to create a project first,
I did that by going to file > new > project and in the pop up wizard I selected perl > perl project
I named the project perltest (original eh?), and used the default location which is the directory workspace in my home directory.
After selecting finish I've got a project
First program
Now we need to create a file, so we go to file > new > file
Select the project (if it isn't selected yet)
I named the file perltest.pl
Selecting finish creates a new empty file in the workspace.
I want to see something quick so I just copy past some code into the workspace.
I found some interesting tutorials on the gtk2 site
So I took some source code from the tutorial:
http://gtk2-perl.sourceforge.net/doc/intro/code/widget_layout.pl
This is an interesting example, it shows me some of the things I can do with a few lines of code and what is more important, I can understand most of what it does and try messing around with it a bit.
If you want the full dissection of what it does I suggest you read the tutorial.
http://gtk2-perl.sourceforge.net/doc/intro/
Run configuration
After I pasted it in the editor I wanted to run it.
Here comes another downside of using an IDE, as I select run > run from the menu I'm asked for a configuration. From the command line I could run this program by just entering perl followed by the program name.
Thankfully it's all pretty straightforward I just select Perl Local and name a new configuration, select my project perltest and from there the file to run perltest.pl.
The run configuration is kept so I don't need to do this for this project again.
Messing with the code
Now comes the fun part:
Clicking run makes a window pop up with 2 buttons, I think that's pretty impressive as it doesn't complain about having library this or that installed or anything. (I run gnome, I guess the gtk libraries come with that)
So now I can start playing with it. As I didn't start by reading the tutorials I don't know what most of it does, but I can make out some things by using common sense.
I start first by trying to change some of the words to see if that's allowed:
my $quit_button = Gtk2::Button->new('_Start');
When I run it now it says start on the quit button, so that works.
I wonder what that underline does, as I see an underline on the S of the button I wonder if it has something to do with that. And indeed moving it to another place in the word makes another letter become underlined. This means I can change the activation key for this button by simply moving the underline in the word. This is very intuitive.
I'm very pleased to see I can change things in this code without even reading anything about it. I know this is no rocket science, but still I can imagine this stuff quickly becoming a lot of fun to learn.
The other button is a counter button which responds to clicking on it by adding up a counter in the window.
So It's pretty obvious what this piece of code does:
$inc_button->signal_connect( clicked => sub {
$label->set_text("Clicked $count times.");
$count++;
});
This must be a subroutine (it's named sub and I recognize the ++ as an increment funtction)
Let's add something to this thing.
$inc_button->signal_connect( clicked => sub {
$label->set_text("Clicked $count times.");
$count++;
$frame->set_border_width($count);
});
I took some of the code earlier in the script and modified it a bit, as I typed the $ a screen popped-up showing me the possible variables for code completion. This is one of the great helpful features of the IDE. Well in this case it doesn't do too much for me, but I now in serious stuff it's very nice to have.
I hoped this would make my window grow as I click the button... and it does.
This is fun.
What to do next?
The next step I guess would be trying to add another button, to make the thing shrink again.
I'm finished for today. I think I'm going to read into these tutorials a bit, because I really like the ease and intuitive rules of this language. I think this is going to give me lots of joy.
API docs
The only thing I'm really looking for is some kind of API documentation which describes the functions I can call so I can for instance use a button to make the background change color or something.
Suggestions?
If you think there are more fun ways of messing with this code, please let me now. If there's anything more that could help me learn this quicker I really appreciate helpful comments.
Some people commented on my previous article pointing me to other GUI toolkits for perl and even some RAD (Rapid Application Development) tools of which I didn't know they existed for perl.
I'll definitely take a look into that stuff and I'll write on my experiences in future articles.
It can take a while before comments get published as most readers are in a different time zone.
This is the second article in a ongoing series about learning perl GUI programming. You may be interested in the other articles too. You can find the other articles here:
1. starting perl GUI programming
2. Installing Eclipse, the Epic Perl plugin and my first Perl GUI program
3. Open Source rocks! Learning from code by debugging
4. Quick and dirty linux GUI programming
5. resources for learning Perl Graphical Programming
6. Drawing and animating directly to the Desktop with Perl
7. Dynamically-creating-gui-objects-on-demand-in-Perl
Popular content
Recent blog posts
- HP linux netbook
- Toshiba Android netbook
- android video terminal
- rugged android phone
- Linux PC Robot < 500$ DIY Linux robot
- Q7 Linux MID nice but missing most important feature
- BD remote for android available soon
- Intelligent Linux based scriptable network camera
- Edge the first foldable dual screen ebook reader/netbook
- iPed chinese for iPad
don't forget to vote if you find something useful!!
- More things that Linux makes easy
9 weeks 13 hours ago - It looks rather like
10 weeks 2 days ago - Performance will be mediocre...
11 weeks 1 day ago - Off-base & Totally Terrible Review
11 weeks 3 days ago - suicidal robot bomber ?
11 weeks 3 days ago - Not a missing feature dumbass!
11 weeks 3 days ago - Impractical device
11 weeks 6 days ago - posting from my edge...
12 weeks 22 hours ago - Yes, running Android makes it expandable.
12 weeks 1 day ago - I have an edge and it is excellent
12 weeks 1 day ago
Navigation
Linux systeembeheer
Linux server

Smallest Linux PC, smaller
than an apple

Linux home automation

Electrical superbike
powered by Linux

Coolest Linux robot ever
transforming,camera,
remote control

Samsung tv Linux hack

Linux multimedia
dream machine

More cool stuff
like this solid gold macbook
at criticalcold.com
Tags
Best karma users
- kaikokan
- uioloio
- martha23
- jake
- j00p34
Categories



Geany too for me...
Anonymous 52 weeks 16 hours 45 min 8 sec ago
Yeah, I second the use of Geany now. It's so much simpler and straightforward as compared to Eclipse.
Cheers, Ed
opesource is always hard to
Anonymous 1 year 2 weeks 1 day 1 hour ago
opesource is always hard to find the right answer with so many options. thanks for sharing this solution to my problem.
wow. this article sure did
Anonymous 1 year 5 weeks 21 hours 24 min ago
wow. this article sure did help me with my problem. Thanks for sharing.
I only wish
Anonymous 1 year 7 weeks 3 days 4 hours ago
I only wish they had code coloring when I was copying in pages of basic out of Byte magazine when I was a kid with a Vic 20. So many cool looking games (at the time) never ran because I couldn't find my syntax error. Of course it didn't help when the magazine published with errors either.
Take care,
Jo
after a long search
Anonymous 1 year 15 weeks 6 hours 29 min ago
afer a lon search I found your description and all it was simple. Thank you very much for posting this. It was a great help for starting perl programming in an IDE environment.
Simple texteditor better for learning
Anonymous 1 year 16 weeks 3 days 17 hours ago
In my experience it is better to use something that don't do syntax coloring and intellisense when learning a new language. A plain old texteditor that just writes text forces the student to focus harder on what he writes and he will learn faster and the knowledge will stay with him for a longer time.
For real work, when you need to get work done as fast as possible, and you are supposed to know what you are doing, tools like Eclips are very handy.
maybe
kaikokan 1 year 16 weeks 3 days 1 hour ago
I think people learn in different ways. For me it helps to see results of my effort quickly, this keeps me motivated. Remember I'm not in a class with a teacher, I need to keep myself motivated and if I can't find what I'm doing wrong it's easily frustrating.
Another alternative
Anonymous 1 year 16 weeks 4 days 10 hours ago
Another alternative for Perl development is Padre - http://padre.perlide.org/ .
Padre is an emerging editor written in Perl. It's already very useful. I use it for professional Perl work every day.
Alternative
Anonymous 1 year 16 weeks 4 days 15 hours ago
Eh, Eclipse IS kinda overkill. I probably would have gone w/ Geany. But to each their own. That's the beauty of opensource.