forum-msg-id-134208-edit

Original date:2019-08-23 16:04:03 Edited by: irv Subject: Re: EuGTK:How To Lookup Stuff

euphoric said...
irv said...

You can justify multi-line text, but not single lines. Look for halign for that. There are several ways to accomplish this.

This is working for me:

set(label_trail,"alignment",0.0) 

Not sure how to do it upon label creation, though:

label_trail = create(GtkLabel,"alignment=0.0") 

You actually have to set xalign separately from the create() function: Don't know why, maybe it can be fixed.

include GtkEngine.e 
 
constant 
    win = create(GtkWindow,"size=300x300,border=10,$destroy=Quit"), 
    pan = create(GtkBox,"orientation=vertical,spacing=10"), 
    lbl = create(GtkLabel,"text=This is a test"), 
    box = create(GtkButtonBox), 
    btn = create(GtkButton,"gtk-quit","Quit") 
    set(lbl,"xalign",0) --* range is 0...1  
     
    add(win,pan) 
    add(pan,lbl) 
    add(box,btn) 
    pack(pan,-box) 
     
show_all(win) 
main() 

EDIT:GtkAlignment is not an {x,y} value, it is a container which can control the layout of whatever is put inside. You probably don't need that, and it is deprecated anyway.

Note that xalign and yalign, if not set, are by default 0.5 and 0.5 (centered) for labels (and most everything else).

Most of this info is in the GTK3 docs. Don't forget that if you look up GtkLabel, and don't see what you are looking for there, follow the Object Hierarchy upward until you find what you need. IOW, label x and y alignment are provided by the ancestor GtkWidget.

Not Categorized, Please Help

Search



Quick Links

User menu

Not signed in.

Misc Menu