Adz07 wrote:
How do i create a frame 200x200 and make it stay centered in the app so even if the window is resized the frame stays 200x200 and stays in the center?? All the Vbox and Hbox stuff is confusing me
Here's the sample code:
<?php
$window = new GtkWindow();
$window->set_size_request(400, 300);
$window->connect_simple('destroy', array('Gtk','main_quit'));
$vbox2 = new GtkVBox(); // note 1
$vbox2->pack_start(new GtkLabel("This frame of size 200x200"));
$vbox2->pack_start(new GtkLabel("will always stay stay centered"));
$vbox2->pack_start(new GtkLabel("no matter how you resize the app"));
$eventbox = new GtkEventBox(); // note 2
$eventbox->add($vbox2);
$eventbox->modify_bg(Gtk::STATE_NORMAL, GdkColor::parse("#CCFF99"));
$frame_200_200 = new GtkFrame(); // note 3
$frame_200_200->set_size_request(200, 200);
$frame_200_200->add($eventbox);
$hbox = new GtkHBox(); // note 4
$hbox->pack_start(new GtkHBox());
$hbox->pack_start($frame_200_200, 0);
$hbox->pack_start(new GtkHBox());
$vbox = new GtkVBox(); // note 5
$vbox->pack_start(new GtkHBox());
$vbox->pack_start($hbox, 0);
$vbox->pack_start(new GtkHBox());
$window->add($vbox); // note 6
$window->show_all();
Gtk::main();
?>
Size and positioning in php-gtk2 is just like playing with lego building blocks. By combining various hboxes and vboxes, with appropriate use of the expand and fill parameters, you can achieve precise positioning and sizing of all widgets in PHP-GTK2.
More explanations here:
http://www.kksou.com/php-gtk2/articles/make-a-200x200-frame-always-centered-no-matter-how-you-resize-the-app-window.phpRegards,
/kksou
p.s. There's another similar example at:
http://www.kksou.com/php-gtk2/articles/change-tab-order---Example-4.phpIt also uses plain vbox's and hbox's to arrange the 12 buttons in a monopoly-like manner.