On Fri, Oct 31, 2003 at 11:58:12AM +0000, Gustavo J. A. M. Carneiro wrote:
>    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.

I've run into this before. mainloop() isn't something to be called from
callbacks lightly, I've discovered -- button_press_event is another one
that causes problems when using this pattern. 

It may very well be that X events are the only ones that are fidgety;
has anybody seen an example of a real signal that is problematic?

>   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.

Another workaround is using idle_add() to display the dialog; in this
case, it's probably close to what Fernando wants to do anyway.

Fernando, how did it go?

> 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

Take care,
--
Christian Robottom Reis | http://async.com.br/~kiko/ | [+55 16] 261 2331
_______________________________________________
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