Sample Code 2: How to change the size of GtkWindow?
Written by kksou
Tuesday, 12 September 2006
You want to change the size of GtkWindow as shown below:
SolutionUse GtkWidget::set_size_request (int width, int height)
| 1 |
$window = new GtkWindow();
$label = new GtkLabel("hello world!");
- 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.
$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:
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.