[Sugar-devel] XML markup capability for a gtk.Button label (PyGTK)?

Art Hunkins abhunkin at uncg.edu
Thu Aug 6 13:13:49 EDT 2009


Thanks for the code suggestion, Tomeu.

The entire method (into which your suggestion was inserted, and which 
otherwise is from Victor's csndsugui) was this:

    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

Unfortunately, the above code fails with this Log (I probably confounded 
something in this larger setting):

/usr/lib/python2.6/site-packages/sugar/util.py:25: DeprecationWarning: the 
sha module is deprecated; use the hashlib module instead

import sha

1249577334.063648 WARNING root: No gtk.AccelGroup in the top level window.

1249577334.066473 WARNING root: No gtk.AccelGroup in the top level window.

/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))



I have tried positioning the two .show() lines at different points to no 
avail.

Do you (or anyone else) have further ideas?

Art Hunkins

----- Original Message ----- 
From: "Tomeu Vizoso" <tomeu at sugarlabs.org>
To: "Art Hunkins" <abhunkin at uncg.edu>
Cc: <michael.gogins at gmail.com>; <Victor.Lazzarini at nuim.ie>; 
<sugar-devel at lists.sugarlabs.org>
Sent: Thursday, August 06, 2009 3:59 AM
Subject: Re: [Sugar-devel] XML markup capability for a gtk.Button label 
(PyGTK)?


On Thu, Aug 6, 2009 at 03:43, Art Hunkins<abhunkin at uncg.edu> wrote:
> Hello, Victor and Mike (et al.),
>
> In reference to Victor's csndsugui.py (PyGTK):
>
> With gtk.Label and gtk.Frame, I've been able to use the set_use_markup()
> property to get larger fonts, bold, italics, etc - by including XML markup
> in my text strings.
>
> However, this property does not exist for gtk.Button, and I've got 
> callback
> buttons that need these features too.
>
> Here is the relevent portion of a callback button that works fine (but no
> markup capability) - from csndsugui.py:
>
> def cbbutton(self,box,callback,title=""):
> butt = gtk.Button(" %s " % title)
>
> I tried unsuccessfully to add markup capability to this title by modifying
> the code thus:
>
> def cbbutton(self,box,callback,title=""):
> label = gtk.Label(title)
> label.set_use_markup(True)
> butt = gtk.Button(" %s " % label)
>
> Can this be made to work? (Sorry my PyGTK chops are so rudimentary.)

Can you try with this?

label = gtk.Label()
label.set_markup(title)
butt = gtk.Button()
butt.child = label
label.show()

Thanks,

Tomeu

> Art Hunkins
>
> _______________________________________________
> Sugar-devel mailing list
> Sugar-devel at lists.sugarlabs.org
> http://lists.sugarlabs.org/listinfo/sugar-devel
> 



More information about the Sugar-devel mailing list