当前位置: 首页>>代码示例>>Python>>正文


Python Gtk.Paned方法代码示例

本文整理汇总了Python中gi.repository.Gtk.Paned方法的典型用法代码示例。如果您正苦于以下问题:Python Gtk.Paned方法的具体用法?Python Gtk.Paned怎么用?Python Gtk.Paned使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在gi.repository.Gtk的用法示例。


在下文中一共展示了Gtk.Paned方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: store_widget_properties

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import Paned [as 别名]
def store_widget_properties(self, widget, widget_name):
        """Sets configuration values for widgets

        If the widget is a window, then the size and position are stored. If the widget is a pane, then only the
        position is stored. If the window is maximized the last insert position before being maximized is keep in the
        config and the maximized flag set to True. The maximized state and the last size and position are strictly
        separated by this.

        :param widget: The widget, for which the position (and possibly the size) will be stored.
        :param widget_name: The window or widget name of the widget, which constitutes a part of its key in the
        configuration file.
        """
        if isinstance(widget, Gtk.Window):
            maximized = bool(widget.is_maximized())
            self.set_config_value('{0}_MAXIMIZED'.format(widget_name), maximized)
            if maximized:
                return
            size = widget.get_size()
            self.set_config_value('{0}_SIZE'.format(widget_name), tuple(size))
            position = widget.get_position()
            self.set_config_value('{0}_POS'.format(widget_name), tuple(position))
        else:  # Gtk.Paned
            position = widget.get_position()
            self.set_config_value('{0}_POS'.format(widget_name), position) 
开发者ID:DLR-RM,项目名称:RAFCON,代码行数:26,代码来源:runtime_config.py

示例2: _init_window

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import Paned [as 别名]
def _init_window(self):
        self.set_wmclass("oomox", "Oomox")
        self.set_role("Oomox-GUI")
        self.connect("delete-event", self._on_quit)
        self.set_default_size(
            width=UI_SETTINGS.window_width,
            height=UI_SETTINGS.window_height
        )

        self._init_headerbar()

        self.box = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL)
        self.add(self.box)

        self.paned_box = Gtk.Paned(orientation=Gtk.Orientation.HORIZONTAL)
        self.paned_box.set_wide_handle(True)
        self.box.pack_start(self.paned_box, expand=True, fill=True, padding=0) 
开发者ID:themix-project,项目名称:oomox,代码行数:19,代码来源:main.py

示例3: resize_paned

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import Paned [as 别名]
def resize_paned(self, paned, rect, relpos):
        """ Resize `paned` to have its handle at `relpos`, then disconnect this signal handler.

        Called from the :func:`Gtk.Widget.signals.size_allocate` signal.

        Args:
            paned (:class:`~Gtk.Paned`): Panel whose size has just been allocated, and whose handle needs initial
                                         placement.
            rect (:class:`~Gdk.Rectangle`): The rectangle specifying the size that has just been allocated to `~paned`
            relpos (`float`): A number between `0.` and `1.` that specifies the handle position

        Returns:
            `True`
        """
        size = rect.width if paned.get_orientation() == Gtk.Orientation.HORIZONTAL else rect.height
        handle_pos = int(round(relpos * size))
        GLib.idle_add(paned.set_position, handle_pos)

        paned.disconnect(self.pending_pane_resizes.pop(paned.get_name()))
        return True 
开发者ID:Cimbali,项目名称:pympress,代码行数:22,代码来源:builder.py

