TTkFileTreeWidget🌶️

class TTkFileTreeWidget(path: str = '.', **kwargs)[source]🌶️

Bases: TTkTreeWidget

A TTkFileTreeWidget provide a widget that allow users to select files or directories.

The TTkFileTree class enables a user to traverse the file system in order to select one or many files or a directory.

Name                                 ▼╿Size         ╿Type        ╿Date Modified       ╿▲
 ∙ Makefile                           │      3.80 KB│File        │2024-11-04 20:37:22 │┊
 ∙ README.md                          │      7.50 KB│File        │2024-06-08 15:34:09 │┊
 - TermTk/                            │             │Folder      │2024-06-08 15:34:12 │┊
   + TTkAbstract/                     │             │Folder      │2024-11-04 20:37:22 │▓
   + TTkCore/                         │             │Folder      │2024-11-04 20:37:22 │▓
   + TTkCrossTools/                   │             │Folder      │2024-06-08 15:34:12 │▓
   + TTkGui/                          │             │Folder      │2024-11-04 20:37:22 │▓
   + TTkLayouts/                      │             │Folder      │2024-11-04 20:37:22 │▓
   - TTkTemplates/                    │             │Folder      │2024-11-04 20:37:22 │┊
     ∙ __init__.py                    │    120 bytes│File        │2024-11-04 20:37:22 │┊
     + __pycache__/                   │             │Folder      │2024-11-05 08:47:38 │┊
     ∙ dragevents.py                  │      2.79 KB│File        │2024-11-04 20:37:22 │┊
     ∙ keyevents.py                   │      2.52 KB│File        │2024-11-04 20:37:22 │┊
     ∙ mouseevents.py                 │      5.16 KB│File        │2024-11-04 20:37:22 │┊
   + TTkTestWidgets/                  │             │Folder      │2024-11-04 20:37:22 │┊
   + TTkTheme/                        │             │Folder      │2024-06-08 15:34:12 │┊
   + TTkTypes/                        │             │Folder      │2024-06-08 15:34:12 │┊
   + TTkUiTools/                      │             │Folder      │2024-11-04 20:37:22 │┊
   + TTkWidgets/                      │             │Folder      │2024-11-04 20:37:22 │┊
   ∙ __init__.py                      │    327 bytes│File        │2024-11-04 19:56:26 │▼

Quickstart:

import TermTk as ttk

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

fileTree = ttk.TTkFileTree(parent=root, path='.')

root.mainloop()
Parameters:

path (str, optional) – the starting path opened by the TTkFileTreeWidget, defaults to the current path (‘.’)

TTkTreeWidget’s inherited init params:

Parameters:

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.

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

viewChanged

This signal is emitted whenever there is a change in the view content topology (size,pos)

viewMovedTo

This signal is emitted when the view content move to a new position (x,y),

viewSizeChanged

This signal is emitted when the view content size changed

Slots🌶️

Slots Inherited from: TTkTreeWidget

collapseAll()

Collapse all collapsable items.

expandAll()

Expands all expandable items.

Slots Inherited from: TTkAbstractScrollView

viewMoveTo(x, y)

This method is used to set the vertical and horizontal offsets of the TTkAbstractScrollViewInterface

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

viewChanged: pyTTkSignal🌶️

This signal is emitted whenever there is a change in the view content topology (size,pos)

Note

This signal must be implemented in any implementation of TTkAbstractScrollView to notify that the view content boudaries changed

viewMovedTo: pyTTkSignal🌶️

This signal is emitted when the view content move to a new position (x,y),

Parameters:
  • x (int) – the new horizontal offset

  • y (int) – the new vertical offset

viewSizeChanged: pyTTkSignal🌶️

This signal is emitted when the view content size changed

Parameters:
  • width (int) – the new width

  • height (int) – the new heighht

Methods🌶️

getOpenPath()[source]🌶️
openPath(path)[source]🌶️
setFilter(filter)[source]🌶️

