|
Sample Code 294: How to set up toolbar with custom text and graphics - Part 3 - exact positioning of labels? |
| Written by kksou | ||||||||||||||
| Thursday, 26 July 2007 | ||||||||||||||
|
Problem Just want to show you the kind of fine controls php-gtk2 give us in the exact positioning of widgets. Take a closer look at the output of Part 1 as shown below. Did you notice that the positioning of the custom labels varies? This is because the size of the custom graphics are not the same,
Suppose we want to make sure that all the custom graphics are centered, and the custom labels aligned to the bottom as shown below:
Solution We make use of GtkAlignment to align the custom graphics and labels. Sample Code The following image files are required by the sample code below. Please save a copy of the image files and put them in the same directory where you store the sample code.
Explanation We make use of the entire code from How to set up toolbar with custom text and graphics - Part 1 - labels below graphics? All you need is to add just one line:
Note
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). Basically, size and positioning is just like playing with Lego building blocks. By combining various hboxes and vboxes, with appropriate use of the Related Links
User reviews There are no user reviews yet. Note: You have to be a registered member to leave a comment. Free registration here. |
||||||||||||||
| < Prev | Next > |
|---|