示例4: on_toggled

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import Paned [as 别名]
def on_toggled(self, menu_item, panel):
        """ Show/Hide side panel """
        try:
            leaf = self.notebooks[panel_name(panel.__name__)].get_parent().get_parent()
        except AttributeError:
            # new sidepanel appeared (not in saved layout .xml file)
            name = panel_name(panel.__name__)
            leaf = self.main_notebook.get_parent().get_parent()
            leaf.dock(self.docks[name][1], SOUTH, self.docks[name][0], name)

        parent = leaf.get_parent()
        names = [p[2] for p in leaf.panels]

        active = menu_item.get_active()
        name = panel_name(panel.__name__)
        shown = sum([1 for panel in self.sidePanels if panel_name(panel.__name__) in names and self.notebooks[panel_name(panel.__name__)].is_visible()])

        if active:
            self.notebooks[name].show()
            leaf.setCurrentPanel(name)
            if shown == 0 and hasattr(leaf, "position"):
                # If this is the first one, adjust Gtk.Paned divider handle
                if leaf.position != 0:
                    parent.set_position(leaf.position)
                else:
                    parent.set_position(parent.props.max_position / 2)
        else:
            self.notebooks[name].hide()
            if shown == 1:
                # If this is the last one, adjust Gtk.Paned divider handle
                pos = parent.get_position()
                leaf.position = pos if pos != parent.props.min_position and pos != parent.props.max_position else 0
                if leaf == parent.get_child1():
                    parent.set_position(parent.props.min_position)
                else:
                    parent.set_position(parent.props.max_position) 
开发者ID:pychess,项目名称:pychess,代码行数:38,代码来源:__init__.py

示例5: initChildren

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import Paned [as 别名]
def initChildren(self, old, new, preserve_dimensions=False):
        if self.position == NORTH or self.position == WEST:
            self.paned.pack1(new, resize=True, shrink=True)
            self.paned.pack2(old, resize=True, shrink=True)
        elif self.position == SOUTH or self.position == EAST:
            self.paned.pack1(old, resize=True, shrink=True)
            self.paned.pack2(new, resize=True, shrink=True)
        old.show()
        new.show()

        def cb(widget, allocation):
            # Set initial position of the divider between the two panes of Gtk.Paned
            if allocation.height != 1:
                if self.position == NORTH:
                    pos = 0.381966011 * allocation.height
                elif self.position == SOUTH:
                    pos = 0.618033989 * allocation.height
                elif self.position == WEST:
                    pos = 0.381966011 * allocation.width
                elif self.position == EAST:
                    pos = 0.618033989 * allocation.width

                widget.set_position(int(pos + .5))
                widget.disconnect(conid)

        if not preserve_dimensions:
            conid = self.paned.connect("size-allocate", cb) 
开发者ID:pychess,项目名称:pychess,代码行数:29,代码来源:PyDockComposite.py

示例6: reset_categories_pos

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import Paned [as 别名]
def reset_categories_pos(self, page):
        """
           whenever a source changes this resets the source categories position
           reflect the changed source
           :param page - RBDisplayPage
        """
        print("reset categories position")
        if not page:
            print("no page")
            return

        if not hasattr(page.props, 'show_browser'):
            print("no browser")
            return

        if not self.plugin.horiz_categories:
            print("not horizontal")
            return

        propertyview = self.find(page, 'RBPropertyView', 'by_name')

        if propertyview is None:
            return

        parent = propertyview.get_parent()

        if isinstance(parent, Gtk.Paned):
            print("paned")
            parent.set_orientation(Gtk.Orientation.HORIZONTAL)
        else:
            print("not paned")
            pane = parent.get_parent()
            print(pane)
            parent.set_orientation(Gtk.Orientation.VERTICAL)
            pane.set_orientation(Gtk.Orientation.HORIZONTAL) 
开发者ID:fossfreedom,项目名称:alternative-toolbar,代码行数:37,代码来源:alttoolbar_type.py

示例7: redraw_panes

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import Paned [as 别名]
def redraw_panes(self):
        """ Handler for :class:`~Gtk.Paned`'s resizing signal.

        Used for delayed drawing events of drawing areas inside the panes.

        This is very useful on windows where resizing gets sluggish if we try to redraw while resizing.
        """
        self.resize_panes = False
        self.p_da_cur.queue_draw()
        self.p_da_next.queue_draw()
        if self.notes_mode:
            self.p_da_notes.queue_draw()
        if self.redraw_timeout:
            self.redraw_timeout = 0 
开发者ID:Cimbali,项目名称:pympress,代码行数:16,代码来源:ui.py

