Repository navigation
Windows and Lists
| Use it for | the windows on your desktop, and lists you filter by typing |
| Import |
from turboframe.ui.windows import TVWindow, LocationsWindow, MessageItem, MessageList; from turboframe.ui.filter import Filtered
|
| Needs | nothing beyond TurboFrame |
| Extend | subclass TVWindow (compose_content), LocationsWindow (activate, EMPTY) |

TVWindow(title="", *, number=0, **kwargs) (turboframe.ui.windows) is a textual-vision Window with Turbo Vision's chrome:
- a frame with the title, the number at the right, and the close and zoom boxes; double when active, single when not;
- scroll bars on the border, bound to its largest scrolling widget, as Turbo Pascal's editor windows had them;
- its content from
compose_content().
from textual.app import ComposeResult
from textual.widgets import TextArea
from turboframe.ui.windows import TVWindow
class NotesWindow(TVWindow):
def __init__(self, number: int) -> None:
super().__init__("Notes", number=number)
self.notes = TextArea()
def compose_content(self) -> ComposeResult:
yield self.notes
app.insert_window(NotesWindow(number=app.free_number()))The window's number (1 to 9) is what Alt+number brings up; app.free_number() gives the lowest one free (see The Desktop). Window > Tile arranges the windows that are tileable, which a TVWindow is.
window.zoom() toggles full size, as the zoom box and F5 do in Turbo Vision. window.frame and window.content are its frame and content container, or None while it opens or closes. Work that ends later checks window.closing before it paints.
Typing in a filtered list narrows it to the items that contain what you typed, case aside. The filter shows on the list's top line, with the count. Backspace edits it, and Esc clears it before it does anything else.
-
Filtered(widget)puts the filter line above a list or tree. -
FilteredListandFilteredTreeare the mixins that make a list or tree filterable.MessageList, the history popups, the file dialog's list, the explorer and the debugger's lists use them. -
matches(text, query)is the test. - A filtered list's
original(shown)gives an item's index in the full list,currentthe index of the focused item in it, andfocus_original(index)puts the bar on one.
from textual.app import ComposeResult
from turboframe.ui.filter import Filtered
from turboframe.ui.windows import MessageList, TVWindow
class Names(TVWindow):
def compose_content(self) -> ComposeResult:
self.list = MessageList(["alpha", "beta", "gamma"])
yield Filtered(self.list)
LocationsWindow(title, number=0) is a filtered list of MessageItem(text, path=None, start=None, end=None): lines, each optionally a place in a file (start and end are character offsets). show(items) fills it, keeping the bar where it was when only the lines' text changed; an empty list shows EMPTY ("(empty)"). Enter, or a double click, on an item with a place calls the window's activate(index), which calls your application's goto_location(path, start, end). EditorMixin gives one that opens the file and selects the range (see The Editor). Use it for search results, compiler messages, a list of problems.
from pathlib import Path
from turboframe.ui.windows import LocationsWindow, MessageItem
window = LocationsWindow("Find results", number=app.free_number())
app.insert_window(window)
window.show([MessageItem("shop.py:12 total = 0", Path("shop.py"), 240, 249)])Override activate(index) in a subclass for a row that does something else. TurboFrame's own subclasses are Find in files' results (Search) and the References and Problems windows (The Editor).
-
OutputWindowandLogWindow: text and logs to read, in Turbo Pascal's Output colours (Log and Output Windows). -
EditorWindow: a file in an editor (The Editor). -
ListWindowandCallStackWindow: a debugger's windows (Debugger Windows). -
ExplorerWindow: the project tree (The Explorer).
A TVWindow's scroll bars sit on its border, bound to its largest scrolling widget; that widget's own bars go away there. Textual's scroll bars elsewhere (an editor's horizontal bar inside a dialog, a scrolling view of yours) are drawn with whole-cell thumbs when your application is a DesktopApp, because Textual's eighth-cell glyphs are not CP437. DesktopApp.CELL_SCROLLBARS = False keeps Textual's; turboframe.ui.compat.install_cell_scrollbars() installs them without DesktopApp. See The Desktop.
-
WheelList: a mixin for a textual-visionListBox, so it scrolls with the mouse wheel (WHEEL_ROWS, 3, rows a notch). -
PassiveScrollBarandFrameScrollBar: Turbo Vision's scroll bars, drawn by you or on a window's border. -
RuleFrame,IndicatorFrame: the frames.IndicatorFrame.set_indicator(text)writes on the bottom border, as an editor's* 12:5.Rule,VRule,HRule: single lines in the frame's colour.
TurboFrame · part of Divengine · GPL-3.0-or-later · report an issue
Tutorial
Examples
The desktop
- The Desktop
- Application Mixins
- Windows and Lists
- Dialogs
- Histories
- Progress
- Themes and Colors
- Glyphs
- Settings and Recent Files
- Command Palette
Editing
Tasks
Languages
Running
Reference
Links