On 3/5/07, Judith <[EMAIL PROTECTED]> wrote: > Hello every body I'm currently programming under perl Tk, but I want to > move to perl Gtk, I want to know the diffrences between these two and > wich is the last version of Gtk, thanks in advanced!!
You can find the latest versions of the Perl module on gtk2-perl.sf.net. The differences between Tk and Gtk are too numerous to talk about in any detail, but the biggest differences are in the way you pack and create widgets. In Tk you create widgets using a parent widget. in Gtk you create the widgets separately. In Tk you specify how a child widget is placed on it's parent with pack or some other function. In Gtk2 there are some widgets whose whole purpose is to be containers, and you add widgets to them. Generally you will use box widgets (Gtk2::HBox and Gtk2::VBox) to control the layout. There are others: Gtk2::Table is a tabular layout, Gtk2::VPaned and Gtk2::HPaned hold two widgets and allow you to move the separator between them, Gtk2::Notebook provides a tab based layout, Gtk2::Fixed is a fixed position layout, and others. You can learn more at http://gtk2-perl.sourceforge.net/doc/ Here is a quick hello world demo. #!/usr/bin/perl use strict; use Gtk2; Gtk2->init; #setup Gtk2 my $window = Gtk2::Window->new; #similar to MainWindow my $hbox = Gtk2::HBox->new; my $label = Gtk2::Label->new('Hello World'); my $button = Gtk2::Button->new('Quit'); #windows are containers that can only hold one item #so we need another container that can hold both #the label and the button, hbox is good for this #since it can hold any number of items and puts them in #a horizontal row $window->add($hbox); #window contains the hbox $hbox->add($label); #hbox contains the label $hbox->add($button); #hbox contains the label and the button #when we click on the close button of the window we want #the program to exit, so hookup the window's destory signal #with a function that will exit the program $window->signal_connect(destroy => \&quit_program); #we also want to quit when the quit button is pressed #so we attach the same function to the button's #clicked signal $button->signal_connect(clicked => \&quit_program); #nothing will show up until we tell Gtk to #show the widgets, we can do this by calling #the show method of every widget or by #calling the show_all method of window $window->show_all; Gtk2->main; #start the main loop sub quit_program { Gtk2->main_quit; } _______________________________________________ gtk-perl-list mailing list [email protected] http://mail.gnome.org/mailman/listinfo/gtk-perl-list
