Python gi.repository.Gtk 模块,ApplicationWindow() 实例源码

我们从Python开源项目中,提取了以下6个代码示例,用于说明如何使用gi.repository.Gtk.ApplicationWindow()

项目:Gnome-Authenticator    作者:bil-elmoussaoui    | 项目源码 | 文件源码
def generate_window(self, *args):
        """
            Generate application window (Gtk.Window)
        """
        Gtk.ApplicationWindow.__init__(self, type=Gtk.WindowType.TOPLEVEL,
                                       application=self.app)
        self.move_latest_position()
        self.set_wmclass("org.gnome.Authenticator", "Gnome Authenticator")
        self.set_icon_name("org.gnome.Authenticator")
        self.use_latest_size()
        self.set_resizable(True)
        self.connect("key_press_event", self.on_key_press)
        self.connect("delete-event", lambda x, y: self.app.on_quit())
        self.notification = InAppNotification()
        self.observable.register(self.notification)
        self.main_box.pack_start(self.notification, False, False, 0)
        self.add(self.main_box)
项目:sbrick-controller    作者:wintersandroid    | 项目源码 | 文件源码
def __init__(self, *args, **kwargs):
        self.config = kwargs.pop("config", None)
        self.sbrick_communications_store = ObservingDict(dict())

        Gtk.ApplicationWindow.__init__(self, *args, **kwargs)

        # self.set_default_size(800, 480)
        self.resize(800, 480)
        self.connect("delete-event", self.on_delete_window)

        self.notebook = Gtk.Notebook()
        self.add(self.notebook)
        self.notebook.set_scrollable(True)

        if self.config is not None:
            for sbrick in self.config:
                page = SBrickBox(sbrick, self.sbrick_communications_store)
                page.connect("show_message", self.on_show_message)
                self.notebook.append_page(page, Gtk.Label(sbrick["name"]))

        self.sequences_box = SequencesBox(self.config, self.sbrick_communications_store)
        self.notebook.append_page(self.sequences_box, Gtk.Label("Sequences"))

        self.actions = []
        self.actions_connected = []

        self.setup_actions()
        self.show_all()

        # noinspection PyUnusedLocal
项目:steemportal    作者:colibrae    | 项目源码 | 文件源码
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 ()
项目:revolt    作者:aperezdc    | 项目源码 | 文件源码
def do_configure_event(self, event):
        result = Gtk.ApplicationWindow.do_configure_event(self, event)
        width, height = self.get_size()
        self.saved_state.set_uint("width", width)
        self.saved_state.set_uint("height", height)
        return result
项目:python-sense-emu    作者:RPi-Distro    | 项目源码 | 文件源码
def do_destroy(self):
        try:
            self._play_stop()
        except AttributeError:
            # do_destroy gets called multiple times, and subsequent times lacks
            # the Python-added instance attributes
            pass
        Gtk.ApplicationWindow.do_destroy(self)
项目:revolt    作者:aperezdc    | 项目源码 | 文件源码
def __init__(self, application, saved_state):
        self.application = application
        self.saved_state = saved_state
        Gtk.ApplicationWindow.__init__(self,
                                       application=application,
                                       icon_name="revolt",
                                       role="main-window",
                                       default_width=saved_state.get_uint("width"),
                                       default_height=saved_state.get_uint("height"))
        if self.saved_state.get_boolean("maximized"):
            self.maximize()
        self.saved_state.bind("maximized", self, "is-maximized", Gio.SettingsBindFlags.SET)

        if application.settings.get_boolean("use-header-bar"):
            self.set_titlebar(self.__make_headerbar())
        self.set_title(u"Revolt")
        application.add_window(self)
        self._webview = WebKit2.WebView(user_content_manager=self._user_content_manager,
                                        web_context=self._web_context)
        self._webview.connect("decide-policy", self.__on_decide_policy)
        application.settings.bind("zoom-factor", self._webview, "zoom-level",
                                  Gio.SettingsBindFlags.GET)
        if hasattr(self._webview, "set_maintains_back_forward_list"):
            self._webview.set_maintains_back_forward_list(False)
        websettings = self._webview.get_settings()
        application.settings.bind("enable-developer-tools", websettings,
                                  "enable-developer-extras",
                                  Gio.SettingsBindFlags.GET)
        application.settings.bind("enable-developer-tools", websettings,
                                  "enable-write-console-messages-to-stdout",
                                  Gio.SettingsBindFlags.GET)

        self.add_accel_group(accelerators.window_keys)

        websettings.set_allow_file_access_from_file_urls(True)
        websettings.set_allow_modal_dialogs(False)  # TODO
        websettings.set_enable_fullscreen(False)
        websettings.set_enable_java(False)
        websettings.set_enable_media_stream(True)
        websettings.set_enable_page_cache(False)  # Single-page app
        websettings.set_enable_plugins(False)
        websettings.set_enable_smooth_scrolling(True)
        websettings.set_enable_webaudio(True)
        websettings.set_javascript_can_access_clipboard(True)
        websettings.set_minimum_font_size(12)  # TODO: Make it a setting
        websettings.set_property("enable-mediasource", True)

        # This makes Revolt lighter, and makes things work for people using
        # binary drivers (i.e. NVidia) with Flatpak build. See issue #29.
        if hasattr(websettings, "set_hardware_acceleration_policy"):
            websettings.set_hardware_acceleration_policy(WebKit2.HardwareAccelerationPolicy.NEVER)

        self._webview.show_all()
        self.add(self._webview)
        self.__connect_widgets()
        self.__notification_ids = set()