Gtk.Paned
Gtk.Paned — A widget with two adjustable panes
Object Hierarchy:
GObject
╰── GInitiallyUnowned
╰── Gtk.Widget
╰── Gtk.Container
╰── Gtk.Paned
├── Gtk.HPaned
╰── Gtk.VPaned
Functions:
- new
(orientation:Gtk.Orientation) -> Gtk.Widget
- add
(self, widget:Gtk.Widget)
- set_position
(self, position:int)
- get_position
(self) -> int
- get_handle_window
(self) -> Gdk.Window
- set_wide_handle
(self, wide:bool)
- get_wide_handle
(self) -> bool
Signals:
- “accept-position”
(widget, user_data)
- “cancel-position”
(widget, user_data)
- “cycle-child-focus”
(widget, reversed, user_data)
- “cycle-handle-focus”
(widget, reversed, user_data)
- “move-handle”
(widget, scroll_type, user_data)
- “toggle-handle-focus”
(widget, user_data)
Description:
Gtk.Paned
has two panes, arranged either horizontally or vertically. The division between the two panes is adjustable by the user by dragging a handle.
Child widgets are added to the panes of the widget with Gtk.Paned::pack1()
and Gtk.Paned::pack2()
. The division between the two children is set by default from the size requests of the children, but it can be adjusted by the user.
A paned widget draws a separator between the two child widgets and a small handle that the user can drag to adjust the division. It does not draw any relief around the children or around the separator. (The space in which the separator is called the gutter.) Often, it is useful to put each child inside a Gtk.Frame with the shadow type set to %GTK_SHADOW_IN so that the gutter appears as a ridge. No separator is drawn if one of the children is missing.
Each child has two options that can be set, resize and shrink. If resize is true, then when the Gtk.Paned
is resized, that child will expand or shrink along with the paned widget. If shrink is true, then that child can be made smaller than its requisition by the user.
Setting shrink to False allows the application to set a minimum size.
If resize is false for both children, then this is treated as if resize is true for both children.
The application can set the position of the slider as if it were set by the user, by calling Gtk.Paned::set_position()
.
Creating a paned widget with minimum sizes.
paned = Gtk.Paned()
paned.set_position(360)
self.add(hpaned)
Function Details:
new()
new (orientation:Gtk.Orientation) -> Gtk.Widget
Creates a new Gtk.Paned
widget.
Returns: a new
Gtk.Paned
.Since: 3.0
set_position()
set_position (self, position:int)
Sets the position of the divider between the two panes.
get_position()
get_position (self) -> int
Obtains the position of the divider between the two panes.
- Returns: position of the divider
get_handle_window()
get_handle_window (self) -> Gdk.Window
Returns the GdkWindow of the handle. This function isuseful when handling button or motion events because itenables the callback to distinguish between the windowof the paned, a child and the handle.
Returns: the paned’s handle window.
Since: 2.20
set_wide_handle()
set_wide_handle (self, wide:bool)
Sets the “wide-handle” property.
- Since: 3.16
get_wide_handle()
get_wide_handle (self) -> bool
Gets the “wide-handle” property.
Returns:
True
if the paned should have a wide handleSince: 3.16
Example:
import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk
def construct_tab(notebook, count):
title = "Tab %i" % (count)
eventbox = Gtk.EventBox()
tab_label = Gtk.Label(title)
eventbox.add(tab_label)
page_label = Gtk.Label(title)
notebook.insert_page(page_label, eventbox, count)
#eventbox.connect("button-press-event", close_tab, page_label)
tab_label.show()
class Paned(Gtk.Window):
def __init__(self):
Gtk.Window.__init__(self)
self.set_title('Paned')
self.set_default_size(1280, 960)
self.connect('destroy', Gtk.main_quit)
hpaned = Gtk.Paned()
hpaned.set_position(360)
self.add(hpaned)
vpaned = Gtk.Paned(orientation=Gtk.Orientation.VERTICAL)
vpaned.set_position(600)
hpaned.add1(vpaned)
#label = Gtk.Label(label='Left Pane')
#hpaned.add1(label)
notebook1 = Gtk.Notebook()
vpaned.add1(notebook1)
notebook2 = Gtk.Notebook()
vpaned.add2(notebook2)
for count in range(3):
construct_tab(notebook1, count)
for count in range(3):
construct_tab(notebook2, count)
vpaned_middle = Gtk.Paned(orientation=Gtk.Orientation.VERTICAL)
vpaned_middle.set_position(640)
hpaned.add2(vpaned_middle)
label = Gtk.Label(label='Top Right Pane')
vpaned_middle.add1(label)
label = Gtk.Label(label='Bottom Right Pane')
vpaned_middle.add2(label)
window = Paned()
window.show_all()
Gtk.main()