Methods Inherited from: TTkTreeWidget

addTopLevelItem(item)

Appends the item as a top-level item in the widget.

addTopLevelItems(items)

Appends the list of items as a top-level items in the widget.

clear()

Clears the tree widget by removing all of its items and selections.

collapseAll()

Collapse all collapsable items.

columnWidth(column)

This property hold the width of the column requested

dragDropMode()

expandAll()

Expands all expandable items.

focusOutEvent()

indexOfTopLevelItem(item)

Returns the index of the given top-level item, or -1 if the item cannot be found.

invisibleRootItem()

Returns the tree widget's invisible root item.

isSortingEnabled()

This property holds whether sorting is enabled

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.

mousePressEvent(evt)

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

paintEvent(canvas)

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

resizeColumnToContents(column)

rwsize the width of the column requestedto its content

selectedItems()

Returns a list of all selected non-hidden items.

selectionMode()

setColumnWidth(column, width)

Set the width of the column requested

setDragDropMode(dndMode)

setHeaderLabels(labels)

Adds a column in the header for each item in the labels list, and sets the label for each column.

setSelectionMode(mode)

Sets the current selection model to the given selectionModel.

setSortingEnabled(enabled)

This property holds whether sorting is enabled

sortColumn()

Returns the column used to sort the contents of the widget.

sortItems(col, order)

Sorts the items in the widget in the specified order by the values in the given column.

takeTopLevelItem(index)

Removes the top-level item at the given index in the tree and returns it, otherwise returns None;

topLevelItem(index)

Returns the top level item at the given index, or None if the item does not exist.

viewFullAreaSize()

This method returns the full widget area size of the TTkAbstractScrollViewInterface implementation.

Methods Inherited from: TTkAbstractScrollView

getViewOffsets()

Retrieve the vertical and horizontal offsets of the TTkAbstractScrollViewInterface

resizeEvent(w, h)

Convenience function, Event Callback triggered after a successful resize

setPadding(top, bottom, left, right)

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

update([repaint, updateLayout, updateParent])

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

viewDisplayedSize()

This method returns the displayed size of the TTkAbstractScrollViewInterface implementation.

viewFullAreaSize()

This method returns the full widget area size of the TTkAbstractScrollViewInterface implementation.

viewMoveTo(x, y)

This method is used to set the vertical and horizontal offsets of the TTkAbstractScrollViewInterface

wheelEvent(evt)

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

Methods Inherited from: TTkContainer

addWidget(widget)

getPadding()

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

getWidgetByName(name)

Return the widget from its name.

hide()

hide the widget

layout()

Get the Layout

maximumHeight()

maximumWidth()

minimumHeight()

minimumWidth()

paintChildCanvas()

removeWidget(widget)

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()

maximumSize()

maximumWidth()

mergeStyle(style)

minDimension(orientation)

minimumHeight()

minimumSize()

minimumWidth()

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)

Convenience function, Event Callback triggered after a successful resize

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.

TTkFileTreeWidget Attributes🌶️

classStyle

fileActivated

This signal is emitted when a file is activated

fileClicked

This signal is emitted when a file is clicked

fileDoubleClicked

This signal is emitted when a file is doubleclicked

folderActivated

This signal is emitted when a fiilder is activated

folderClicked

This signal is emitted when a folder is clicked

folderDoubleClicked

This signal is emitted when a folder is doubleclicked

itemActivated

This signal is emitted when the user activates an item by double-clicking or pressing a special key (e.g., Enter).

itemChanged

This signal is emitted when the contents of the column in the specified item changes.

itemClicked

This signal is emitted when the user clicks inside the widget.

itemCollapsed

This signal is emitted when the specified item is collapsed so that none of its children are displayed.

itemDoubleClicked

This signal is emitted when the user double clicks inside the widget.

itemExpanded

This signal is emitted when the specified item is expanded so that all of its children are displayed.