[pygtk] Re: gtk.ComboBox: how to handle the popup window?

Sandro Dentella sandro at e-den.it
Mon Mar 27 01:54:13 WST 2006


> You can connect to a property to be notified of any property changes,
> use g_signal_connect "notify::popup-shown"

I didn't know g_signal_connect, and starting from this mail I discovered
notify::text, i found it interesting so I wanted to understand what would be
more usefull to setup a validation (connect to key_press_event being another
possibility) 

The example/exercise below  poses quite a some questions:

1. to avoid infinite loop I used a flag, but it doesn't seem to be seen. It
   is as if the signal processing is deferred so that doesn't see the
   correct value of the variable 'sem'

2. I could have used some blocking of signal handling, but I got lost
   between  widget.signal_handler_block(insert_sig) (suggested in
   http://www.async.com.br/faq/pygtk/index.py?req=show&file=faq14.005.htp)
   and handler_block they require a handler_id that I dont know where to
   find out...

Thanks for your attention
sandro
*:-)



class gtk_staff(object):
    def __init__(self):
        w = gtk.Window()
        e = gtk.Entry()
        w.add(e)
        w.show_all()
        self.sem = "OUT"
        e.connect('notify::text', self.show_text)

    def show_text(self, wdg, ev):
        txt = wdg.get_text()
        print "txt: ", txt, "self.sem", self.sem
        
        if self.sem == 'OUT' and len(txt) < 5:  # avoid inifinit loop...
            self.sem = 'IN'
            #wdg.handler_block(???)
            wdg.set_text(txt + '*')
            #wdg.handler_unblock(???)
            self.sem = 'OUT'
            
        print "sem: ", self.sem
        return

gtk_staff()

-- 
Sandro Dentella  *:-)
e-mail: sandro a e-den.it 
http://www.tksql.org                    TkSQL Home page - My GPL work


More information about the pygtk mailing list