TermTk.TTkWidgets.TTkPickers.filepicker

TTkFileDialogPicker

class TTkFileDialogPicker(*args, **kwargs)[source]

TTkFileDialogPicker:

╔═════════════════════════════════════════════════════════════════════════╗
║ Pick Something                                                    [^][x]║
╟─────────────────────────────────────────────────────────────────────────╢
║Look in:      [/home/one/github/Varie/pyTermTk                ^][<][>][^]║
║┌──────────╥────────────────────────────────────────────────────────────┐║
║│∙ Computer║Name               ▼╿Size     ╿Type   ╿Date Modified      ╿▲│║
║│∙ Home    ║   - TTkUiTools/    │         │Folder │2023-04-18 16:38:03│┊│║
║│          ║     ∙ __init__.py  │ 75 bytes│File   │2023-04-18 16:38:03│┊│║
║│          ║     + __pycache__/ │         │Folder │2023-04-18 23:54:33│┊│║
║│          ║     + properties/  │         │Folder │2023-04-18 16:38:03│┊│║
║│          ║     ∙ uiloader.py  │  7.96 KB│File   │2023-04-18 16:38:03│┊│║
║│          ║     ∙ uiproperties.│  2.39 KB│File   │2023-04-18 16:38:03│▓│║
║│          ║   + TTkWidgets/    │         │Folder │2023-04-18 16:38:03│▓│║
║│          ║   ∙ __init__.py    │272 bytes│File   │2023-04-18 16:38:03│▓│║
║│          ║   + __pycache__/   │         │Folder │2023-04-18 23:54:33│▓│║
║│          ║ + demo/            │         │Folder │2023-04-18 16:38:03│┊│║
║│          ║ + docs/            │         │Folder │2023-04-27 22:16:30│┊│║
║│          ║ + experiments/     │         │Folder │2023-04-27 13:10:29│┊│║
║│          ║ ∙ pippo.py         │  1.72 KB│File   │2023-04-26 21:01:53│┊│║
║│          ║ ∙ profiler.bin     │256.71 KB│File   │2023-04-10 06:01:03│▼│║
║└──────────╨────────────────────────────────────────────────────────────┘║
║File name:    /home/one/github/Varie/pyTermTk/TermTk/TTkUiTools/ [ Open ]║
║Files of type:[All Files (*)                                   ^][Cancel]║
╚═════════════════════════════════════════════════════════════════════════╝

Demo: formwidgets.py (Try Online)

ttkdesigner Tutorial

Parameters
  • path (str, optional) – the current path used in the file dialog, defaults to “.”

  • caption (str, optional) – the title of the dialog, defaults to “File Dialog

  • filter (str, optional) –

    List of filters separated with “;;”, defaults to “All Files (*)”.

    Example:

    filter="Images (*.png *.xpm *.jpg);;Text files (*.txt);;XML files (*.xml)"
    

  • fileMode (FileMode, optional) – The file mode defines the number and type of items that the user is expected to select in the dialog, defaults to Anyfile

  • acceptMode (AcceptMode, optional) – TThe action mode defines whether the dialog is for opening or saving files, defaults to AcceptOpen

Signals

signal pathPicked(pathName)

This signal is emitted whenever any path is picked (Files/Dir)

Parameters

pathName (str) – the name of the path

signal filePicked(fileName)

This signal is emitted whenever any file is picked

Parameters

fileName (str) – the name of the file

signal folderPicked(dirName)

This signal is emitted whenever any folder is picked

Parameters

dirName (str) – the name of the folder

addWidget(widget)

Warning

Method Deprecated,

use TTkWidget -> layout -> addWidget

i.e.

parentWidget.layout().addWidget(childWidget)
border()
close()
dragEnterEvent(evt) bool

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

Note

Reimplement this function to handle this event

Parameters

evt (TTkDropEvent) – The drop event

Returns

True if the event has been handled

Return type

bool

dragLeaveEvent(evt) bool

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

Note

Reimplement this function to handle this event

Parameters

evt (TTkDropEvent) – The drop event

Returns

True if the event has been handled

Return type

bool

dragMoveEvent(evt) bool

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

Note

Reimplement this function to handle this event

Parameters

