當前位置: 首頁>>代碼示例>>Python>>正文


Python Popup.show方法代碼示例

本文整理匯總了Python中popup.Popup.show方法的典型用法代碼示例。如果您正苦於以下問題:Python Popup.show方法的具體用法?Python Popup.show怎麽用?Python Popup.show使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在popup.Popup的用法示例。


在下文中一共展示了Popup.show方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: __init__

# 需要導入模塊: from popup import Popup [as 別名]
# 或者: from popup.Popup import show [as 別名]

#.........這裏部分代碼省略.........
                        if msg:
                                uri = msg.get_value('uri')

                                if uri:
                                        gfile = gio.File(uri)

                                        if gfile.is_native():
                                                paths.append(gfile)

                except StandardError:
                        pass

                # Recent documents
                paths.append(RecentDocumentsDirectory(screen=self._window.get_screen()))

                # Local bookmarks
                for path in self._local_bookmarks():
                        paths.append(path)

                # Desktop directory
                desktopdir = self._desktop_dir()

                if desktopdir:
                        paths.append(gio.File(desktopdir))

                # Home directory
                paths.append(gio.File(os.path.expanduser('~')))

                self._popup = Popup(self._window, paths, self.on_activated)

                self._popup.set_default_size(*self._plugin.get_popup_size())
                self._popup.set_transient_for(self._window)
                self._popup.set_position(gtk.WIN_POS_CENTER_ON_PARENT)

                self._window.get_group().add_window(self._popup)

                self._popup.connect('destroy', self.on_popup_destroy)

        def _local_bookmarks(self):
                filename = os.path.expanduser('~/.gtk-bookmarks')

                if not os.path.isfile(filename):
                        return []

                paths = []

                for line in file(filename, 'r').xreadlines():
                        uri = line.strip().split(" ")[0]
                        f = gio.File(uri)

                        if f.is_native():
                                try:
                                        info = f.query_info("standard::type")

                                        if info and info.get_file_type() == gio.FILE_TYPE_DIRECTORY:
                                                paths.append(f)
                                except glib.GError:
                                        pass

                return paths

        def _desktop_dir(self):
                config = os.getenv('XDG_CONFIG_HOME')

                if not config:
                        config = os.path.expanduser('~/.config')

                config = os.path.join(config, 'user-dirs.dirs')
                desktopdir = None

                if os.path.isfile(config):
                        for line in file(config, 'r').xreadlines():
                                line = line.strip()

                                if line.startswith('XDG_DESKTOP_DIR'):
                                        parts = line.split('=', 1)
                                        desktopdir = os.path.expandvars(parts[1].strip('"').strip("'"))
                                        break

                if not desktopdir:
                        desktopdir = os.path.expanduser('~/Desktop')

                return desktopdir

        # Callbacks
        def on_quick_open_activate(self, action):
                if not self._popup:
                        self._create_popup()

                self._popup.show()

        def on_popup_destroy(self, popup):
                alloc = popup.get_allocation()
                self._plugin.set_popup_size((alloc.width, alloc.height))

                self._popup = None

        def on_activated(self, gfile):
                cedit.commands.load_uri(self._window, gfile.get_uri(), None, -1)
                return True
開發者ID:cranes-bill,項目名稱:cedit,代碼行數:104,代碼來源:windowhelper.py

示例2: QuickOpenPlugin

# 需要導入模塊: from popup import Popup [as 別名]
# 或者: from popup.Popup import show [as 別名]

#.........這裏部分代碼省略.........
        # File browser root directory
        bus = self.window.get_message_bus()

        if bus.is_registered('/plugins/filebrowser', 'get_root'):
            msg = bus.send_sync('/plugins/filebrowser', 'get_root')

            if msg:
                gfile = msg.props.location

                if gfile and gfile.is_native():
                    paths.append(gfile)

        # Recent documents
        paths.append(RecentDocumentsDirectory())

        # Local bookmarks
        for path in self._local_bookmarks():
            paths.append(path)

        # Desktop directory
        desktopdir = self._desktop_dir()

        if desktopdir:
            paths.append(Gio.file_new_for_path(desktopdir))

        # Home directory
        paths.append(Gio.file_new_for_path(os.path.expanduser('~')))

        self._popup = Popup(self.window, paths, self.on_activated)
        self.window.get_group().add_window(self._popup)

        self._popup.set_default_size(*self.get_popup_size())
        self._popup.set_transient_for(self.window)
        self._popup.set_position(Gtk.WindowPosition.CENTER_ON_PARENT)
        self._popup.connect('destroy', self.on_popup_destroy)

    def _local_bookmarks(self):
        filename = os.path.expanduser('~/.gtk-bookmarks')

        if not os.path.isfile(filename):
            return []

        paths = []

        for line in file(filename, 'r').xreadlines():
            uri = line.strip().split(" ")[0]
            f = Gio.file_new_for_uri(uri)

            if f.is_native():
                try:
                    info = f.query_info(Gio.FILE_ATTRIBUTE_STANDARD_TYPE,
                                        Gio.FileQueryInfoFlags.NONE,
                                        None)

                    if info and info.get_file_type() == Gio.FileType.DIRECTORY:
                        paths.append(f)
                except:
                    pass

        return paths

    def _desktop_dir(self):
        config = os.getenv('XDG_CONFIG_HOME')

        if not config:
            config = os.path.expanduser('~/.config')

        config = os.path.join(config, 'user-dirs.dirs')
        desktopdir = None

        if os.path.isfile(config):
            for line in file(config, 'r').xreadlines():
                line = line.strip()

                if line.startswith('XDG_DESKTOP_DIR'):
                    parts = line.split('=', 1)
                    desktopdir = os.path.expandvars(parts[1].strip('"').strip("'"))
                    break

        if not desktopdir:
            desktopdir = os.path.expanduser('~/Desktop')

        return desktopdir

    # Callbacks
    def on_quick_open_activate(self, action, user_data=None):
        if not self._popup:
            self._create_popup()

        self._popup.show()

    def on_popup_destroy(self, popup, user_data=None):
        alloc = popup.get_allocation()
        self.set_popup_size((alloc.width, alloc.height))

        self._popup = None

    def on_activated(self, gfile, user_data=None):
        Gedit.commands_load_location(self.window, gfile, None, -1, -1)
        return True
