python类Application()的实例源码

application.py 文件源码 项目:mcg 作者: coderkun 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def _load_ui(self):
        # Create builder to load UI
        self._builder = Gtk.Builder()
        self._builder.set_translation_domain(Application.DOMAIN)
        self._builder.add_from_resource(self._get_resource_path('gtk.glade'))
application.py 文件源码 项目:mcg 作者: coderkun 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def _load_appmenu(self):
        builder = Gtk.Builder()
        builder.set_translation_domain(Application.DOMAIN)
        builder.add_from_resource(self._get_resource_path('gtk.menu.ui'))
        self.set_app_menu(builder.get_object('app-menu'))
application.py 文件源码 项目:mcg 作者: coderkun 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def _get_resource_path(self, path):
        return "/{}/{}".format(Application.ID.replace('.', '/'), path)
ui.py 文件源码 项目:ez_gpg 作者: sgnn7 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def do_startup(self):
        print("Starting up...")
        Gtk.Application.do_startup(self)

        menu = Gio.Menu()

        for action, is_menu_item, callback in self._actions:
            if is_menu_item:
                menu.append(action.capitalize(), "app.%s" % action)

            simple_action = Gio.SimpleAction.new(action, None)
            simple_action.connect('activate', callback)
            self.add_action(simple_action)

        self.set_app_menu(menu)
player.py 文件源码 项目:chromecast-player 作者: wa4557 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def __init__(self, uri, show_gui=True):
        Gtk.Application.__init__(self,
                                 application_id='org.gnome.chromecast-player',
                                 flags=Gio.ApplicationFlags.FLAGS_NONE)
        GLib.set_application_name("Chromecast Player")
        GLib.set_prgname('chromecast-player')
        self.connect("activate", self._on_activate, uri)
        self.cast = None
        self.mc = None
        self.get_chromecast_config()
        self.uri = None
        self.play_now = True if uri else False
        self.play_uri = []
        self.serverthread = None
        self.subtitlethread = None
        self.local_port = 0
        self.show_gui = show_gui
        self.imagethread = None
        self.transcode_options = None
        self.playlist_manager = None
        if uri and not isinstance(uri, (list, tuple)):
            self.uri = [uri]
        elif uri:
            self.uri = uri
        self.loaded = False
        self.loc_file = None
        self.stop_worker = False
        self.is_playing = False
        self.is_paused = False
        self.is_idle = False
        self.is_disconnected = False
        self.playlist_counter = 0
        self.seeking = False
        self.overwrite = False
        self.continue_playing = False
        self.volume_changing = False
__main__.py 文件源码 项目:dri-config 作者: TingPing 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def do_shutdown(self):
        Gtk.Application.do_shutdown(self)
        if self.window:
            self.window.destroy()
gui_application.py 文件源码 项目:ghetto_omr 作者: pohzhiee 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def do_startup(self):
        Gtk.Application.do_startup(self)

        action = Gio.SimpleAction.new("about", None)
        action.connect("activate", self.on_about)
        self.add_action(action)

        action = Gio.SimpleAction.new("quit", None)
        action.connect("activate", self.on_quit)
        self.add_action(action)

        builder = Gtk.Builder.new_from_string(MENU_XML, -1)
        self.set_app_menu(builder.get_object("app-menu"))
gtk3.py 文件源码 项目:steemportal 作者: colibrae 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def __init__ (self):
        """
        Interface initialisation
        This function opens the window, calls back through the core, to 
        get the configuration, to load the initial interface. 

        The configuration tells the interface what to set up in the initial
        startup.
        """
        Gtk.Application.__init__(self,
            application_id="org.ascension.ascension",
            flags=Gio.ApplicationFlags.FLAGS_NONE)
        self.connect("activate", self.on_activate)
gtk3.py 文件源码 项目:steemportal 作者: colibrae 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def init (self, config):
        """
        Abstraction for command to open GUI. For Gtk+-3.0, this just maps to the
        built in Gtk.Application.run () command. For other GUI libraries, this
        will invoke the same. In this case, it triggers the activate hook.
        """
        # Import config object into this object's namespace
        self.config = config
        self.run ()
gtk3.py 文件源码 项目:steemportal 作者: colibrae 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def on_activate (self, data=None):
        """
        Activate Gtk.Application
        """
        debug ("Activating Gtk.Application", True)
        debug ("creating main window", False)
        self.window = window = Gtk.ApplicationWindow ()
        debug ("binding window to Application", False)
        self.add_window (window)
        winspec = self.config.get_interface ().split ()
        window.resize (int(winspec[2]), int(winspec[3]))
        window.move (int(winspec[0]), int(winspec [1]))
        window.connect('delete-event', self.save_state)
        window.show_all ()
