[pygtk] updating with combo-entry

David M. Cook dave@davidcook.org
Wed, 30 Oct 2002 16:40:11 -0800

On Wed, Oct 30, 2002 at 11:45:23AM +0100, mekkaoui omar wrote:

> Hi,
> I use glade to develop my application.
> I would like to update information on a window after 
> selecting an entry in the combo.  But, I don't know which 
> signal I will use to associate it to an "updating function".

The simplest way is to add a button to do this, of course, but to save mouse
clicks the following seems to work for me:

class Foo:

      def __init__(self, ...):
	  self.button_press = 0
	  self.combo.list.connect("button_pressed_event", self.button_press)
	  self.combo.list.connect("button_release_event", self.button_release)
	  # or you can make the connection with glade and use signal_connect()
      def button_press(self, *args):
      	  self.button_press = 1
      def button_release(self, *args):
      	  if self.button_press:
	     self.button_press = 0
In other words, if a mouse button is released after one has been pressed,
call the addText() method.  This shouldn't do anything until the user has
made a selection from the list and released the mouse button, at least
that's what it seems to do for me.  Actually, if they just click and release
the popdown button, the first item in the popdown will be added.  The user
can always cancel this action by moving the mouse cursor away from the list
(e.g. to the "grey" area of the app) before releasing the mouse.  

I have not tested this thoroughly for unintended consequences.  It also
doesn't handle the case where the user uses the keyboard to open and
navigate the popdown.
Dave Cook