Sample Code 5: How to right justify the text in GtkLabel?
Written by kksou
Tuesday, 12 September 2006
You want to right justify the text in GtkLabel as shown below:
| 1 |
$window = new GtkWindow();
$label = new GtkLabel("hello world!\nthis is line2\nand this is line3");
- 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.
- A label can contain multiple lines by using
\n as line breaks. Note that you have to enclose
\n in double quotes, not single quotes.
- To right justify, use
- To left justify, use
- To center text, use
- To left-right justify text, use
$label->set_justify() only justifies the text within the label. The entire label is still centered relative to the window.
If you wish to produce something similar to the output below, i.e. the whole text right align to the right of GtkWindow:
Please refer to this article.