SlideShare a Scribd company logo
GUI Programming 
with Perl / GTK
Anuradha Weeraman
anu@taprobane.org
http://www.linux.lk/~anu/
23 May 2006
 
Contents
●
 Overview 
●
 GUI Toolkits
●
 Hello World
●
 Layout
●
 C ­> Perl
●
 GUI Builders
●
 CPAN
Overview
●
 What's a widget?
●
 What's a GUI?
●
 What's a GUI toolkit?
●
 What's GTK?
●
 What's GTK­Perl?
●
 How is GUI programming different?
GUI Toolkits
●
 Athena Widget Library
●
 OSF Motif
●
 Xforms
●
 FLTK
●
 the GIMP Toolkit
●
 Qt Toolkit
●
 LessTif
Hello World
#!/usr/bin/perl
use Gtk2 '-init';
$window = Gtk2::Window->new;
$label = Gtk2::Label->new ("Hello World");
$window->add ($label);
$window->show_all;
Gtk2->main;
Hello World – Part 2
#!/usr/bin/perl
use Gtk2 '-init';
$window = Gtk2::Window->new;
$window->signal_connect(
destroy => sub { Gtk2->main_quit }
);
$label = Gtk2::Label->new ("Hello World");
$window->add ($label);
$window->show_all;
Gtk2->main;
Hello World – Part 3
#!/usr/bin/perl
use Gtk2 '-init';
$window = Gtk2::Window->new;
$window->set_title("Hello");
$window->signal_connect(destroy => sub { Gtk2->main_quit });
$button = Gtk2::Button->new ("Greetings Earthling");
$button->signal_connect(clicked => sub { Gtk2->main_quit });
$window->add ($button);
$window->show_all;
Gtk2->main;
Hello World – Part 4
#!/usr/bin/perl
use Gtk2 '-init';
sub quit_program {
Gtk2->main_quit;
print "Program has stopped.n";
}
$window = Gtk2::Window->new;
$window->set_title("Hello");
$window->signal_connect(destroy => &quit_program);
$button = Gtk2::Button->new ("Greetings Earthling");
$button->signal_connect(clicked => &quit_program);
$window->add ($button);
$window->show_all;
Gtk2->main;
Layout ­ HBox
$window = Gtk2::Window->new;
$hbox = Gtk2::HBox->new;
$button_1 = Gtk2::Button->new ("Button 1");
$button_2 = Gtk2::Button->new ("Button 2");
$hbox->pack_start ($button_1, 0, 0, 0);
$hbox->pack_start ($button_2, 0, 0, 0);
$window->add ($hbox);
Layout ­ VBox
$window = Gtk2::Window->new;
$vbox = Gtk2::VBox->new;
$button_1 = Gtk2::Button->new ("Button 1");
$button_2 = Gtk2::Button->new ("Button 2");
$vbox->pack_start ($button_1, 0, 0, 0);
$vbox->pack_start ($button_2, 0, 0, 0);
$window->add ($vbox);
C ­> Perl
●
 Consistent naming
●
 One­to­one mapping
●
 Object­oriented
●
 Transparently handles type­casting, reference 
counting etc.
●
 Exceptions allowed where Perl capabilities 
afford a cleaner API – multiple return values, 
string / array function parameters
Function Name Translation
g_ -> Glib
gtk_ -> Gtk2
gdk_ -> Gtk2::Gdk
gdk_pixbuf_ -> Gtk2::Gdk::Pixbuf
pango_ -> Gtk2::Pango
Function Name Translation
gtk_window_ -> Gtk2::Window
gtk_button_ -> Gtk2::Button
gtk_window_new -> Gtk2::Window->new
gtk_button_new -> Gtk2::Button->new
Function Parameters
gtk_window_set_title
(GtkWindow *window, gchar string)
becomes
$window->set_title ($string)
Function Parameters
GList replaced by variable number of arguments:
gtk_window_set_icon_list (GtkWindow * window, GList * list)
$window->set_icon_list (@icons)
Same with the array moved to the end of the parameter list:
gtk_list_insert_items (GtkList *list, GList *items, gint position)
$list->insert_items ($position, @items)
  