開發者ID:onia,項目名稱:pygi,代碼行數:104,代碼來源:__init__.py

示例3: __init__

# 需要導入模塊: from popup import Popup [as 別名]
# 或者: from popup.Popup import show [as 別名]
class WindowHelper:
    
    def __init__(self, window, plugin):
        self._window = window
        self._plugin = plugin
        self._popup = None
        
        self._install_menu()

    def deactivate(self):
        self._uninstall_menu()
        
        self._window = None
        self._plugin = None

    def update_ui(self):
        pass
    
    def _install_menu(self):
        manager = self._window.get_ui_manager()
        self._action_group = gtk.ActionGroup("GeditQuickHighlightModePluginActions")
        self._action_group.add_actions([(
            "QuickHighlightMode",
            gtk.STOCK_OPEN,
            _("Quick Highlight Mode"),
            "<Ctrl><Shift>H",
            _("Quickly switch between document syntax highlight modes"),
            self.on_lang_switcher_activate
        )])
        
        manager.insert_action_group(self._action_group, -1)
        self._ui_id = manager.add_ui_from_string(ui_str)
    
    def _uninstall_menu(self):
        manager = self._window.get_ui_manager()
        
        manager.remove_ui(self._ui_id)
        manager.remove_action_group(self._action_group)
        
        manager.ensure_update()
    
    def _create_popup(self):
        self._popup = Popup(self._window, self.on_selected)
        
        self._popup.set_default_size(*self._plugin.get_popup_size())
        self._popup.set_transient_for(self._window)
        self._popup.set_position(gtk.WIN_POS_CENTER_ON_PARENT)
        
        self._window.get_group().add_window(self._popup)
        
        self._popup.connect("destroy", self._destroy_popup)
    
    def _destroy_popup(self, popup):
        alloc = popup.get_allocation()
        self._plugin.set_popup_size((alloc.width, alloc.height))
        
        self._popup = None
    
    # Events
    def on_lang_switcher_activate(self, action):
        if not self._popup:
            self._create_popup()
        
        self._popup.show()
    
    def on_selected(self, lang):
        doc = self._window.get_active_document()
        doc.set_language(lang)
        return True
開發者ID:nagaozen,項目名稱:gedit-plugin-quickhighlightmode,代碼行數:71,代碼來源:windowhelper.py

示例4: __init__

# 需要導入模塊: from popup import Popup [as 別名]
# 或者: from popup.Popup import show [as 別名]
class WindowHelper:
    def __init__(self, window, plugin, search_func):
        self._window = window
        self._plugin = plugin

        self._search_func = search_func

        self._popup = None
        self._install_menu()

    def deactivate(self):
        self._uninstall_menu()
        self._window = None
        self._plugin = None

    def update_ui(self):
        pass

    def _uninstall_menu(self):
        manager = self._window.get_ui_manager()
        manager.remove_ui(self._ui_id)
        manager.remove_action_group(self._action_group)
        manager.ensure_update()

    def _install_menu(self):
        manager = self._window.get_ui_manager()
        self._action_group = gtk.ActionGroup("GeditAPQuickOpenPluginActions")
        self._action_group.add_actions(
            [
                (
                    "APQuickOpen",
                    gtk.STOCK_OPEN,
                    _("Axy Quick open"),
                    "<Ctrl><Alt>O",
                    _("Axy Quickly open documents"),
                    self.on_quick_open_activate,
                )
            ]
        )

        manager.insert_action_group(self._action_group, -1)
        self._ui_id = manager.add_ui_from_string(ui_str)

    def _create_popup(self):
        self._popup = Popup(self._window, self.on_result, self._search_func)
        self._popup.set_default_size(*self._plugin.get_popup_size())
        self._popup.set_transient_for(self._window)
        self._popup.set_position(gtk.WIN_POS_CENTER_ON_PARENT)

        self._window.get_group().add_window(self._popup)
        self._popup.connect("destroy", self.on_popup_destroy)

    def on_quick_open_activate(self, action):
        if not self._popup:
            self._create_popup()

        self._popup.show()

    def on_popup_destroy(self, popup):
        alloc = popup.get_allocation()
        self._plugin.set_popup_size((alloc.width, alloc.height))
        self._popup = None

    def on_result(self, path):
        path = os.path.join(get_core(self._window).get_path(), path)
        uri = gio.File(path).get_uri()
        gedit.commands.load_uri(self._window, uri, None, -1)
        return True
開發者ID:alexkv,項目名稱:Gedit-PowerProject-Plugins,代碼行數:70,代碼來源:windowhelper.py


注:本文中的popup.Popup.show方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。