Hi! I've got a SpinButton that governs a float setting in my program. If the user should enter something something illegal in there (for example "hi mom!") I want to paint it red to show the user the error of his ways.
This seems simple enough - just connect to the 'changed' signal of the SpinButton and do whatever you need to, but here's the snag: I can't detect faulty input since I have no idea how the SpinButton parses text. Using float(b.get_text()) does not work, because the text is internationallized and may have decimal commas and other weird things that python does not like. Using locale.atof(b.get_text()) does not work either, because in the en_US locale the string "0,11" is interpreted by the SpinButton as 0 and by locale.atof as 11. For integers it's no easier, because "50,1,,1" is interpreted by the SpinButton as 50 and by locale.atof as 5011. Furthermore, I can't connect to 'value-changed' because that's only updated on correct input, and I cant use 'input' because the docs say that can't be handled from pygtk. So what do I do? /Joel Hedlund _______________________________________________ pygtk mailing list [email protected] http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://faq.pygtk.org/
