[Sugar-devel] Fw: set_use_markup and gtk.Button
Art Hunkins
abhunkin at uncg.edu
Fri Aug 7 18:03:52 EDT 2009
Tomeu,
Thanks for your suggestion:
[May this help?
http://lists-archives.org/gtk/08302-gtk_widget_anchored-assertion-failure.html
The toplevel widget in your case is the Activity class.]
I'm not aware of what this reference really means except that I must be
doing something wrong!
I've taken your advice and have addressed this mail (here forwarded to the
sugar-devel list) to the pyGTK list. Hopefully, someone will come up with a
solution to "small text on buttons". I'm still trying to get larger text
overall on SoaS!
Art Hunkins
----- Original Message -----
From: "Art Hunkins" <abhunkin at uncg.edu>
To: <pygtk at daa.com.au>
Sent: Friday, August 07, 2009 5:52 PM
Subject: set_use_markup and gtk.Button
>I have been happily using the set_use_markup property of gtk.Label and
>gtk.Frame with XML markup, to create bolded, italic and various sized text.
>
> I need to do this with gtk.Button as well - to do the same with (callback)
> button labels. However, I've not been able. I've employed the two general
> approaches below (with results immediately below them):
>
> #1:
>
> def cbbutton(self,box,callback,title=""):
> """Creates a callbackbutton
> box: parent box
> callback: click callback
> title: if given, the button name
> returns the widget instance"""
> self.cbbutts = self.cbbutts + 1
> label = gtk.Label(title)
> label.set_use_markup(True)
> butt = gtk.Button(" %s " % label)
> box.pack_start(butt, False, False, 5)
> self.cbbuttons.append([butt,label,0])
> butt.connect("clicked", callback)
> butt.show()
> return butt
>
> The above version runs fine, but gives unwanted button labels, of this
> variety:
> <gtk.Label object a 0x[....] (GtkLabel at 0x[....different])>
>
>
> #2:
>
> def cbbutton(self,box,callback,title=""):
> """Creates a callbackbutton
> box: parent box
> callback: click callback
> title: if given, the button name
> returns the widget instance"""
> self.cbbutts = self.cbbutts + 1
> label = gtk.Label()
> label.set_markup(title)
> butt = gtk.Button()
> butt.child = label
> label.show()
> box.pack_start(butt, False, False, 5)
> self.cbbuttons.append([butt,label,0])
> butt.connect("clicked", callback)
> butt.show()
> return butt
>
> The above version crashes, with the following error log:
>
> /usr/lib/python2.6/site-packages/sugar/activity/main.py:35: GtkWarning:
> gtk_widget_realize: assertion `GTK_WIDGET_ANCHORED (widget) ||
> GTK_IS_INVISIBLE (widget)' failed
> activity.show()
> Gtk:ERROR:gtkwidget.c:7967:gtk_widget_real_map: assertion failed:
> (GTK_WIDGET_REALIZED (widget))
>
> Can someone please suggest what changes might give me a proper label?
>
> FWIW, including XML tags in "title" makes no difference whatever in the
> above results.
>
> Art Hunkins
More information about the Sugar-devel
mailing list