[pygtk] Formatting a spinbutton's display
Walter Leibbrandt
walter at translate.org.za
Mon Jul 28 22:17:40 WST 2008
IIRC, you can set custom text with the set_text() method (or by
modifying the "text" property), seeing as a SpinButton is a sub-class of
gtk.Entry. So connect to the spin button's "changed" and/or
"change-value" event(s), read and format the new text and call
set_text() with your formatted string.
This might also mean that you need to do set_numeric(False) as to allow
non-numeric strings.
Jeremy S wrote:
> I would like to use a spinbutton but instead of just displaying a
> float or integer, I want the display to be formatted. In my case I
> want it to be formatted as currency ($ in front and commas separating
> thousands, millions, etc.), but I can't even find any information on
> how to tackle this problem generally.
>
> I know for treeviews this type of thing can be accomplished with
> set_cell_data_func. Is there anything similar for spinbuttons?
> _______________________________________________
> pygtk mailing list pygtk at daa.com.au
> http://www.daa.com.au/mailman/listinfo/pygtk
> Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
>
--
Walter Leibbrandt http://translate.org.za/blogs/walter
Software Developer +27 12 460 1095 (w)
Translate.org.za
Recent blogs:
* Gtk+ Tip of the Day: Modifying the subject of an event being processed
http://www.translate.org.za/blogs/walter/en/content/gtk-tip-day-modifying-subject-event-being-processed
* Spelt 0.1rc2 released
* CorpusCatcher 0.1 released
More information about the pygtk
mailing list