Sample Code 2: How to change the size of GtkWindow? |
|
Written by kksou
|
|
Tuesday, 12 September 2006 |
|
Problem You want to change the size of GtkWindow as shown below:

Solution Use GtkWidget::set_size_request (int width, int height)
$window->set_size_request(400, 100);
Sample Code 1 2 3 4 5 6 7
| <?php $window = new GtkWindow(); $window->set_size_request(400, 100);
$window->connect_simple('destroy', array('Gtk','main_quit')); $label = new GtkLabel("hello world!"); $window->add($label);
|
- Note that this is only 70% of the sample code. You have to be a registered member to see the entire sample code. Please login or register.
- Registration is free and immediate.
- Have some doubt about the registration? Please read this forum article.
Explanation
$window->set_size_request(400,100) sets the window size to width=400, height=100.
If you set only the width, e.g. $window->set_size_request(400,-1) you will get:

Note that GTK will adjust the height for you automically to fit the height of the label.
If you set only the height, e.g. $window->set_size_request(-1,100) you will get:

Notes
set_size_request works on most other widgets, including hbox, vbox, buttons, labels, etc.
For example, you can use $label->set_size_request(48,36) to set the size of a label.
User reviews Average user ratings: 4.5 (from 11 users) Note: You have to be a registered member to leave a comment. Free registration here. |
March 06, 2008 7:44am
March 10, 2008 8:46am
April 02, 2008 12:16am
August 05, 2008 9:28pm
August 06, 2008 2:35pm
September 06, 2008 11:20pm
March 06, 2009 2:50pm
March 16, 2009 2:35am
May 08, 2009 11:55pm
April 24, 2010 3:34am
hai i it usefull
July 16, 2010 6:56pm