TTkSplitter🌢️

class TTkSplitter(*, border: bool = False, orientation: Direction = Direction.HORIZONTAL, **kwargs)[source]🌢️

Bases: TTkContainer

TTkSplitter:

A container widget that arranges child widgets with adjustable splitter bars.

Horizontal Splitter:
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β•₯─────────β•₯─────────┐
β”‚ Widget1 β•‘ Widget2 β•‘ Widget3 β”‚
β”‚         β•‘         β•‘         β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β•¨β”€β”€β”€β”€β”€β”€β”€β”€β”€β•¨β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Vertical Splitter:
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚          Widget 1                β”‚
β•žβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•‘
β”‚          Widget 2                β”‚
β•žβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•‘
β”‚          Widget 3                β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

The splitter allows users to redistribute space between child widgets by dragging the splitter bars. Widgets can have fixed or proportional sizes.

Demo: splitter.py (online)

import TermTk as ttk

root = ttk.TTk(layout=ttk.TTkGridLayout())

splitter = ttk.TTkSplitter(parent=root, orientation=ttk.TTkK.HORIZONTAL)
splitter.addWidget(ttk.TTkTestWidgetSizes(border=True), size=20)
splitter.addWidget(ttk.TTkTestWidgetSizes(border=True))
splitter.addWidget(ttk.TTkTestWidgetSizes(border=True), size=30)

root.mainloop()

Initialize the splitter

param border:

Draw a border around the splitter, defaults to False

type border:

bool, optional

param orientation:

Splitter orientation (TTkK.Direction.HORIZONTAL or TTkK.Direction.VERTICAL), defaults to TTkK.Direction.HORIZONTAL

type orientation:

TTkK.Direction, optional

TTkContainer’s inherited init params:

Parameters:
  • layout (TermTk.TTkLayouts) – the layout of this widget, optional, defaults to TTkLayout

  • padding (TTkPadding) – the padding (top, bottom, left, right) of the widget, defaults to (0,0,0,0)

  • paddingTop (int) – the Top padding, override Top padding if already defined, optional, default=0 if padding is not defined

  • paddingBottom (int) – the Bottom padding, override Bottom padding if already defined, optional, default=0 if padding is not defined

  • paddingLeft (int) – the Left padding, override Left padding if already defined, optional, default=0 if padding is not defined

  • paddingRight (int) – the Right padding, override Right padding if already defined, optional, default=0 if padding is not defined

  • forwardStyle (bool) – [Experimental] any change of style will reflect the children, defaults to False

TTkWidget’s inherited init params:

Parameters:
  • name (str, optional) – the name of the widget, defaults to β€œβ€

  • parent (TTkWidget, optional) – the parent widget, defaults to None

  • x (int, optional) – the x position, defaults to 0

  • y (int, optional) – the y position, defaults to 0

  • pos ((int,int), optional) – the [x,y] position (override the previously defined x, y), defaults to (x,y)

  • width (int, optional) – the width of the widget, defaults to 0

  • height (int, optional) – the height of the widget, defaults to 0

  • size ((int,int), optional) – the size [width, height] of the widget (override the previously defined sizes), defaults to (width,height)

  • maxWidth (int, optional) – the maxWidth of the widget, defaults to 0x10000

  • maxHeight (int, optional) – the maxHeight of the widget, defaults to 0x10000

  • maxSize ((int,int), optional) – the max [width,height] of the widget, optional, defaults to (maxWidth,maxHeight)

  • minWidth (int, optional) – the minWidth of the widget, defaults to 0

  • minHeight (int, optional) – the minHeight of the widget, defaults to 0

  • minSize ((int,int), optional) – the minSize [width,height] of the widget, optional, defaults to (minWidth,minHeight)

  • toolTip (TTkString, optional) – This property holds the widget’s tooltip, defaults to β€˜β€™

  • style (dict, optional) – this field hold the custom style to be used by this widget

  • addStyle (dict, optional) – this field is required to override/merge the new style on top of the current one, useful if only few params need to be changed

  • visible (bool, optional) – the visibility, optional, defaults to True

  • enabled (bool, optional) – the ability to handle input events, optional, defaults to True