evt (TTkDropEvent) – The drop event

Returns

True if the event has been handled

Return type

bool

dropEvent(evt) bool

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

Note

Reimplement this function to handle this event

Parameters

evt (TTkDropEvent) – The drop event

Returns

True if the event has been handled

Return type

bool

enterEvent(evt) bool

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

Note

Reimplement this function to handle this event

Parameters

evt (TTkMouseEvent) – The mouse event

Returns

True if the event has been handled

Return type

bool

getPadding() -> (<class 'int'>, <class 'int'>, <class 'int'>, <class 'int'>)

Retrieve the widget padding sizes

Returns

list[top, bottom, left, right]: the 4 padding sizes

hide()
keyEvent(evt) bool

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

Note

Reimplement this function to handle this event

Parameters

evt (TTkKeyEvent) – The keyboard event

Returns

True if the event has been handled

Return type

bool

keyPressEvent(evt) bool

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

Note

Reimplement this function to handle this event

Parameters

evt (TTkKeyEvent) – The keyboard event

Returns

True if the event has been handled

Return type

bool

keyReleaseEvent(evt) bool

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

Note

Reimplement this function to handle this event

Parameters

evt (TTkKeyEvent) – The keyboard event

Returns

True if the event has been handled

Return type

bool

layout()

Get the layout

Returns

The layout used

Return type

TTkLayout or derived

leaveEvent(evt) bool

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

Note

Reimplement this function to handle this event

Parameters

evt (TTkMouseEvent) – The mouse event

Returns

True if the event has been handled

Return type

bool

lowerWidget()
mouseDoubleClickEvent(evt) bool

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

Note

Reimplement this function to handle this event

Parameters

evt (TTkMouseEvent) – The mouse event

Returns

True if the event has been handled

Return type

bool

mouseDragEvent(evt)

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

Note

Reimplement this function to handle this event

Parameters

evt (TTkMouseEvent) – The mouse event

Returns

True if the event has been handled

Return type

bool

mouseEvent(evt)

Caution

Don’t touch this!

mouseMoveEvent(evt) bool

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

Note

Reimplement this function to handle this event

Parameters

evt (TTkMouseEvent) – The mouse event

Returns

True if the event has been handled

Return type

bool

mousePressEvent(evt)

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

Note

Reimplement this function to handle this event

Parameters

evt (TTkMouseEvent) – The mouse event

Returns

True if the event has been handled

Return type

bool

mouseReleaseEvent(evt) bool

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

Note

Reimplement this function to handle this event

Parameters

evt (TTkMouseEvent) – The mouse event

Returns

True if the event has been handled

Return type

bool

mouseTapEvent(evt) bool

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

Note

Reimplement this function to handle this event

Parameters

evt (TTkMouseEvent) – The mouse event

Returns

True if the event has been handled

Return type

bool

move(x: int, y: int)

Move the widget

Parameters
  • x (int) – x position

  • y (int) – y position

moveEvent(x: int, y: int)

Event Callback triggered after a successful move

name() str
newMenubarTop()

Warning

Method Deprecated,

use setMenuBar instead

i.e.

menuBar = TTkMenuBarLayout()
frame.setMenuBar(menuBar)
menuBar.addMenu("File")
paintChildCanvas()

Caution

Don’t touch this!

paintEvent(canvas)

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

raiseWidget(raiseParent=True)
removeWidget(widget)

Warning

Method Deprecated,

use TTkWidget -> layout -> removeWidget

i.e.

parentWidget.layout().removeWidget(childWidget)
resize(w: int, h: int)

Resize the widget

Parameters
  • w (int) – the new width

  • h (int) – the new height

resizeEvent(w, h)

Event Callback triggered after a successful resize

setBorder(border)
setDisabled(disabled=True)
setEnabled(enabled: bool = True)
setFocus()
setGeometry(x: int, y: int, w: int, h: int)

Resize and move the widget

Parameters
  • x (int) – x position

  • y (int) – y position

  • w (int) – the new width

  • h (int) – the new height

setName(name: str)
setPadding(top: int, bottom: int, left: int, right: int)

Set the padding of the widget

Parameters
  • top (int) – top padding

  • bottom (int) – bottom padding

  • left (int) – left padding

  • right (int) – right padding

