PHP-GTK2 Newsletter

PHP-GTK2 Tips & Techniques
FREE Newsletter
by kksou



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:

How to change the size of GtkWindow?


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:

  • How to 0002?

    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:

  • How to 0002?


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)
  1. Nathan Matteson
    March 06, 2008 7:44am

  2. Adam Blake
    March 10, 2008 8:46am

  3. Sebastian Gebhard
    April 02, 2008 12:16am

  4. kvravikiran
    August 05, 2008 9:28pm

  5. niQ from The Netherlands
    August 06, 2008 2:35pm

  6. Bonface
    September 06, 2008 11:20pm

  7. martti pitkanen
    March 06, 2009 2:50pm

  8. FrankBahon
    March 16, 2009 2:35am

  9. Keith Fernie
    May 08, 2009 11:55pm

  10. arunraja
    April 24, 2010 3:34am
    hai

    hai i it usefull

  11. Grover
    July 16, 2010 6:56pm

Note: You have to be a registered member to leave a comment. Free registration here.

 
< Prev   Next >

Blog - Forum - Privacy Policy - Contact Us
Copyright © 2006-2009. kksou.com. All Rights Reserved