[pygtk] set_use_markup and gtk.SpinButton

Nathan Samson nathansamson at gmail.com
Tue Aug 11 07:27:56 WST 2009


Since it seems you need to pass a pango.FontDescription you could try:

spin.get_layout().set_font_description(pango.FontDescription('normal 10'))

Although I never used get_layout and/or set_font_description and/or pango
(directly)

On Tue, Aug 11, 2009 at 00:59, Art Hunkins <abhunkin at uncg.edu> wrote:

> I am trying to use a variant of your first suggestion:
> spin.get_layout().set_font_description('normal 10')
>
> ('normal 10' is even one of the examples in the reference manual). All I
> want to do is to set the size larger.
>
> However, I get this error message:
> TypeError: desc should be a PangoFontDescription or None.
>
> "None" works, but I haven't been able to get anything else to do so,
> including ('Sans 10 Bold').
>
> Any ideas?
>
> Art Hunkins
>
> ----- Original Message -----
> From: "saeed" <saeed.gnu at gmail.com>
> To: "Art Hunkins" <abhunkin at uncg.edu>
> Cc: <pygtk at daa.com.au>
> Sent: Monday, August 10, 2009 3:39 AM
> Subject: Re: [pygtk] set_use_markup and gtk.SpinButton
>
>
> > First way is to specify a larger or bold font, ex:
> >
> > spin.get_layout().set_font_description('Sans 10 Bold')
> >
> > ______________
> > Second way is to use pango layout markup and make the text bold, ex:
> >
> > spin.connect('expose-event',lambda widget,event:
> > widget.get_layout().set_markup('<b>%s</b>'%widget.get_text()))
> >
> >
> > Description:
> > SpinButton is an Entry
> > and an Entry has a method get_layout() that returns the pango.Layout
> > used to display the entry
> > and a pango.Layout has a method set_markup() that that accept at least
> > Bold (<b>) and Underlien (<i>)
> >
> >
> > On 8/10/09, Art Hunkins <abhunkin at uncg.edu> wrote:
> >> I've a somewhat related problem with gtk.SpinButton: I need to make the
> >> numeric display (i.e., the digits) larger in size. The basic code I'm
> >> using
> >> is this:
> >>
> >>        adj = gtk.Adjustment(init,start,end,step,page,0)
> >>        spin = gtk.SpinButton(adj,accel)
> >>        if label == "": name = title
> >>        else: name = label
> >>        label = gtk.Label(name)
> >>        box.pack_start(spin, False, False, 5)
> >>        box.pack_start(label, False, False, 2)
> >>        self.spins.append([spin,title,init])
> >>        adj.connect("value_changed", self.spincallback, spin)
> >>        spin.show()
> >>        label.show()
> >>        self.set_channel(title, init)
> >>
> >> I assume that I must convert "spin" to a string, looking something like:
> >> ("<big><big> + spin + </big></big>")
> >> followed by: spin.set_use_markup(True)
> >>
> >> Perhaps gtk.Entry is involved as well? (In which case, I'd like
> >> characters
> >> restricted to numeric, and a maximum of 3 digits.)
> >>
> >> I'd very much appreciate any suggestions.
> >>
> >> Art Hunkins
> >>
> >> _______________________________________________
> >> pygtk mailing list   pygtk at daa.com.au
> >> http://www.daa.com.au/mailman/listinfo/pygtk
> >> Read the PyGTK FAQ: http://faq.pygtk.org/
> >>
>
> _______________________________________________
> pygtk mailing list   pygtk at daa.com.au
> http://www.daa.com.au/mailman/listinfo/pygtk
> Read the PyGTK FAQ: http://faq.pygtk.org/
>



-- 
http://www.nathansamson.be

To understand recursion, you must first understand recursion.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.daa.com.au/pipermail/pygtk/attachments/20090811/87396e11/attachment.htm 


More information about the pygtk mailing list