On Fri, Sep 27, 2002 at 07:13:36PM -0400, Rajarshi Guha wrote:
> So in my callback class I have the functions defined as so:
> 
> class Callbacks:
>     def on_terminal_activate(w):
>         g.terminal = w.get_chars(0, w.get_position())
>     def on_terminal_changed(w):
>         g.terminal = w.get_chars(0, w.get_position())
> 
> However the first function gets called when I press the enter key on the combo 
> list and the second function gets called when I choose an entry from the drop 
> down list. However, when the second function is called, w.get_position() 
> returns 0, so I end up with no text.

Don't hook to the combo itself. Use combo.entry, which gets you the
entry member of the GtkComboB. If you use entry.get_text() you'll
probably have no problems of this sort.  If you do, try using
gtk.idle_add() on a function that gets the character buffer.

> I had thought of calling the 'on_terminal_activate' from the 
> 'on_terminal_changed' function as so:
> 
>    def on_terminal_changed(w):
>            self.on_terminal_activate(w)
>  
> but then I get
> 
> global name 'self' is not defined.

Yes, because you may notice that you are not declaring self as the first
parameter in your callback. But this may be something to do with
signal_autoconnect; I haven't used it in years.

> Am I proceeding in the right direction? If so, how can I call the activate 
> signl - since I use ibglade.GladeXML() to load widgets and 
> signal_autoconnect() to load the callbacks I cant seem to call an individual 
> callback.  Or is there a better way to get the text out of a combo list 
> without having to press enter each time.

Enter should not be required; it's bad usability. You should hook to the
following signals of the Combo's entry:

    - insert_text
    - delete_text

Take care,
--
Christian Reis, Senior Engineer, Async Open Source, Brazil.
http://async.com.br/~kiko/ | [+55 16] 261 2331 | NMFL
_______________________________________________
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