示例8: switch_annotations

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import Paned [as 别名]
def switch_annotations(self, widget, event = None):
        """ Switch the display to show annotations or to hide them.

        Returns:
            `bool`: whether the mode has been toggled.
        """
        if issubclass(type(widget), Gtk.CheckMenuItem) and widget.get_active() == self.show_annotations:
            return False

        self.show_annotations = not self.show_annotations

        self.p_frame_annot.set_visible(self.show_annotations)
        self.config.set('presenter', 'show_annotations', 'on' if self.show_annotations else 'off')

        if self.show_annotations:
            parent = self.p_frame_annot.get_parent()
            if issubclass(type(parent), Gtk.Paned):
                if parent.get_orientation() == Gtk.Orientation.HORIZONTAL:
                    size = parent.get_parent().get_allocated_width()
                else:
                    size = parent.get_parent().get_allocated_height()
                parent.set_position(self.pane_handle_pos[parent] * size)

        self.annotations.add_annotations(self.doc.current_page().get_annotations())
        self.pres_annot.set_active(self.show_annotations)

        return True 
开发者ID:Cimbali,项目名称:pympress,代码行数:29,代码来源:ui.py

示例9: update_layout

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import Paned [as 别名]
def update_layout(self, layout_name, widget, pane_handle_pos):
        """ Setter for the notes layout.

        Args:
            layout_name (`str`): the name of the layout to update
            widget (:class:`~Gtk.Widget`): the widget that will contain the layout.
            pane_handle_pos (`dict`): Map of :class:`~Gtk.Paned` to the relative handle position (float in 0..1)
        """
        self.layout[layout_name] = self.widget_layout_to_tree(widget, pane_handle_pos) 
开发者ID:Cimbali,项目名称:pympress,代码行数:11,代码来源:config.py

示例10: load

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import Paned [as 别名]
def load(self, widgets, connection, lounge):
        self.connection = connection

        # deferred imports to not slow down PyChess starting up
        from pychess.widgets.ViewsPanel import ViewsPanel
        from pychess.widgets.InfoPanel import InfoPanel
        from pychess.widgets.ChannelsPanel import ChannelsPanel

        self.viewspanel = ViewsPanel(self.connection)
        self.channelspanel = ChannelsPanel(self.connection)
        self.adj = self.channelspanel.get_vadjustment()
        self.infopanel = InfoPanel(self.connection)

        self.chatbox = Gtk.Paned()
        __widget__ = self.chatbox

        self.chatbox.add1(self.channelspanel)

        notebook = Gtk.Notebook()
        notebook.append_page(self.viewspanel, Gtk.Label(_("Chat")))
        notebook.append_page(self.infopanel, Gtk.Label(_("Info")))
        self.chatbox.add2(notebook)

        self.panels = [self.viewspanel, self.channelspanel, self.infopanel]
        self.viewspanel.connect('channel_content_Changed',
                                self.channelspanel.channel_Highlight, id)

        self.channelspanel.connect('conversationAdded',
                                   self.onConversationAdded)
        self.channelspanel.connect('conversationRemoved',
                                   self.onConversationRemoved)
        self.channelspanel.connect('conversationSelected',
                                   self.onConversationSelected)
        self.channelspanel.connect('focus_in_event', self.focus_in, self.adj)

        for panel in self.panels:
            panel.show_all()
            panel.start()
        self.chatbox.show_all()

        uistuff.keep(self.chatbox, "chat_paned_position")

        return __widget__ 
开发者ID:pychess,项目名称:pychess,代码行数:45,代码来源:ChatPanel.py