Array parameter and integer with the size of that array, replaced by variable number 
of arguments:
gtk_curve_set_vector (GtkCurve *curve, int veclen, gfloat vector[])
$curve->set_vector (@vector)
Same with the array moved to the end of parameter list:
gtk_item_factory_create_items (GtkItemFactory * ifactory,
guint n_entries, GtkItemFactoryEntry * entries,
gpointer callback_data)
$itemfactory->create_items ($callback_data, @entries)
Return Values
gtk_window_get_size (GtkWindow *window, gint *width,
gint *height)
($width, $height) = $window->get_size
gtk_calendar_get_date (GtkCalendar * calendar,
guint year, guint month, guint day)
($year, $month, $day) = $calendar->get_date
GUI Builders ­ Glade
Installing Modules
Download foo­module.tar.gz
$ tar zxvf foo­module.tar.gz
$ cd foo­module
$ perl Configure.PL
$ make
$ make test
# make install
           OR
use CPAN.
CPAN
●
 CPAN.org
●
 Comprehensive Perl Archive Network
●
 Mirrors all over the world
●
 Command line shell
●
 Bundled with standard Perl distribution
●
 Intuitive module management
CPAN
perl ­MCPAN ­e shell
cpan> install Term::ReadKey
cpan> install Term::ReadLine
cpan> install Bundle::CPAN
cpan> h or ?
 Thank You!
For more information, visit:
http://www.gtk.org
http://www.gtk2­perl.sourceforge.net
You can download this presentation 
from http://www.linux.lk/~anu

More Related Content

What's hot (17)

PDF
Docker presentation
Eugen Oskin
 
PPTX
ng-docs
Anuradha Bandara
 
PDF
T3chFest 2017 - La Revolucion del Open Source
Iván López Martín
 
PDF
How to Contribute to GStreamer
Samsung Open Source Group
 
PDF
Mobile Apps by Pure Go with Reverse Binding
Takuya Ueda
 
ODP
Gcc - Linux Hack Day
Leonn Ferreira
 
ODP
GStreamer Instruments
Kyrylo Polezhaiev
 
PDF
GroongaアプリケーションをDockerコンテナ化して配布する
ongaeshi
 
PDF
Graphics Programming OpenGL & GLUT in Code::Blocks
Budditha Hettige
 
ODP
GIT - DUG Antwerp
Krimson
 
PDF
Improving GStreamer performance on large pipelines: from profiling to optimiz...
Luis Lopez
 
PDF
Luigi - A Python framework for data processing and pipelining
Hoffman Lab
 
PPTX
Nuget
leeju lee
 
PDF
Kotlin everywhere: share your kotlin code across platforms
Boris D'Amato
 
PDF
Gcd(i os & os x 멀티스레딩 기법)
창욱 정
 
PDF
Introduction to the Moby Project
Jochen Zehnder
 
PPTX
How to Git and Github | Hands on workshop
PavitraBhagat
 
Docker presentation
Eugen Oskin
 
T3chFest 2017 - La Revolucion del Open Source
Iván López Martín
 
How to Contribute to GStreamer
Samsung Open Source Group
 
Mobile Apps by Pure Go with Reverse Binding
Takuya Ueda
 
Gcc - Linux Hack Day
Leonn Ferreira
 
GStreamer Instruments
Kyrylo Polezhaiev
 
GroongaアプリケーションをDockerコンテナ化して配布する
ongaeshi
 
Graphics Programming OpenGL & GLUT in Code::Blocks
Budditha Hettige
 
GIT - DUG Antwerp
Krimson
 
Improving GStreamer performance on large pipelines: from profiling to optimiz...
Luis Lopez
 
Luigi - A Python framework for data processing and pipelining
Hoffman Lab
 
Nuget
leeju lee
 
