Gustavo J. A. M. Carneiro wrote:
On Fri, 2005-02-25 at 10:57 +0000, John Gill wrote:I also had that problem with a "Table for dummies" widget and took the following solution:
See attached code for a way to provide visual feedback as the entry is
edited.
I was recently faced with the same problem. I thought about this very same solution, but in the end I gave it up because hardcoding background colour is bad when interacting with themes. For instance, you change the background between white and red. This particular pair of colours make look bad in some themes. Moreover, dark themes will likely have a white or light text colour, and in this case white text in white background will disappear.
My solution, although also not perfect, was to place a small
gtk.STOCK_DIALOG_WARNING icon inside the entry, and toggle between
making it insensitive (=value OK) or sensitive (=bad value).
Requesting the gtk.Style object and use one of the colors of a state other than normal, depending on what you are doing. In my case this was the base color in a cell. For the entry validation case, it could be even better to animate the effect, perhaps by rotating through a pair of these colors... but I haven't implemented this:).
This is what I did for a treeview...
def get_color_string(color): assert isinstance(color, gtk.gdk.Color) return "#%04X%04X%04X" % (color.red, color.green, color.blue)
temp_tv = gtk.TreeView()
normal_color = get_color_string(temp_tv.get_style().base[gtk.STATE_NORMAL])
strong_color = get_color_string(temp_tv.get_style().base[gtk.STATE_SELECTED])
del temp_tv
Fernando Sanmart�n Woerner also wrote some sort of a validating gtk.Entry IIRC for its use in pygestor called PixEntryCompletion. Your can get the code for pygestor here: http://www.galilea.cl/gestor/descargas.html and see PixEntryCompletion in action (swf screen capture) here: http://www.galilea.cl/~snmartin/swf/pec/pec.html
It would be great having a "repository" for this pygtk friendly widgets if they are general enough...
Pachi _______________________________________________ pygtk mailing list [email protected] http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
