本文整理汇总了Python中gi.repository.Gtk.Application方法的典型用法代码示例。如果您正苦于以下问题:Python Gtk.Application方法的具体用法?Python Gtk.Application怎么用?Python Gtk.Application使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gi.repository.Gtk
的用法示例。
在下文中一共展示了Gtk.Application方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import Application [as 别名]
def __init__(self, application, window):
utilities.assert_arg_type(application, Gtk.Application, arg_pos=1)
utilities.assert_arg_type(window, MainAppWindow, arg_pos=2)
super(MainMenuBar, self).__init__(application)
self.window = weakref.proxy(window)
self._add_accelerators()
graphs_menu_item = self.gtk_builder_get('menuitem_tools_create_graph')
if graphs.has_matplotlib:
graphs_submenu = Gtk.Menu.new()
for graph_name in graphs.get_graphs():
graph = graphs.get_graph(graph_name)
menu_item = Gtk.MenuItem.new_with_label(graph.name_human)
menu_item.connect('activate', self.signal_activate_tools_show_campaign_graph, graph_name)
graphs_submenu.append(menu_item)
graphs_menu_item.set_submenu(graphs_submenu)
graphs_menu_item.show_all()
else:
graphs_menu_item.set_sensitive(False)
示例2: __init__
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import Application [as 别名]
def __init__(self, application, plugin_id):
"""
:param application: The parent application for this object.
:type application: :py:class:`Gtk.Application`
:param str plugin_id: The identifier of this plugin.
"""
super(PluginDocumentationWindow, self).__init__(application)
plugin_path = self.application.plugin_manager.get_plugin_path(plugin_id)
if plugin_path is None:
raise FileNotFoundError(errno.ENOENT, "could not find the data path for plugin '{0}'".format(plugin_id))
md_file = os.path.join(plugin_path, 'README.md')
if md_file is None or not os.path.isfile(md_file):
self.window.destroy()
raise FileNotFoundError(errno.ENOENT, "plugin '{0}' has no documentation".format(plugin_id), md_file)
self._md_file = md_file
self._plugin = self.application.plugin_manager[plugin_id]
self.refresh()
self.webview.connect('key-press-event', self.signal_key_press_event)
self.webview.connect('open-remote-uri', self.signal_webview_open_remote_uri)
self.window.set_title('Plugin Documentation')
示例3: __init__
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import Application [as 别名]
def __init__(self, application, exc_info=None, error_uid=None):
"""
:param application: The parent application for this object.
:type application: :py:class:`Gtk.Application`
:param tuple exc_info: The exception information as provided by :py:func:`sys.exc_info`.
:param str error_uid: An optional unique identifier for the exception that can be provided for tracking purposes.
"""
super(ExceptionDialog, self).__init__(application)
self.error_description = self.gtk_builder_get('label_error_description')
self.error_details = self.gtk_builder_get('textview_error_details')
self.error_details.modify_font(Pango.FontDescription('monospace 9'))
self.exc_info = exc_info or sys.exc_info()
self.error_uid = error_uid
linkbutton = self.gobjects['linkbutton_github_issues']
linkbutton.set_label('Project Issue Tracker')
linkbutton.connect('activate-link', lambda _: utilities.open_uri(linkbutton.get_property('uri')))
示例4: test_cantRegisterAfterRun
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import Application [as 别名]
def test_cantRegisterAfterRun(self):
"""
It is not possible to register a C{Application} after the reactor has
already started.
"""
reactor = gireactor.GIReactor(useGtk=False)
self.addCleanup(self.unbuildReactor, reactor)
app = Gio.Application(
application_id='com.twistedmatrix.trial.gireactor',
flags=Gio.ApplicationFlags.FLAGS_NONE)
def tryRegister():
exc = self.assertRaises(ReactorAlreadyRunning,
reactor.registerGApplication, app)
self.assertEqual(exc.args[0],
"Can't register application after reactor was started.")
reactor.stop()
reactor.callLater(0, tryRegister)
ReactorBuilder.runReactor(self, reactor)
示例5: do_activate
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import Application [as 别名]
def do_activate(self):
"""Callback when launched from the desktop."""
# Browser (still hidden)
if not self.browser:
self.browser = MainWindow(self.req, self)
if self.props.application_id == 'org.gnome.GTGDevel':
self.browser.get_style_context().add_class('devel')
self.init_actions()
self.init_plugin_engine()
self.browser.present()
self.open_uri_list()
log.debug("Application activation finished")
示例6: __init__
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import Application [as 别名]
def __init__(self, running_tests=False):
"""Create the Gtk.Application and connect the activate signal.
Args:
running_tests: If True, running from test suite. Do not show pop-up
windows and do not parse user configuration files.
"""
# Init application and set default values
app_id = "org.vimiv" + str(time()).replace(".", "")
super(Vimiv, self).__init__(application_id=app_id)
self.set_flags(Gio.ApplicationFlags.HANDLES_OPEN)
self.connect("activate", self.activate_vimiv)
self._paths = []
self._index = 0
self._widgets = {}
self.debug = False
self._tmpdir = None
self.running_tests = running_tests
# Set up all commandline options
self._init_commandline_options()
示例7: __init__
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import Application [as 别名]
def __init__(self, log_viewer, purge_recent, chess_file, ics_host, ics_port, loop, splash, version_check):
Gtk.Application.__init__(self,
application_id="org.pychess",
flags=Gio.ApplicationFlags.NON_UNIQUE)
self.loop = loop
if ics_host:
ICLogon.host = ics_host
if ics_port:
ICLogon.port = ics_port
self.log_viewer = log_viewer
self.purge_recent = purge_recent
self.chess_file = chess_file
self.window = None
self.splash = splash
self.version_check = version_check
示例8: do_command_line
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import Application [as 别名]
def do_command_line(self, args):
"""
GTK.Application command line handler
called if Gio.ApplicationFlags.HANDLES_COMMAND_LINE is set.
must call the self.do_activate() to get the application up and running.
"""
Gtk.Application.do_command_line(self, args) # call the default commandline handler
# make a command line parser
parser = argparse.ArgumentParser(prog='gui')
# add a -c/--color option
parser.add_argument('-q', '--quit-after-init', dest='quit_after_init', action='store_true', help='initialize application (e.g. for macros initialization on system startup) and quit')
# parse the command line stored in args, but skip the first element (the filename)
self.args = parser.parse_args(args.get_arguments()[1:])
# call the main program do_activate() to start up the app
self.do_activate()
return 0
示例9: do_command_line
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import Application [as 别名]
def do_command_line(self, args):
'''
GTK.Application command line handler
called if Gio.ApplicationFlags.HANDLES_COMMAND_LINE is set.
must call the self.do_activate() to get the application up and running.
'''
Gtk.Application.do_command_line(self, args) # call the default commandline handler
# make a command line parser
parser = argparse.ArgumentParser(prog='gui')
# add a -c/--color option
parser.add_argument('-q', '--quit-after-init', dest='quit_after_init', action='store_true', help='initialize application (e.g. for macros initialization on system startup) and quit')
# parse the command line stored in args, but skip the first element (the filename)
self.args = parser.parse_args(args.get_arguments()[1:])
# call the main program do_activate() to start up the app
self.do_activate()
return 0
示例10: do_startup
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import Application [as 别名]
def do_startup(self):
Gtk.Application.do_startup(self)
self.builder = Gtk.Builder()
self.builder.add_from_file(get_resource('manager_gui.glade'))
self.builder.set_application(self)
self.builder.connect_signals(self)
# This does not get initialized until needed
self.extras = dict()
self.system_themes = envspecific.get_installed_themes(self.us_se['desktop_environment'])
self.listen_changes = False
self.saved_settings = False
self.entries_error = list()
self.changed = list()
# Override the quit menu
action = Gio.SimpleAction.new("quit", None)
action.connect("activate", self.on_confirm_exit)
self.add_action(action)
# noinspection PyAttributeOutsideInit
示例11: __init__
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import Application [as 别名]
def __init__(self):
Gtk.Application.__init__(self,
application_id="com.github.bilelmoussaoui.Authenticator",
flags=Gio.ApplicationFlags.FLAGS_NONE)
GLib.set_application_name(_("Authenticator"))
GLib.set_prgname("Authenticator")
self.alive = True
self._menu = Gio.Menu()
示例12: get_default
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import Application [as 别名]
def get_default():
if Application.instance is None:
Application.instance = Application()
return Application.instance
示例13: do_startup
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import Application [as 别名]
def do_startup(self):
"""Startup the application."""
Gtk.Application.do_startup(self)
# Unlock the keyring
self.__generate_menu()
self.__setup_actions()
Application.__setup_css()
# Set the default night mode
is_night_mode = Settings.get_default().is_night_mode
gtk_settings = Gtk.Settings.get_default()
gtk_settings.set_property("gtk-application-prefer-dark-theme",
is_night_mode)
示例14: set_use_qrscanner
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import Application [as 别名]
def set_use_qrscanner(state):
Application.USE_QRSCANNER = state
示例15: __init__
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import Application [as 别名]
def __init__(self):
Gtk.Application.__init__(self)
self.connect("activate", self.on_activate)
self.controller = AlienFXProber.get_controller()
self.themefile = AlienFXThemeFile(self.controller)
self.selected_action = None
self.action_type = self.themefile.KW_ACTION_TYPE_FIXED
self.theme_edited = False
self.set_theme_done = True