Previous
Reference 
Perl/Tk Tutorial - Create GUI with Perl's Tk Module
Appendix

Appendix

Appendix A : About the Author

My name is Binny V A. I have been programming in Perl and Tcl/Tk for a while now - but only recently have I started programming with Perl/Tk. So I am not an expert in Perl/Tk. But I have already written a tutorial for Tcl/Tk. So I thought that I will translate the Tk parts to perl and give the world a new Perl/Tk program. So don't be angry if you see a lot of similarities between Tcl/Tk Tutorial and this Perl/Tk tutorial. I can plagiarise from myself, can't I? Anyway, all questions, suggestions, criticisms etc can be directed to . You can know more about me at my website. For all the programs that I made in Perl, go to the perl page in my site.

If you have liked this tutorial, I have wrote another tutorial on Tcl/Tk language. Check it out.
I also wrote tutorials on CGI-Perl and JavaScript.


Appendix B : Commonly Made mistakes in Perl/Tk

There are a few 'irregularities' at the places where Perl and Tk meet. These places are often a source of problems for new Perl/Tk programmers. Here is a list of most common mistakes made by new Perl/Tk programmers. I made quite a few of them myself.

Callbacks
Calling a function from a button is almost always trouble for the inexperienced. Assume that you created a function called showGreeting. $button = $mw -> Button(-text=>"Hello",-command=>showGreeting); #- Won't work.
$button = $mw -> Button(-text=>"Hello",-command=>showGreeting()); #- Again, won't work.
$button = $mw -> Button(-text=>"Hello",-command=>&showGreeting); #- Will not work.
This is the porper way of doing it.
$button = $mw -> Button(-text=>"Hello",-command=>\&showGreeting); #- Finally. Something that works.
$button = $mw -> Button(-text=>"Hello",-command=>sub { showGreeting(); } ); #- Another method of doing it.

Variables
This has a similar effect as the above problem.
$entry = $mw -> Entry(-textvariable=>$var); #- This is not the right way.
$entry = $mw -> Entry(-textvariable=>\$var); #- Correct way.

Using qw//
Don't use a white space inside a value if you are using the qw// method to configure options. See below for more details.


Appendix C : Tcl/Tk And Perl/Tk

If you are more squinted with the Tcl/Tk's way of doing it, you will be happy to know that there is a way of giving the options in the Tcl/Tk style.
$label = $mw -> Label(qw/-text Hello -font courierfont -relief raised/) -> pack();
qw function will split the given string at white space. It can be understood as being roughly equivalent to:
split(' ', q/STRING/);
So the no space is allowed inside values if you are using this. For example, the following line will create an error.
$label = $mw -> Label(qw/-text "Hello World" -font courierfont -relief raised/) -> pack();
Even using quotes(") will give unexpected results.
$label = $mw -> Label(qw/-text "Hello" -font courierfont -relief "raised"/) -> pack();


Appendix D : Codes

Almost all the programs in the tutorial are available in a zipped format for download.


Appendix E : FeedBacks

How do you like this tutorial? Pen some comments below.

If you have any questions send me an e-mail at . If you leave a question in the above feedback form, be sure to give you e-mail address if you want me to respond.

Previous
Reference 

Comments

Anonymous at 19 Apr, 2007 05:48
This is an excellent tutorial. It gives you all the information you need to start writing GUI programs, and gives you information and were to go and to get more.
Reply to this.
Laurence at 12 Jul, 2007 12:32
Thank you so much for this tutorial, it has helped me loads.
Keep up the good work.
Reply to this.
Pankaj at 09 Aug, 2007 12:12
Quite informative. Got all the information i needed as a beginner.
Thanks.
Reply to this.
Maria J. at 16 Aug, 2007 06:24
I find this tutorial very, very helpful. Thanks a lot for your clear, well structured explanation and great examples.
Reply to this.
Mark at 24 Aug, 2007 11:54
I agree excellent starting point, short and to the point. Much better than the bask in my own glory types that frequent a lot of the linux post sites.
Reply to this.
Doug at 25 Sep, 2007 12:28
I agree with the others, this is an Excellent tutorial! Thanks for setting it up. It helped me to quickly get back into shape working with tk after a break of 10 years. I just wish the authors of the published books followed your writing style of clear examples!

Keep up the fantastic work!
Reply to this.
Anonymous at 29 Nov, 2007 10:06
This tutorial was really of great help to me as i was a begginner. If we have two labels how can the second label be printed in the next line by using pack geometry manager( i used framalso).I could not get that option. By using grid i was able to do this.Hope you will reply me as soon as possible.Thank you.
Reply to this.
Binny V A at 30 Nov, 2007 02:00

pack .first_label
pack .second_label


That should do it
Reply to this.
Avidan Zhang at 22 Jan, 2008 12:28
Very helpful tutorial! Easy for new comers to make first step in TK under PERL.
Thank you very much!
Reply to this.
Panayiotis Omirou at 21 Jul, 2008 02:58
Excellent tutorial for encouraging people using perl to create guis.Good Job!
Reply to this.
K Burke at 14 Aug, 2008 02:24
Many thanks, this tutorial was very useful. My first faltering steps away from command line input/ouptput!!
Reply to this.
Vijay at 26 Mar, 2009 10:06
Hi,

I want to open the browser (IE or FireFox) in TK window (frame). Is it possible?

or

Is it possible to display a webpage inside TK frame? If possible how?

Please send mail to vijaybabur@mobiusservices.in
Reply to this.
Comment

Please dont enter you comments in this form - this is a fake form to confuse spamming bots. The next form is the real one.




Comment




Comment Formating : HTML tags a, strong, em, b, i, code, pre, p and br allowed. Other tags will be shown as code(< will become &lt;). Urls, Line breaks will be auto-formated.
Subscribe to Feed