TMouseEvents’s inherited init params:

Initialize self. See help(type(self)) for accurate signature.

TDragEvents’s inherited init params:

Initialize self. See help(type(self)) for accurate signature.

Style🌢️

classStyle = {
            'default':     {'glyphs' : {
                                TTkK.VERTICAL   : ('β•ž','═','β•‘'),
                                TTkK.HORIZONTAL : ('β•₯','β•‘','╨') },
                            'color': TTkColor.fgbg("#dddddd","#222222"),
                            'borderColor': TTkColor.RST },
            'disabled':    {'color': TTkColor.fg('#888888'),
                            'borderColor':TTkColor.fg('#888888')},
            'focus':       {'color': TTkColor.fgbg("#ffddff","#222222"),
                            'borderColor': TTkColor.fg("#ffffaa")}
        }

Signals🌢️

closed

This signal is emitted whenever the widget is closed

currentStyleChanged

This signal is emitted whenever the widget stye change

focusChanged

This signal is emitted whenever the focus status change i.e. with the setFocus() or clearFocus() methods.

sizeChanged

This signal is emitted whenever the widget size change

Slots🌢️

Slots Inherited from: TTkContainer

hide()

hide the widget

show()

show the widget

Slots Inherited from: TTkWidget

close()

Close (Destroy/Remove) the widget

hide()

hide the widget

lowerWidget()

Lower the Widget below its relatives

raiseWidget([raiseParent])

Raise the Widget above its relatives

setDisabled([disabled])

This property holds whether the widget is disnabled

setEnabled([enabled])

This property holds whether the widget is enabled

setFocus()

Focus the widget

setVisible(visible)

Set the visibility status of this widget

show()

show the widget

update([repaint,Β updateLayout,Β updateParent])

Notify the drawing routine that the widget changed and needs to draw its new content.

Members🌢️

closed: pyTTkSignal🌢️

This signal is emitted whenever the widget is closed

Parameters:

widget (TTkWidget) – the widget closed (=self)

currentStyleChanged: pyTTkSignal🌢️

This signal is emitted whenever the widget stye change

Parameters:

style (dict) – the new style applied

focusChanged: pyTTkSignal🌢️

This signal is emitted whenever the focus status change i.e. with the setFocus() or clearFocus() methods

Parameters:

status (bool) – the curent focus status

sizeChanged: pyTTkSignal🌢️

This signal is emitted whenever the widget size change

Parameters:
  • width (int) – the new widget width

  • height (int) – the new widget height

Methods🌢️

addItem(item: TTkLayout, size: int | None = None, title: str | TTkString | None = None) None[source]🌢️

Add a layout to the end of the splitter

Parameters:
  • item (TTkLayout) – The layout to add

  • size (int, optional) – Fixed size for the item in characters, defaults to None (proportional)

  • title (str, TTkString, optional) – Optional title for the item, defaults to None

border() bool[source]🌢️

Get the current border state

Returns:

True if border is visible, False otherwise

Return type:

bool

clean() None[source]🌢️

Remove all widgets and items from the splitter

count() int[source]🌢️

Get the number of items in the splitter

Returns:

The count of widgets/items

Return type:

int

indexOf(widget: TTkWidget | TTkLayout) int[source]🌢️

Get the index of a widget or layout in the splitter

Parameters:

widget (TTkWidget or TTkLayout) – The widget or layout to find

Returns:

The index of the item

Return type:

int

insertItem(index: int, item: TTkLayout, size: int | None = None, title: str | TTkString | None = None) None[source]🌢️

Insert a layout at the specified index

Parameters:
  • index (int) – The index to insert at

  • item (TTkLayout) – The layout to insert

  • size (int, optional) – Fixed size for the item in characters, defaults to None (proportional)

  • title (str, TTkString, optional) – Optional title for the item, defaults to None

