Well, it's gtk+/C's fault, not pygtk's.  It seems that gtk+ doesn't
like when you connect to focus-out-event and run a nested main loop
inside the handler (dialog.run).  The GtkEntry widget expects to receive
the event soon.

  Maybe you should bring this up in the gtk list, or file bug report in
bugzilla.

  In the mean time, as a workaround, you could dialog.show() and make it
modal, but return False from the handler as soon as possible.  Also,
notice that 2 identical dialogs are created when you press F1.  You have
to prevent that somehow.

  Regards.

A Sex, 2003-10-31 �s 11:43, Fernando San Martin W. escreveu:
> On Fri, 31 Oct 2003 07:37:52 -0400, Fernando San Martin W. wrote
> > i try this:
> > 
> > import gobject
> > import gtk
> > 
> > from gtk import TRUE, FALSE
> > 
> > def mainwin():
> >     
> >     
> >     def advice():
> >             m = unicode("Atenci�n", 'latin-1')
> >             
> >             dialog  = gtk.MessageDialog(w, gtk.DIALOG_MODAL |
> > gtk.DIALOG_DESTROY_WITH_PARENT,gtk.MESSAGE_INFO, gtk.BUTTONS_OK,
> > m.encode('utf-8'))
> >     
> >             dialog.run()
> >             dialog.destroy()
> > 
> >     def on_entry_key_press_cb(entry, event):
> >             if event.keyval == gtk.keysyms.F1:
> >                     advice()
> > 
> >     def on_entry_focus_out_cb(entry, event):
> >             advice()
> >     
> >             return FALSE
> >     
> >     w = gtk.Window()
> >     w.connect('destroy', lambda w: gtk.main_quit())
> >     w.set_title('Core Test')
> >     
> >     v = gtk.VBox()
> >     
> >     w.add(v)
> >     
> >     e = gtk.Entry()
> >     
> >     e.add_events(gtk.gdk.KEY_PRESS_MASK)
> >     e.connect('key-press-event', on_entry_key_press_cb)
> >     e.connect('focus-out-event', on_entry_focus_out_cb)
> >     
> >     v.pack_start(e)
> >     
> >     b = gtk.Button("Quit")
> >     
> >     v.pack_start(b)
> >     
> >     
> >     w.show_all()
> > 
> > mainwin()
> > gtk.mainloop()
> > 
> > when the entry widget lost_focus, the messagebox it's showed, but 
> > after little delay all crash...
>  
> The problem is in the focus out event, i get this out from stdout:
> 
> python -u test.py
> sys:1: DeprecationWarning: Non-ASCII character '\xf3' in file test.py on line
> 11, but no encoding declared; see http://www.python.org/peps/pep-0263.html for
> details
> 
> (test.py:2786): Gtk-WARNING **: GtkEntry - did not receive focus-out-event. If you
> connect a handler to this signal, it must return
> FALSE so the entry gets the event as well
> 
> Gtk-ERROR **: file ../../gtk/gtkentry.c: line 4338 (blink_cb): assertion
> failed: (GTK_WIDGET_HAS_FOCUS (entry))
> aborting...
> Exit code: 0 Signal: 6
> 
> so i don't know what should be that.
> 
> thanks
> 
> Fernando San Mart�n Woerner                counter.li.org
> Jefe Departamento Inform�tica              #216550
> Galilea S.A.                               Talca
> 2 Norte 965 - Fono/Fax: 56-71-224876       Chile
>                                 
> "Soy due�o de las palabras que guardo, y prisionero de las que digo."
> 
> _______________________________________________
> pygtk mailing list   [EMAIL PROTECTED]
> http://www.daa.com.au/mailman/listinfo/pygtk
> Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
-- 
Gustavo Jo�o Alves Marques Carneiro
<[EMAIL PROTECTED]> <[EMAIL PROTECTED]>


_______________________________________________
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