application.py 文件源码 项目:luminance 作者: craigcabrey 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def do_startup(self):
        Gtk.Application.do_startup(self)

        builder = Gtk.Builder()

        builder.add_from_resource(get_resource_path('ui/about.ui'))
        builder.add_from_resource(get_resource_path('ui/menu.ui'))

        self.app_menu = builder.get_object('app-menu')
        self.about_dialog = builder.get_object('about-dialog')

        action = Gio.SimpleAction.new('connect', None)
        action.connect('activate', self._on_connect)
        self.add_action(action)

        action = Gio.SimpleAction.new('about', None)
        action.connect('activate', self._on_about)
        self.add_action(action)

        action = Gio.SimpleAction.new('quit', None)
        action.connect('activate', self._on_quit)
        self.add_action(action)

        self.set_app_menu(self.app_menu)

        self.mark_busy()
application.py 文件源码 项目:luminance 作者: craigcabrey 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def do_activate(self):
        Gtk.Application.do_activate(self)

        self._connect(self.host, self.username)

        self.unmark_busy()
application.py 文件源码 项目:draobpilc 作者: awamper 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def do_command_line(self, command_line):
        Gtk.Application.do_command_line(self, command_line)

        show_preferences = False
        if '--preferences' in command_line.get_arguments():
            show_preferences = True

        self.do_activate(show_preferences)

        return 0
main.py 文件源码 项目:gestureManager 作者: GabMus 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def __init__(self):
        Gtk.Application.__init__(self,
                                 application_id="org.gabmus.gesturemanager",
                                 flags=Gio.ApplicationFlags.FLAGS_NONE)
        self.connect("activate", self.activateCb)
main.py 文件源码 项目:gestureManager 作者: GabMus 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def do_startup(self):
        # start the application
        Gtk.Application.do_startup(self)
__main__.py 文件源码 项目:razerCommander 作者: GabMus 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def main():
    application = Application()

    try:
        ret = application.run(sys.argv)
    except SystemExit as e:
        ret = e.code

    sys.exit(ret)
test_gireactor.py 文件源码 项目:zenchmarks 作者: squeaky-pl 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def test_gApplicationActivate(self):
        """
        L{Gio.Application} instances can be registered with a gireactor.
        """
        reactor = gireactor.GIReactor(useGtk=False)
        self.addCleanup(self.unbuildReactor, reactor)
        app = Gio.Application(
            application_id='com.twistedmatrix.trial.gireactor',
            flags=Gio.ApplicationFlags.FLAGS_NONE)

        self.runReactor(app, reactor)
test_gireactor.py 文件源码 项目:zenchmarks 作者: squeaky-pl 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def test_gtkApplicationActivate(self):
        """
        L{Gtk.Application} instances can be registered with a gtk3reactor.
        """
        reactor = gtk3reactor.Gtk3Reactor()
        self.addCleanup(self.unbuildReactor, reactor)
        app = Gtk.Application(
            application_id='com.twistedmatrix.trial.gtk3reactor',
            flags=Gio.ApplicationFlags.FLAGS_NONE)

        self.runReactor(app, reactor)
test_gireactor.py 文件源码 项目:zenchmarks 作者: squeaky-pl 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def test_portable(self):
        """
        L{gireactor.PortableGIReactor} doesn't support application
        registration at this time.
        """
        reactor = gireactor.PortableGIReactor()
        self.addCleanup(self.unbuildReactor, reactor)
        app = Gio.Application(
            application_id='com.twistedmatrix.trial.gireactor',
            flags=Gio.ApplicationFlags.FLAGS_NONE)
        self.assertRaises(NotImplementedError,
                          reactor.registerGApplication, app)
test_gireactor.py 文件源码 项目:zenchmarks 作者: squeaky-pl 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def test_noQuit(self):
        """
        Older versions of PyGObject lack C{Application.quit}, and so won't
        allow registration.
        """
        reactor = gireactor.GIReactor(useGtk=False)
        self.addCleanup(self.unbuildReactor, reactor)
        # An app with no "quit" method:
        app = object()
        exc = self.assertRaises(RuntimeError, reactor.registerGApplication, app)
        self.assertTrue(exc.args[0].startswith(
                "Application registration is not"))


问题


面经


文章

微信
公众号

扫码关注公众号