示例11: build

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import Paned [as 别名]
def build(self, webview_obj, data_source, title):
        width = 900
        height = 600

        # Prettier process name
        if proctitle_available:
            setproctitle.setproctitle("software-boutique")

        window = Gtk.Window()
        window.set_position(Gtk.WindowPosition.CENTER)
        window.set_wmclass("software-boutique", "software-boutique")
        window.set_title(title)
        window.set_icon_from_file(os.path.join(data_source, "view", "ui", "boutique.svg"))

        # http://askubuntu.com/questions/153549/how-to-detect-a-computers-physical-screen-size-in-gtk
        s = Gdk.Screen.get_default()
        if s.get_height() <= 600:
            window.set_size_request(768, 528)
        else:
            window.set_size_request(width, height)

        self.webkit = webview_obj

        # Load the starting page
        html_path = "file://" + os.path.abspath(os.path.join(data_source, "view", "boutique.html"))
        self.webkit.load_uri(html_path)

        # Create scrolled window (containing WebKit) to be part of a horz. pane
        sw = Gtk.ScrolledWindow()
        sw.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC)
        sw.add(self.webkit)
        pane = Gtk.Paned(orientation = Gtk.Orientation.HORIZONTAL)

        # GTK Window -> Paned -> ScrolledWindow -> WebKit + Inspector (debugging)
        pane.add(sw)
        window.add(pane)

        # If debugging, open the inspector side-by-side
        if self.webkit.inspector:
            def dummy(webview):
                return True

            inspector = self.webkit.get_inspector()
            inspector.connect("open-window", dummy)
            inspector.show()
            inspector_webview = inspector.get_web_view()
            pane.add(inspector_webview)
            pane.set_position(1000)
            window.set_size_request(1920, 600)
            window.set_position(Gtk.WindowPosition.CENTER)

        window.connect("delete-event", self._close)
        self.window = window 
开发者ID:ubuntu-mate,项目名称:software-boutique,代码行数:55,代码来源:app_window.py

示例12: widget_layout_to_tree

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import Paned [as 别名]
def widget_layout_to_tree(self, widget, pane_handle_pos):
        """ Build a tree representing a widget hierarchy, leaves are strings and nodes are `dict`.

        Recursive function. See validate_layout() for more info on the tree structure.

        Args:
            widget (:class:`~Gtk.Widget`): the widget where to start
            pane_handle_pos (`dict`): Map of :class:`~Gtk.Paned` to the relative handle position (float in 0..1)

        Returns:
            `dict`: A tree of dicts reprensenting the widget hierarchy
        """
        orientation_names = {Gtk.Orientation.HORIZONTAL: 'horizontal', Gtk.Orientation.VERTICAL: 'vertical'}

        name = widget.get_name()
        matching_widget_names = [k for k, v in self.placeable_widgets.items() if v == name]

        if matching_widget_names:
            return matching_widget_names[0]

        elif issubclass(type(widget), Gtk.Box):
            return {'resizeable': False, 'orientation': orientation_names[widget.get_orientation()],
                    'children': [self.widget_layout_to_tree(c, pane_handle_pos) for c in widget.get_children()]}

        elif issubclass(type(widget), Gtk.Paned):
            proportions = [1]
            reverse_children = []
            orientation = widget.get_orientation()
            if orientation == Gtk.Orientation.HORIZONTAL:
                get_size = Gtk.Widget.get_allocated_width
            else:
                get_size = Gtk.Widget.get_allocated_height

            while issubclass(type(widget), Gtk.Paned) and orientation == widget.get_orientation():
                left_pane = widget.get_child1()
                right_pane = widget.get_child2()

                visible = left_pane.get_visible() and right_pane.get_visible()
                position = widget.get_position()
                widget_size = get_size(widget)

                if not visible or widget_size <= 1:
                    # reuse number that was in config initially, otherwise gets overwritten with 0
                    ratio = pane_handle_pos[widget]
                else:
                    ratio = float(position) / widget_size

                proportions = [ratio] + [(1 - ratio) * p for p in proportions]
                reverse_children.append(right_pane)
                widget = left_pane

            reverse_children.append(left_pane)

            return {'resizeable': True, 'proportions': proportions, 'orientation': orientation_names[orientation],
                    'children': [self.widget_layout_to_tree(c, pane_handle_pos) for c in reversed(reverse_children)]}

        raise ValueError('Error serializing layout: widget of type {} '.format(type(widget)) +
                         'is not an expected container or named widget: "{}"'.format(name)) 
开发者ID:Cimbali,项目名称:pympress,代码行数:60,代码来源:config.py


注:本文中的gi.repository.Gtk.Paned方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。