PyGTK Paned Class - PyGTK

What is PyGTK Paned Class?

Paned class is the base class for widgets which can show two adaptable panes either horizontally (gtk.Hpaned) or vertically (gtk.Vpaned). Child widgets to panes are added by using pack1 () and pack2 () methods.

Paned widget draws a separator slider between two panes and offers a handle to adjust their relative width/height. If the resize property of child widget inside a pane is set to True, it will resize according to the size of the panes.

The resulting methods are available for HPaned as well as VPaned class −

  • Paned.add1(child) − This adds the widget stated by child to the top or left pane
  • Paned.add2(child) − This adds the widget stated by child to the bottom or right pane.
  • Paned.pack1(child, resize, shrink) − This adds the widget stated by child to the top or left pane with the parameters. If resize is True, child should be resized when the paned widget is resized. If shrink is True, child can be made smaller than its minimum size request.
  • Paned.pack2(child, resize, shrink) − This sets the position of the divider between the two panes.

Both types of Paned widgets emit the resulting signals −

accept-position

This is emitted whenpanedhas the focus causing the child widget with the focus to be activated.

cancel-position

This is emitted when theEsckey is pressed whilepanedhas the focus.

move-handle

This is emitted whenpanedhas the focus and the separator is moved.

Example

The resulting instance uses a gtk.Hpaned widget. In the left pane, a TreeView widget is added, and in the right pane, there is a TextView widget. When any row in TreeView is selected, it will emit row_activated signal which is connected to a callback function. The on_activated()function retrieves row's text and displays in the text view panel.

Observe the code –

The above code will generate the resulting output −

hpaned_widget_demo

All rights reserved © 2020 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

PyGTK Topics