Re: How to get and set the width/height of a label?

I tried:in Python,it is gtk.Label.size_request().However, it only return the size the widget request to draw itself.If you resize the window,which in turn resizes the label,the value gtk.Label.size_request() returns doesn't change.

I find gtk.Widget.get_allocation() would work,even when the label is resized.It returns a gtk.gdk.Rectangle(x, y, width, height),like (0, 0, 74, 17).

And,how to set the size of gtk.Label?Is gtk.Widget.size_allocate() the answer?

On Fri, Aug 7, 2009 at 10:43 AM, Jorge Opaso Pazos <jorge opaso gmail com> wrote:
This works (C):

int main(int a_argc,char **a_argv)
GtkWidget *l_label;
GtkRequisition l_req;


l_label = gtk_label_new("hello");
gtk_widget_size_request(l_label,&l_req); // not gtk_widget_get_size_request

printf("%d %d\n",l_req.width,l_req.height);

return 0;

Output: 31 17

Maybe in python is: gtk.Label.size_request() 


Jorge Opaso Pazos

El 06-08-2009, a las 21:33, cbx escribió:

I would like to know how to get and set the size of a label.
There seems no answer in the pygtk API(me using Python currently). gtk.Label.get_size_request() only return (-1,-1).
Google doesn't give much information too. _______________________________________________
gtk-list mailing list
gtk-list gnome org

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]