[pygtk] Implementing command history with a gtk.Entry

N. French nbm_clan at yahoo.com
Thu Jul 27 02:56:40 WST 2006


Of course the hour of head scratching before sending that email was
less fruitful than the next 30 seconds... I was missing this:

if gobject.pygtk_version < (2, 8):
    gobject.type_register(MyTextView)

Now it works great.  Thanks for all the help everyone!

--- "N. French" <nbm_clan at yahoo.com> wrote:

> I tried following the faq but when I try to connect to the
> 'mykeypress'
> signal I get this:
> 
>   File "/root/dev/test/hardware/python/nw_gtk.py", line 50, in
> __init__
>     self.entry.connect('mykeypress', self.up_arrow)
> TypeError: unknown signal name
> 
> Here's my class code.  I think this is nearly identical to the faq
> entry I was following
>
(http://www.async.com.br/faq/pygtk/index.py?req=show&file=faq23.034.htp).
>  Anyone see where I'm going wrong?
> 
> class EntryWithKeyPresses(gtk.Entry):
>     __gsignals__ = dict(
>         mykeypress = (
>         gobject.SIGNAL_RUN_LAST | gobject.SIGNAL_ACTION,
> 	    None, # return value
> 	    (str,) # arguments
>         )
>     )
> 
> gtk.binding_entry_add_signal(EntryWithKeyPresses, gtk.keysyms.Up, 0,
> 'mykeypress', str, 'Up')
> gtk.binding_entry_add_signal(EntryWithKeyPresses, gtk.keysyms.Down,
> 0,
> 'mykeypress', str, 'Down')
> 
> 
> [...]
> 
> 
> 
> --- "David M. Cook" <dave at davidcook.org> wrote:
> 
> > On Mon, Jul 24, 2006 at 10:47:44AM -0700, N. French wrote:
> > 
> > > My problem is:  how do I catch the up/down arrow keypresses?  I
> was
> > 
> > I know of two ways to catch the up/down arrows:
> > 
> > - connect to the key-press event
> > - Create your own Entry subclass with up/down arrow keybindings
> > 
> > See the FAQ for the latter, which is the more elegant solution if
> you
> > are
> > not using glade.  Unfortunately, I don't think gtk lets you add
> > keybindings
> > to an existing instance (i.e. from a glade widget tree), which
> seems
> > like a
> > bug to me.
> > 
> > Dave Cook
> > _______________________________________________
> > pygtk mailing list   pygtk at daa.com.au
> > http://www.daa.com.au/mailman/listinfo/pygtk
> > Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
> > 
> 
> 
> __________________________________________________
> Do You Yahoo!?
> Tired of spam?  Yahoo! Mail has the best spam protection around 
> http://mail.yahoo.com 
> _______________________________________________
> pygtk mailing list   pygtk at daa.com.au
> http://www.daa.com.au/mailman/listinfo/pygtk
> Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
> 


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 


More information about the pygtk mailing list