insertWidget(index: int, widget: TTkWidget, size: int | None = None, title: str | TTkString | None = None) None[source]🌢️

Insert a widget at the specified index

Parameters:
  • index (int) – The index to insert at

  • widget (TTkWidget) – The widget to insert

  • size (int, optional) – Fixed size for the widget in characters, defaults to None (proportional)

  • title (str, TTkString, optional) – Optional title for the widget, defaults to None

orientation() Direction[source]🌢️

Get the current splitter orientation

Returns:

The orientation (HORIZONTAL or VERTICAL)

Return type:

TTkK.Direction

removeItem(item: TTkLayout) None[source]🌢️

Remove a layout from the splitter

Parameters:

item (TTkLayout) – The layout to remove

replaceItem(index: int, item: TTkLayout, title: str | TTkString | None = None) None[source]🌢️

Replace the layout at the specified index

Parameters:
  • index (int) – The index to replace at

  • item (TTkLayout) – The new layout

  • title (str, TTkString, optional) – Optional title for the item, defaults to None

replaceWidget(index: int, widget: TTkWidget, title: str | None = None) None[source]🌢️

Replace the widget at the specified index

Parameters:
  • index (int) – The index to replace at

  • widget (TTkWidget) – The new widget

  • title (str, TTkString, optional) – Optional title for the widget, defaults to None

setBorder(border: bool) None[source]🌢️

Set whether to draw a border around the splitter

Parameters:

border (bool) – True to show border, False to hide

setOrientation(orientation: Direction) None[source]🌢️

Set the splitter orientation

Parameters:

orientation (TTkK.Direction) – The new orientation (HORIZONTAL or VERTICAL)

setSizes(sizes: List[int | None]) None[source]🌢️

Set the sizes for all widgets in the splitter

Parameters:

sizes (list of int or None) – List of sizes in characters (None for proportional sizing)

widget(index: int) TTkWidget | TTkLayout[source]🌢️

Get the widget or layout at the specified index

Parameters:

index (int) – The index of the item

Returns:

The widget or layout at the index

Return type:

TTkWidget or TTkLayout

Methods Inherited from: TTkContainer

addWidget(widget[,Β size,Β title])

Add a widget to the end of the splitter

getPadding()

Retrieve the TTkContainer's paddings sizes as shown in Layout Topology

getWidgetByName(name)

Return the widget from its name.

hide()

hide the widget

keyEvent(evt)

This event handler, can be reimplemented in a subclass to receive key events for the widget.

layout()

Get the Layout

maximumHeight()

Get the maximum height allowed for the splitter

maximumWidth()

Get the maximum width allowed for the splitter

minimumHeight()

Get the minimum height required for the splitter

minimumWidth()

Get the minimum width required for the splitter

paintChildCanvas()

removeWidget(widget)

Remove a widget from the splitter

rootLayout()

This is a root layout mainly used to place items that are not supposed to be inside the main layout (i.e. the menu elements).

setCurrentStyle(*args,Β **kwargs)

setLayout(layout)

Set the Layout used by this widget to place all the child widgets.

setPadding(top,Β bottom,Β left,Β right)

Set the TTkContainer's paddings sizes as shown in Layout Topology

show()

show the widget

update([repaint,Β updateLayout,Β updateParent])

Notify the drawing routine that the widget changed and needs to draw its new content.

Methods Inherited from: TTkWidget

clearFocus()

Remove the Focus state of this widget

close()

Close (Destroy/Remove) the widget

currentStyle()

disableWidgetCursor([disable])

enableWidgetCursor([enable])

focusInEvent()

focusOutEvent()

focusPolicy()

geometry()

getCanvas()

getPixmap()

Convenience function which return a pixmap representing the current widget status

getWidgetByName(name)

Return the widget from its name.

hasFocus()

This property holds the focus status of this widget

