PHP-GTK2 Newsletter
|
Sample Code 276: How to make a 200x200 frame always centered no matter how you resize the app window? |
| Written by kksou | ||||||
| Tuesday, 26 June 2007 | ||||||
|
Problem This is in reponse to Adz07's post titled "Aligning a fixed size panel". He wants to be able to have a frame 200x200 that always stay centered in the application no matter how the user resizes the window as shown below:
Solution When I first started on PHP-GTK, I find size and positioning one of the most confusing areas in PHP-GTK. I believe it's the same for many of the people new to PHP-GTK2. To develop any serious application, the first step is always to layout the widgets. It's something so fundamental, such as making the buttons to be of size 80x32, or making the Help button always stay at the top right-hand corner no matter how the user resize the application. But, unless you have learned it before, you will find it a challenge trying to accomplish these supposedly simple tasks. That's why I devoted one-third of my ebook PHP-GTK2 Demystified just on size and positioning. I called them the three fundamental building blocks of PHP-GTK2, the other two being signal handling and object-oriented framework. Of course it's not possible for me to explain everything about size and positioning in this article. But with the sample code below, together with some of the explanations in the official PHP-GTK2 documentation, it will be a good start. Basically, size and positioning is just like playing with Lego building blocks. By combining various hboxes and vboxes, with appropriate use of the Sample Code
Explanation
Note
Of course you can use the Glade tool to help you with size and positioning of widgets. However, if you are really serious about php-gtk2, you should try to understand the fundamentals. Once you know the "why's", you will be able to use the Glade tool more effectively. Related Links
User reviews Average user ratings: 0.0 (from 2 users) Note: You have to be a registered member to leave a comment. Free registration here. |
||||||
| < Prev | Next > |
|---|







0.0 (from 2 users)
June 26, 2007 4:42am
Cheers for this! This sort of info is hard to come by! You are a life saver.
Adz07
June 26, 2007 10:16am
Dear kksou,
Thank you so much for sharing your strong skills and knowledge with us mere mortals :)
I just bought your e-book and frankly it is a must for everyone serious with Php-Gtk2 programming. Thumbs up !