[pygtk] set_use_markup and gtk.SpinButton

saeed saeed.gnu at gmail.com
Mon Aug 10 15:46:03 WST 2009


there is no maximum of 3 digits!! You can specify number of characters
(width of entry) and number of digits using methods:

SpinButton.set_range(min_value, max_value)
Entry.set_width_chars(char_num)
SpinButton.set_digits(dig_num)

See the PyGTK reference:
http://www.pygtk.org/docs/pygtk/class-gtkspinbutton.html
http://www.pygtk.org/docs/pygtk/class-gtkentry.html

On 8/10/09, saeed <saeed.gnu at gmail.com> wrote:
> 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/
>>
>


More information about the pygtk mailing list