Skip to main content

textual-cogs

Framework: Textual

A collection of Textual dialogs.

screenshot

Dialogs included so far:

  • Generic MessageDialog - shows messages to the user
  • OpenFileDialog - gives the user a way to select a file to open
  • QuitDialog - ask the user if they want to quit the application
  • SaveFileDialog - gives the user a way to select a location to save a file
  • SingleChoiceDialog - gives the user a series of choices to pick from
  • SingleColorPickerDialog - gives the user a way to select a color
  • TextEntryDialog - ask the user a question and get their answer using an Input widget

Installation

You can install textual-cog using pip:

python -m pip install textual-cogs

You also need Textual to run these dialogs.

Example Usage

Here is an example of creating a small application that opens the MessageDialog immediately. You would normally open the dialog in response to a message or event that has occurred, such as when the application has an error or you need to tell the user something.

from textual.app import App
from textual.app import App, ComposeResult

from textual_cogs.dialogs import MessageDialog
from textual_cogs import icons


class DialogApp(App):
    def on_mount(self) -> ComposeResult:
        def my_callback(value: None | bool) -> None:
            self.exit()

        self.push_screen(
            MessageDialog(
                "What is your favorite language?",
                icon=icons.ICON_QUESTION,
                title="Warning",
            ),
            my_callback,
        )


if __name__ == "__main__":
    app = DialogApp()
    app.run()

When you run this code, you will get something like the following:

screenshot

Creating a TextEntryDialog

Here is how you would create a TextEntryDialog:

from textual.app import App
from textual.app import App, ComposeResult

from textual_cogs.dialogs import TextEntryDialog


class DialogApp(App):
    def on_mount(self) -> ComposeResult:
        def my_callback(value: str | bool) -> None:
            self.exit()

        self.push_screen(
            TextEntryDialog("What is your name?", "Information"), my_callback
        )


if __name__ == "__main__":
    app = DialogApp()
    app.run()

When you run this code, you will see the following:

screenshot

Creating a SaveFileDialog

The following code demonstrates how to create a SaveFileDialog:

from textual.app import App
from textual.app import App, ComposeResult

from textual_cogs.dialogs import SaveFileDialog


class DialogApp(App):
    def on_mount(self) -> ComposeResult:
        self.push_screen(SaveFileDialog())

if __name__ == "__main__":
    app = DialogApp()
    app.run()

When you run this code, you will see the following:

screenshot

Metadata

Release files for textual-cogs 0.0.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for textual-cogs 0.0.4
File Size Uploaded
textual_cogs-0.0.4.tar.gz 8.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for textual-cogs 0.0.4
File Interpreter ABI Platform
textual_cogs-0.0.4-py3-none-any.whl Python 3 none any Details

Total release size: 21.1 kB

Release files / textual_cogs-0.0.4.tar.gz

Download URL textual_cogs-0.0.4.tar.gz
Size 8.7 kB
Tags Source
SHA-256 checksum
How to use checksums
d59fd16bb69c1304c570da9caaa5feba7f9e82b8de2ca6cc586e2bd46bbfbfab
BLAKE2b-256 checksum
How to use checksums
9a6cf1bb42a81619b3d52090d9a56ae1dc77d5d2cfc9df8c0e882c1574c3cae2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.3

Release files / textual_cogs-0.0.4-py3-none-any.whl

Download URL textual_cogs-0.0.4-py3-none-any.whl
Size 12.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e868305e794e7229923a1306281944f0d00aacc0a3ff21066c35924a123b4bd3
BLAKE2b-256 checksum
How to use checksums
12975e77917d79a3808a286cdda09ee3f5610b59eeba245040f455ceeab7dd92
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.3

Release history Release notifications | RSS feed

0.0.5

2 release files

This release

0.0.4 This release

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page