height()

hide()

hide the widget

isEnabled()

This property holds whether the widget is enabled

isEntered()

isVisible()

Retrieve the visibility status of this widget

isVisibleAndParent()

lowerWidget()

Lower the Widget below its relatives

maxDimension(orientation)

maximumHeight()

Get the maximum height allowed for the splitter

maximumSize()

maximumWidth()

Get the maximum width allowed for the splitter

mergeStyle(style)

minDimension(orientation)

minimumHeight()

Get the minimum height required for the splitter

minimumSize()

minimumWidth()

Get the minimum width required for the splitter

mouseEvent(evt)

move(x,Β y)

Move the widget

moveEvent(x,Β y)

Convenience function, Event Callback triggered after a successful move

name()

paintChildCanvas()

paintEvent(canvas)

Paint Event callback, this need to be overridden in the widget.

parentWidget()

pasteEvent(txt)

Callback triggered when a paste event is forwarded to this widget.

pos()

raiseWidget([raiseParent])

Raise the Widget above its relatives

resize(width,Β height)

Resize the widget

resizeEvent(w,Β h)

Handle resize events and update widget geometries

setCurrentStyle(*args,Β **kwargs)

setDefaultSize(arg,Β width,Β height)

setDisabled([disabled])

This property holds whether the widget is disnabled

setDropEventProxy(proxy)

setEnabled([enabled])

This property holds whether the widget is enabled

setFocus()

Focus the widget

setFocusPolicy(policy)

This property holds the way the widget accepts keyboard focus

setGeometry(x,Β y,Β width,Β height)

Resize and move the widget

setMaximumHeight(maxh)

setMaximumSize(maxw,Β maxh)

setMaximumWidth(maxw)

setMinimumHeight(minh)

setMinimumSize(minw,Β minh)

setMinimumWidth(minw)

setName(name)

Set the name of this Instance

setParent(parent)

setStyle([style])

setToolTip(toolTip)

setVisible(visible)

Set the visibility status of this widget

setWidgetCursor([pos,Β type])

show()

show the widget

size()

style()

toolTip()

update([repaint,Β updateLayout,Β updateParent])

Notify the drawing routine that the widget changed and needs to draw its new content.

widgetItem()

width()

x()

y()

Methods Inherited from: TMouseEvents

enterEvent(evt)

This event handler, can be reimplemented in a subclass to receive mouse enter events for the widget.

leaveEvent(evt)

This event handler, can be reimplemented in a subclass to receive mouse leave events for the widget.

mouseDoubleClickEvent(evt)

This event handler, can be reimplemented in a subclass to receive mouse click events for the widget.

mouseDragEvent(evt)

This event handler, can be reimplemented in a subclass to receive mouse drag events for the widget.

mouseMoveEvent(evt)

This event handler, can be reimplemented in a subclass to receive mouse move events for the widget.

mousePressEvent(evt)

This event handler, can be reimplemented in a subclass to receive mouse press events for the widget.

mouseReleaseEvent(evt)

This event handler, can be reimplemented in a subclass to receive mouse release events for the widget.

mouseTapEvent(evt)

This event handler, can be reimplemented in a subclass to receive mouse click events for the widget.

wheelEvent(evt)

This event handler, can be reimplemented in a subclass to receive mouse wheel events for the widget.

Methods Inherited from: TKeyEvents

keyEvent(evt)

This event handler, can be reimplemented in a subclass to receive key events for the widget.

Methods Inherited from: TDragEvents

dragEnterEvent(evt)

This event handler, can be reimplemented in a subclass to receive drag events for the widget.

dragLeaveEvent(evt)

This event handler, can be reimplemented in a subclass to receive drag events for the widget.

dragMoveEvent(evt)

This event handler, can be reimplemented in a subclass to receive drag events for the widget.

dropEvent(evt)

This event handler, can be reimplemented in a subclass to receive drag events for the widget.

TTkSplitter Attributes🌢️

classStyle