setTitle(title)
setVisible(visible: bool)
setWindowFlag(flag)
show()
title()
wheelEvent(evt) bool

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

Note

Reimplement this function to handle this event

Parameters

evt (TTkMouseEvent) – The mouse event

Returns

True if the event has been handled

Return type

bool

windowFlag()

TTkFileButtonPicker

class TTkFileButtonPicker(*args, **kwargs)[source]

TTkFileButtonPicker:

┌────┐
│File│
╘════╛

╔═════════════════════════════════════════════════════════════════════════╗
║ Pick Something                                                    [^][x]║
╟─────────────────────────────────────────────────────────────────────────╢
║Look in:      [/home/one/github/Varie/pyTermTk                ^][<][>][^]║
║┌──────────╥────────────────────────────────────────────────────────────┐║
║│∙ Computer║Name               ▼╿Size     ╿Type   ╿Date Modified      ╿▲│║
║│∙ Home    ║   - TTkUiTools/    │         │Folder │2023-04-18 16:38:03│┊│║
║│          ║     ∙ __init__.py  │ 75 bytes│File   │2023-04-18 16:38:03│┊│║
║│          ║     + __pycache__/ │         │Folder │2023-04-18 23:54:33│┊│║
║│          ║     + properties/  │         │Folder │2023-04-18 16:38:03│┊│║
║│          ║     ∙ uiloader.py  │  7.96 KB│File   │2023-04-18 16:38:03│┊│║
║│          ║     ∙ uiproperties.│  2.39 KB│File   │2023-04-18 16:38:03│▓│║
║│          ║   + TTkWidgets/    │         │Folder │2023-04-18 16:38:03│▓│║
║│          ║   ∙ __init__.py    │272 bytes│File   │2023-04-18 16:38:03│▓│║
║│          ║   + __pycache__/   │         │Folder │2023-04-18 23:54:33│▓│║
║│          ║ + demo/            │         │Folder │2023-04-18 16:38:03│┊│║
║│          ║ + docs/            │         │Folder │2023-04-27 22:16:30│┊│║
║│          ║ + experiments/     │         │Folder │2023-04-27 13:10:29│┊│║
║│          ║ ∙ pippo.py         │  1.72 KB│File   │2023-04-26 21:01:53│┊│║
║│          ║ ∙ profiler.bin     │256.71 KB│File   │2023-04-10 06:01:03│▼│║
║└──────────╨────────────────────────────────────────────────────────────┘║
║File name:    /home/one/github/Varie/pyTermTk/TermTk/TTkUiTools/ [ Open ]║
║Files of type:[All Files (*)                                   ^][Cancel]║
╚═════════════════════════════════════════════════════════════════════════╝

Demo: formwidgets.py (Try Online)

ttkdesigner Tutorial

Parameters
  • path (str, optional) – the current path used in the file dialog, defaults to “.”

  • caption (str, optional) – the title of the dialog, defaults to “File Dialog

  • filter (str, optional) –

    List of filters separated with “;;”, defaults to “All Files (*)”.

    Example:

    filter="Images (*.png *.xpm *.jpg);;Text files (*.txt);;XML files (*.xml)"
    

  • fileMode (FileMode, optional) – The file mode defines the number and type of items that the user is expected to select in the dialog, defaults to Anyfile

  • acceptMode (AcceptMode, optional) – TThe action mode defines whether the dialog is for opening or saving files, defaults to AcceptOpen

Signals

signal pathPicked(pathName)

This signal is emitted whenever any path is picked (Files/Dir)

Parameters

pathName (str) – the name of the path

signal filePicked(fileName)

This signal is emitted whenever any file is picked

Parameters

fileName (str) – the name of the file

signal folderPicked(dirName)

This signal is emitted whenever any folder is picked

Parameters

dirName (str) – the name of the folder

close()
dragEnterEvent(evt) bool

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

Note

Reimplement this function to handle this event

Parameters

evt (TTkDropEvent) – The drop event

Returns

True if the event has been handled

Return type

bool

dragLeaveEvent(evt) bool

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

Note

Reimplement this function to handle this event

Parameters

evt (TTkDropEvent) – The drop event

