class Application(Gtk.Application): def __init__(self, *args, **kwargs): super().__init__(*args, application_id="org.example.myapp", flags=Gio.ApplicationFlags.HANDLES_COMMAND_LINE, **kwargs) self.window = None self.add_main_option("test", ord("t"), GLib.OptionFlags.NONE, GLib.OptionArg.NONE, "Command line test", None) def do_startup(self): Gtk.Application.do_startup(self) action = Gio.SimpleAction.new("quit", None) action.connect("activate", self.on_quit) self.add_action(action) def do_activate(self): # We only allow a single window and raise any existing ones if not self.window: # Windows are associated with the application # when the last one is closed the application shuts down self.window = AppWindow(application=self, title="Main Window") self.window.present() def do_command_line(self, command_line): options = command_line.get_options_dict() if options.contains("test"): # This is printed on the main instance print("Test argument recieved") self.activate() return 0