Kotlin everywhere: share your kotlin code across platforms
Boris D'Amato
 
Gcd(i os & os x 멀티스레딩 기법)
창욱 정
 
Introduction to the Moby Project
Jochen Zehnder
 
How to Git and Github | Hands on workshop
PavitraBhagat
 

Viewers also liked (8)

PDF
gtk2-perl
tutorialsruby
 
PDF
PHP-GTK
tutorialsruby
 
ODP
Javascript in Linux Desktop
Yuren Ju
 
PDF
GUI in Gtk+ con Glade & Anjuta
delfinostefano
 
PDF
Gtk development-using-glade-3
caezsar
 
ODP
Integrating CC Licensing with Applications
Nathan Yergler
 
PPT
Linux Kernel Development
Priyank Kapadia
 
PPTX
Introduction to c programming
Manoj Tyagi
 
gtk2-perl
tutorialsruby
 
PHP-GTK
tutorialsruby
 
Javascript in Linux Desktop
Yuren Ju
 
GUI in Gtk+ con Glade & Anjuta
delfinostefano
 
Gtk development-using-glade-3
caezsar
 
Integrating CC Licensing with Applications
Nathan Yergler
 
Linux Kernel Development
Priyank Kapadia
 
Introduction to c programming
Manoj Tyagi
 
Ad

Similar to GUI Programming with Perl / GTK (20)

PDF
gtk2-perl
tutorialsruby
 
PDF
An introduction to Gnome An introdu.pptx
JAYAVARSHINIJR
 
PDF
Quick and Dirty GUI Applications using GUIDeFATE
Connie New
 
PDF
Pygtk tutorial
HarikaReddy115
 
PPTX
Php on the Web and Desktop
Elizabeth Smith
 
PDF
Modern Perl desktop apps - Cluj.pm March 2014
Arpad Szasz
 
PPTX
GUI Programming using Tkinter-converted.pptx
dvarshitha04
 
PPTX
d1c70870-58fb-4da8-ae54-28d1c44a7347.pptx
pritigaikwad801
 
PDF
GUI toolkits comparison for python
Darren Su
 
PDF
Graphical User Interface or GUI
Jakaria Hossain Ridoy
 
PDF
Mastering Perltk 1st Ed Stephen Lidie Nancy Walsh
ymbyocwl494
 
PPTX
About Python Tkinter and creating .a GUI
jdatta247
 
PDF
Qt Tutorial - Part 1
rmitc
 
PDF
Introduction to linux
Kevin OBrien
 
PDF
Guy haviv - History of GUI visual design
Guy Haviv
 
PPTX
Operating system
NilaNila16
 
PPT
Intro tounix
Hamza Abdolateef
 
PPTX
CHAPTER 1 INTRODUCTION TO UNIX.pptx
MahiDivya
 
gtk2-perl
tutorialsruby
 
An introduction to Gnome An introdu.pptx
JAYAVARSHINIJR
 
Quick and Dirty GUI Applications using GUIDeFATE
Connie New
 
Pygtk tutorial
HarikaReddy115
 
Php on the Web and Desktop
Elizabeth Smith
 
Modern Perl desktop apps - Cluj.pm March 2014
Arpad Szasz
 
GUI Programming using Tkinter-converted.pptx
dvarshitha04
 
d1c70870-58fb-4da8-ae54-28d1c44a7347.pptx
pritigaikwad801
 
GUI toolkits comparison for python
Darren Su
 
Graphical User Interface or GUI
Jakaria Hossain Ridoy
 
Mastering Perltk 1st Ed Stephen Lidie Nancy Walsh
ymbyocwl494
 
About Python Tkinter and creating .a GUI
jdatta247
 
Qt Tutorial - Part 1
rmitc
 
Introduction to linux
Kevin OBrien
 
Guy haviv - History of GUI visual design
Guy Haviv
 
Operating system
NilaNila16
 
Intro tounix
Hamza Abdolateef
 
