[pygtk] dialog response

Stephen George steve_geo at optusnet.com.au
Tue Aug 17 06:44:57 WST 2010


  Hi,


On 17/08/2010 12:59 AM, Pietro Battiston wrote:
>> On 09/08/10 10:17, Imre Horvath wrote:
>>> Hi!
>>>
>>> I've got a dialog, with Ok and Cancel buttons in the actionarea (I'm
>>> using gtkbuilder)
>>> I want to validate the dialog data. I write an action handler for the Ok
>>> button that validates it, but i need the dialog remain open when
>>> validation fails. How can i do this?
>>>
>>> Thanks in advance:
>>> Imre Horvath
> I think there are two clean approaches (I used both, in different
> cases):
> 1) the dialog is ran in a loop, which always run()s it again when the
> data validity check is no passed (possibly after showing an error
> message)
> 2) the buttons are initially unsensitive and a function, which runs
> several times per second and checks the validity, takes care of setting
> them (un)sensitive
>
> Pietro


#2 is a neat idea, to extend on this idea you can have a look at 
ValidatedEntry at http://www.astro.umass.edu/~dpopowich/python/

This widget provides visual indications when data is not valid for a 
field, and package includes a little demo app that shows the OK button 
disabled until you get all the input fields correct and valid (might 
have to fish in demo code to understand the format each field is 
expecting for demo).

Cheers Steve



More information about the pygtk mailing list