Skip to content

API turboframe.ui.dialogs

rafageist edited this page Dec 4, 2026 · 4 revisions

turboframe.ui.dialogs

Source: turboframe/ui/dialogs.py. Generated from the code of TurboFrame 0.3.0 by tools/wiki_api.py.

Turbo Vision dialogs over the desktop: message boxes, the file and folder dialog, Find and Replace, Go to line, a one-line input with Browse.

  • DialogScreen runs one dialog modally: the desktop stays visible behind it (with Turbo Vision's shadows) and Esc cancels it. In a worker, await app.push_screen_wait(DialogScreen(dialog)) returns the command the dialog ended with.
  • TVDialog composes its controls inside the window content; Enter in an input line or a cluster presses the default button; what its input lines held joins their histories when it ends with anything but Cancel. An application's own dialogs subclass TVDialog and yield their controls from compose_content().

Contents

CM_BROWSE, CM_CHANGE_ALL, DialogScreen, FileDialog, FileList, GotoLineDialog, InputDialog, MessageBox, SearchDialog, TVDialog, browse_into, confirm, file_info, information, replace_prompt, shown_path

CM_BROWSE

10257

CM_CHANGE_ALL

10256

class DialogScreen

class DialogScreen(ModalScreen)
DialogScreen(dialog: Dialog)

Runs one Dialog modally over the desktop (no dimming, centred).

  • action_cancel() -> None

class FileDialog

class FileDialog(TVDialog)
FileDialog(title: str, directory: Path, *, name: str = '', pattern: str = '*', ok_label: str | None = None, folders: bool = False, buttons: Sequence[tuple[str, Command, str]] = (), select_name: bool | None = None)

Open / Save-as dialog, laid out as Turbo Pascal's: the name line (with its history), the files on cyan with their scroll bar, the buttons in a column at the right, and the pane below with the folder and the file under the bar (size, date). One column of names: today's are longer than 8.3.

Entries are .., folders (name/) and files matching the wildcard. chosen holds the resulting path once the dialog ends with OK. With folders it lists only folders and OK on . chooses the one shown.

  • show_info(index: int | None = None) -> None: The pane: the folder and its wildcard, then the entry under the bar.
  • entry_focused(index: int) -> None
  • entry_chosen(index: int) -> None
  • accept(text: str) -> None

class FileList

class FileList(WheelList, FilteredList, ListBox)
FileList(dialog: 'FileDialog', **kwargs)

The files of the folder, on Turbo Pascal's cyan: the chosen one white on green while the list has the focus, yellow when the focus is elsewhere. Reports the chosen entry and accepts on a double click.

  • focus_item(item: int) -> None
  • select_item(item: int) -> None

class GotoLineDialog

class GotoLineDialog(TVDialog)
GotoLineDialog(line: int)
  • valid(command: Command) -> bool

class InputDialog

class InputDialog(TVDialog)
InputDialog(title: str, label: str, text: str = '', *, hint: str = '', select: tuple[int, int] | None = None, browse: tuple[str, Path] | None = None, browse_folders: bool = False, allow_empty: bool = False, history: str | None = None)

One line of text (a name or a path): value holds it after OK.

With browse=(pattern, folder) a Browse button picks a file with the file dialog and writes its absolute path (relative paths stay welcome); with browse_folders, a folder.

  • title_text() -> str
  • valid(command: Command) -> bool

class MessageBox

class MessageBox(TVDialog)
MessageBox(title: str, text: str, buttons: list[tuple[str, Command, str]], *, width: int = 52, default: int = 0)

Text plus a row of buttons. Plain letters also press the buttons.

default is the button that Enter presses and that has the focus at first (the first one unless told otherwise: a question about running code starts on its safe answer).

class SearchDialog

class SearchDialog(TVDialog)
SearchDialog(*, replace: bool, query: str, replacement: str, options: SearchOptions)

Find (replace=False) or Replace dialog, laid out like Turbo Pascal's.

After OK / Change all: search_text, replacement and options hold the input.

class TVDialog

class TVDialog(Dialog)

Dialog whose children are composed inside the window content.

  • end_modal(command: Command) -> None

browse_into

async def browse_into(dialog: TVDialog, line: InputLine, title: str, pattern: str, start: Path, *, folders: bool = False) -> bool

File dialog over dialog; the chosen file's absolute path goes into line.

Call from a worker. start: the folder to begin in, unless line already names a file or folder that exists (relative paths are taken from start). folders: choose a folder, not a file.

confirm

def confirm(title: str, text: str) -> MessageBox

file_info

def file_info(path: Path, name: str, width: int) -> str

Turbo Pascal's second line: NAME size May 4, 2019 10:16pm.

information

def information(title: str, text: str) -> MessageBox

replace_prompt

def replace_prompt() -> MessageBox

shown_path

def shown_path(path: Path) -> str

path with the home folder as ~, as a shell shows it.

Clone this wiki locally