Issues with

those warnings about the accessibility bus in Debian Sid i386 occur with
every Python application using the Gtk library. Maybe the Gtk classes do
not work properly together with the AT-SPI2 interface in the
32bit-Versions, but this should be discussed elsewhere.
You can simply work around the script's failure to display the
menu items in Debian Sid amd64 systems just by wrapping around them
another Gio.Menu object and placing this in the Gtk.Application menu
bar. Here is the changed code:

from gi.repository import Gtk
from gi.repository import Gio
import sys

class MyWindow(Gtk.ApplicationWindow):

    def __init__(self, app):
        Gtk.Window.__init__(self, title="GMenu Example",

class MyApplication(Gtk.Application):

    def __init__(self):

    def do_activate(self):
        win = MyWindow(self)

    def do_startup(self):
        # start the application
        # new (2014-08-26): Create fileMenu as wrapper around menu
        fileMenu = Gio.Menu()
        # create a menu
        menu = Gio.Menu()
        # append to the menu three options
        menu.append("New", "")
        menu.append("About", "app.about")
        menu.append("Quit", "app.quit")
        # changed (2014-08-26): menu as submenu of fileMenu
        fileMenu.append_submenu("File", menu)
        # changed (2014-08-26): Place fileMenu in the application menu

        # create an action for the option "new" of the menu
        new_action ="new", None)
        # connect it to the callback function new_cb
        new_action.connect("activate", self.new_cb)
        # add the action to the application

        # option "about"
        about_action ="about", None)
        about_action.connect("activate", self.about_cb)

        # option "quit"
        quit_action ="quit", None)
        quit_action.connect("activate", self.quit_cb)

    # callback function for "new"
    def new_cb(self, action, parameter):
        print ("This does nothing. It is only a demonstration.")

    # callback function for "about"
    def about_cb(self, action, parameter):
        print ("No AboutDialog for you. This is only a demonstration.")

    # callback function for "quit"
    def quit_cb(self, action, parameter):
        print ("You have quit.")

app = MyApplication()
exit_status =

Regards, Jürgen

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]