Hi all,

in a GnomeApp I created menus including a UIINFO_TOGGLEITEM. However, the
connected callback cannot determine the value of the toggle item, since it
receives a GtkObject of type GtkCheckMenuItem instead of the GtkCheckMenuItem
itself. Therefore the method call __getattr__("active") does not work. Is it
possible to access the GtkCheckMenuItem inside the GtkObject ? For GtkMenus
everything works just fine.

Cheers
Juergen


from gtk import *
from gnome.ui import *

def toggled(checkMenuItem):
    print checkMenuItem
    print checkMenuItem.__getattr__("active")

win = GnomeApp()
win.connect("destroy", mainquit)

# Gnome Menu
toggle_menu = [UIINFO_TOGGLEITEM("Toggle", cb=toggled)]
main_menu = [UIINFO_SUBTREE('GnomeMenu', toggle_menu)]
win.create_menus(main_menu)

# GtkMenu
vbox = GtkVBox()
gtkMenuBar = GtkMenuBar()
gtkMenuItem = GtkMenuItem("GtkMenu")
gtkSubMenu = GtkMenu()
gtkCheck = GtkCheckMenuItem("Toggle")
gtkCheck.connect("toggled", toggled)
gtkSubMenu.append(gtkCheck)
gtkMenuItem.set_submenu(gtkSubMenu)
gtkMenuBar.append(gtkMenuItem)
vbox.pack_start(gtkMenuBar, expand=TRUE)

win.set_contents(vbox)
win.set_usize(100,100)
win.show_all()
mainloop()

-- 
_____________________________________________________________________________

     ____/  __  /  ____/  /     Jürgen Ehrensberger
    /      /   /  /      /      Laboratoire de Télécommunications
   ____/  ____/  ____/  /       Ecole Polytechnique Fédérale de Lausanne
  /      /      /      /        1015 Lausanne, Switzerland
_____/ _/     _/     _____/     Tel:  +41 21 693 46 94, Fax: +41 21 693 26 83
                                Mail: [EMAIL PROTECTED]
_____________________________________________________________________________
To unsubscribe: echo "unsubscribe" | mail [EMAIL PROTECTED]

Reply via email to