CHAPTER 1 INTRODUCTION TO UNIX.pptx
MahiDivya
 
Ad

Recently uploaded (20)

PDF
SFWelly Summer 25 Release Highlights July 2025
Anna Loughnan Colquhoun
 
PPTX
✨Unleashing Collaboration: Salesforce Channels & Community Power in Patna!✨
SanjeetMishra29
 
PPTX
Webinar: Introduction to LF Energy EVerest
DanBrown980551
 
PDF
Building Real-Time Digital Twins with IBM Maximo & ArcGIS Indoors
Safe Software
 
PDF
Complete Network Protection with Real-Time Security
L4RGINDIA
 
PPTX
AUTOMATION AND ROBOTICS IN PHARMA INDUSTRY.pptx
sameeraaabegumm
 
PPTX
UiPath Academic Alliance Educator Panels: Session 2 - Business Analyst Content
DianaGray10
 
PDF
Achieving Consistent and Reliable AI Code Generation - Medusa AI
medusaaico
 
PDF
How Startups Are Growing Faster with App Developers in Australia.pdf
India App Developer
 
PDF
Human-centred design in online workplace learning and relationship to engagem...
Tracy Tang
 
PPTX
WooCommerce Workshop: Bring Your Laptop
Laura Hartwig
 
PDF
Exolore The Essential AI Tools in 2025.pdf
Srinivasan M
 
PDF
The Builder’s Playbook - 2025 State of AI Report.pdf
jeroen339954
 
PDF
Transcript: New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
PDF
Jak MŚP w Europie Środkowo-Wschodniej odnajdują się w świecie AI
dominikamizerska1
 
PPTX
Building Search Using OpenSearch: Limitations and Workarounds
Sease
 
PDF
Complete JavaScript Notes: From Basics to Advanced Concepts.pdf
haydendavispro
 
PDF
Smart Trailers 2025 Update with History and Overview
Paul Menig
 
PDF
Wojciech Ciemski for Top Cyber News MAGAZINE. June 2025
Dr. Ludmila Morozova-Buss
 
PPTX
MSP360 Backup Scheduling and Retention Best Practices.pptx
MSP360
 
SFWelly Summer 25 Release Highlights July 2025
Anna Loughnan Colquhoun
 
✨Unleashing Collaboration: Salesforce Channels & Community Power in Patna!✨
SanjeetMishra29
 
Webinar: Introduction to LF Energy EVerest
DanBrown980551
 
Building Real-Time Digital Twins with IBM Maximo & ArcGIS Indoors
Safe Software
 
Complete Network Protection with Real-Time Security
L4RGINDIA
 
AUTOMATION AND ROBOTICS IN PHARMA INDUSTRY.pptx
sameeraaabegumm
 
UiPath Academic Alliance Educator Panels: Session 2 - Business Analyst Content
DianaGray10
 
Achieving Consistent and Reliable AI Code Generation - Medusa AI
medusaaico
 
How Startups Are Growing Faster with App Developers in Australia.pdf
India App Developer
 
Human-centred design in online workplace learning and relationship to engagem...
Tracy Tang
 
WooCommerce Workshop: Bring Your Laptop
Laura Hartwig
 
Exolore The Essential AI Tools in 2025.pdf
Srinivasan M
 
The Builder’s Playbook - 2025 State of AI Report.pdf
jeroen339954
 
Transcript: New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
Jak MŚP w Europie Środkowo-Wschodniej odnajdują się w świecie AI
dominikamizerska1
 
Building Search Using OpenSearch: Limitations and Workarounds
Sease
 
Complete JavaScript Notes: From Basics to Advanced Concepts.pdf
haydendavispro
 
Smart Trailers 2025 Update with History and Overview
Paul Menig
 
Wojciech Ciemski for Top Cyber News MAGAZINE. June 2025
Dr. Ludmila Morozova-Buss
 
MSP360 Backup Scheduling and Retention Best Practices.pptx
MSP360
 

GUI Programming with Perl / GTK