Returns

True if the event has been handled

Return type

bool

dragMoveEvent(evt) bool

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

Note

Reimplement this function to handle this event

Parameters

evt (TTkDropEvent) – The drop event

Returns

True if the event has been handled

Return type

bool

dropEvent(evt) bool

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

Note

Reimplement this function to handle this event

Parameters

evt (TTkDropEvent) – The drop event

Returns

True if the event has been handled

Return type

bool

enterEvent(evt) bool

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

Note

Reimplement this function to handle this event

Parameters

evt (TTkMouseEvent) – The mouse event

Returns

True if the event has been handled

Return type

bool

hide()
isCheckable()

This property holds whether the button is checkable

Returns

bool

isChecked()

This property holds whether the button is checked

Only checkable buttons can be checked. By default, the button is unchecked.

Returns

bool

keyEvent(evt)

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

Note

Reimplement this function to handle this event

Parameters

evt (TTkKeyEvent) – The keyboard event

Returns

True if the event has been handled

Return type

bool

keyPressEvent(evt) bool

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

Note

Reimplement this function to handle this event

Parameters

evt (TTkKeyEvent) – The keyboard event

Returns

True if the event has been handled

Return type

bool

keyReleaseEvent(evt) bool

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

Note

Reimplement this function to handle this event

Parameters

evt (TTkKeyEvent) – The keyboard event

Returns

True if the event has been handled

Return type

bool

leaveEvent(evt) bool

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

Note

Reimplement this function to handle this event

Parameters

evt (TTkMouseEvent) – The mouse event

Returns

True if the event has been handled

Return type

bool

lowerWidget()
mouseDoubleClickEvent(evt) bool

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

Note

Reimplement this function to handle this event

Parameters

evt (TTkMouseEvent) – The mouse event

Returns

True if the event has been handled

Return type

bool

mouseDragEvent(evt) bool

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

Note

Reimplement this function to handle this event

Parameters

evt (TTkMouseEvent) – The mouse event

Returns

True if the event has been handled

Return type

bool

mouseEvent(evt)

Caution

Don’t touch this!

mouseMoveEvent(evt) bool

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

Note

Reimplement this function to handle this event

Parameters

evt (TTkMouseEvent) – The mouse event

Returns

True if the event has been handled

Return type

bool

mousePressEvent(evt)

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

Note

Reimplement this function to handle this event

Parameters

evt (TTkMouseEvent) – The mouse event

Returns

True if the event has been handled

Return type

bool

mouseReleaseEvent(evt)

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

Note

Reimplement this function to handle this event

Parameters

evt (TTkMouseEvent) – The mouse event

Returns

True if the event has been handled

Return type

bool

mouseTapEvent(evt) bool

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

Note

Reimplement this function to handle this event

Parameters

evt (TTkMouseEvent) – The mouse event

Returns

True if the event has been handled

Return type

bool

move(x: int, y: int)

Move the widget

Parameters
  • x (int) – x position

  • y (int) – y position

moveEvent(x: int, y: int)

Event Callback triggered after a successful move

name() str
paintEvent(canvas)

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

raiseWidget(raiseParent=True)
resize(w: int, h: int)

Resize the widget

Parameters
  • w (int) – the new width

  • h (int) – the new height

resizeEvent(w: int, h: int)

Event Callback triggered after a successful resize

setCheckable(ch)

Enable/Disable the checkable property

Parameters

ch (bool) – Checkable

setChecked(ch)

Set the checked status

Parameters

ch (bool) – Checked

setDisabled(disabled=True)
setEnabled(enabled: bool = True)
setFocus()
setGeometry(x: int, y: int, w: int, h: int)

Resize and move the widget

Parameters
  • x (int) – x position

  • y (int) – y position

  • w (int) – the new width

  • h (int) – the new height

setName(name: str)
setText(text)

This property holds the text shown on the button

Parameters

text (TTkString) –

setVisible(visible: bool)
show()
text()

This property holds the text shown on the button

Returns

TTkString

wheelEvent(evt) bool

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

Note

Reimplement this function to handle this event

Parameters

evt (TTkMouseEvent) – The mouse event

Returns

True if the event has been handled

Return type

bool