Hello,
I am writing an applet that displays a list of items and then
refreshes them every so often. To do this I am using an EventBox that
when clicked does a menu.popup(). This works fine until the refresh
method is called. I try to destroy the menu and then build another
one. After this happens when the EventBox is clicked on I get the
following stacktrace.
/usr/local/bin/applet.py:40: GtkWarning: gtk_window_set_accept_focus:
assertion `GTK_IS_WINDOW (window)' failed
theMenu.popup(None, None, None, ev.button, gtk.get_current_event_time())
/usr/local/bin/applet.py:40: GtkWarning: gtk_window_move: assertion
`GTK_IS_WINDOW (window)' failed
theMenu.popup(None, None, None, ev.button, gtk.get_current_event_time())
/usr/local/bin/applet.py:40: GtkWarning: gtk_widget_size_request:
assertion `GTK_IS_WIDGET (widget)' failed
theMenu.popup(None, None, None, ev.button, gtk.get_current_event_time())
/usr/local/bin/applet.py:40: GtkWarning: gtk_widget_size_allocate:
assertion `GTK_IS_WIDGET (widget)' failed
theMenu.popup(None, None, None, ev.button, gtk.get_current_event_time())
/usr/local/bin/applet.py:40: GtkWarning: gtk_widget_realize: assertion
`GTK_WIDGET_ANCHORED (widget) || GTK_IS_INVISIBLE (widget)' failed
theMenu.popup(None, None, None, ev.button, gtk.get_current_event_time())
I have attached an example script of that shows exactly how I am doing
this. The script uses the GNOME_PythonAppletSample.server file that
comes with the python gnome applet package.
I was hoping someone could tell my what I am doing wrong, and what the
proper way to achieve this is.
Thanks
--
Jay Graves
[EMAIL PROTECTED]
jay.skabber.com
#!/usr/bin/env python
import pygtk
pygtk.require('2.0')
import gtk
import gnomeapplet
import gobject
menu = gtk.Menu()
def refresh(theMenu):
print 'refreshing the menu'
print theMenu
theMenu.destroy()
theMenu = gtk.Menu()
# build the menu
item3 = gtk.MenuItem()
item4 = gtk.MenuItem()
vBox3 = gtk.VBox()
vBox4 = gtk.VBox()
label3 = gtk.Label("Label 3")
label4 = gtk.Label("Label 4")
vBox3.add(label3)
vBox4.add(label4)
item3.add(vBox3)
item4.add(vBox4)
theMenu.add(item3)
theMenu.add(item4)
theMenu.show_all()
def clicked(self, ev, theMenu):
print ev.button
print menu
print theMenu
if ev.button == 1:
theMenu.popup(None, None, None, ev.button, gtk.get_current_event_time())
def sample_factory(applet, iid):
print "Creating new applet instance"
eb = gtk.EventBox()
label = gtk.Label("Click Me!")
eb.connect("button-press-event", clicked, menu)
eb.add(label)
# build the menu
item1 = gtk.MenuItem()
item2 = gtk.MenuItem()
vBox1 = gtk.VBox()
vBox2 = gtk.VBox()
label1 = gtk.Label("Label 1")
label2 = gtk.Label("Label 2")
vBox1.add(label1)
vBox2.add(label2)
item1.add(vBox1)
item2.add(vBox2)
menu.add(item1)
menu.add(item2)
menu.show_all()
applet.add(eb)
applet.show_all()
gobject.timeout_add(10000, refresh, menu)
return True
print "Starting factory"
gnomeapplet.bonobo_factory("OAFIID:GNOME_PythonAppletSample_Factory",
gnomeapplet.Applet.__gtype__,
"hello", "0", sample_factory)
print "Factory ended"
_______________________________________________
pygtk mailing list [email protected]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/