On Fri, 2005-02-25 at 13:09 +0100, Rafael Villar Burke wrote:
>Gustavo J. A. M. Carneiro wrote:
>
>>On Fri, 2005-02-25 at 10:57 +0000, John Gill wrote:
>>  
>>
>>>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).
>>  
>>
>I also had that problem with a "Table for dummies" widget and took the 
>following solution:
>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

  Interesting idea, but, I'm not sure if there is any widget state whose
colours can be interpreted by the user as meaning the value of the entry
is [not] correct.

>
>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

  Yes, I based my code on his idea! :-)

>
>It would be great having a "repository" for this pygtk friendly widgets 
>if they are general enough...

  I was hoping kiwi2 could be such repository... ;-)

  Also missing, and related to this, is gtk forms.  A gtk.Dialog
subclass that emits a signal to ask for validation, and another signal
to indicate 'apply these values'.  The 'validate' signal handler could
check all widgets in the dialog to see if they have valid values and
return a boolean.  The 'apply' signal would let the user add handler
that fetches values from the form widgets and applies them to the
application.  The dialog could also track the modified state of the
widgets to make the apply button sensitive only when there are changes.
Also, a simple method would be nice to tell the dialog whether to have
apply/cancel/ok buttons (explicit apply), or only close (instant apply),
without bothering the programmer with more details.
  </dreaming>

  Regards.

-- 
Gustavo J. A. M. Carneiro
<[EMAIL PROTECTED]> <[EMAIL PROTECTED]>
The universe is always one step beyond logic.

Attachment: smime.p7s
Description: S/MIME cryptographic signature

_______________________________________________
pygtk mailing list   [email protected]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/

Reply via email to