Dialogs

Usage Pattern

Creation Functions

qtrio.dialogs.create_integer_dialog(parent=None)[source]

Create an integer input dialog.

Parameters

parent (Optional[QWidget]) – See qtrio.dialogs.IntegerDialog.parent.

Return type

IntegerDialog

Returns

The dialog manager.

qtrio.dialogs.create_text_input_dialog(title=None, label=None, parent=None)[source]

Create a text input dialog.

Parameters
Return type

TextInputDialog

Returns

The dialog manager.

qtrio.dialogs.create_file_save_dialog(parent=None, default_directory=None, default_file=None, options=PySide2.QtWidgets.QFileDialog.Option(0))[source]

Create an open or save dialog.

Parameters
Return type

FileDialog

qtrio.dialogs.create_message_box(title, text, icon=PySide2.QtWidgets.QMessageBox.Icon.Information, buttons=PySide2.QtWidgets.QMessageBox.StandardButton.Ok, parent=None)[source]

Create a message box.

Parameters
Return type

MessageBox

Classes

class qtrio.dialogs.IntegerDialog(parent=None, dialog=None, edit_widget=None, accept_button=None, reject_button=None, result=None)[source]

Bases: object

Manage a dialog for inputting an integer from the user. Generally instances should be built via qtrio.dialogs.create_integer_dialog().

parent: Optional[QWidget]

The parent widget for the dialog.

dialog: Optional[QInputDialog]

The actual dialog widget instance.

edit_widget: Optional[QLineEdit]

The line edit that the user will enter the input into.

accept_button: Optional[QPushButton]

The entry confirmation button.

reject_button: Optional[QPushButton]

The input cancellation button.

result: Optional[int]

The result of parsing the user input.

shown

See qtrio.dialogs.DialogProtocol.shown.

finished

See qtrio.dialogs.DialogProtocol.finished.

setup()[source]

See qtrio.dialogs.DialogProtocol.setup().

Return type

None

teardown()[source]

See qtrio.dialogs.DialogProtocol.teardown().

Return type

None

await wait()[source]

See qtrio.dialogs.DialogProtocol.wait().

Return type

int

class qtrio.dialogs.TextInputDialog(title=None, label=None, parent=None, dialog=None, accept_button=None, reject_button=None, line_edit=None, result=None)[source]

Bases: object

Manage a dialog for inputting an integer from the user. Generally instances should be built via qtrio.dialogs.create_text_input_dialog().

title: Optional[str]

The title of the dialog.

label: Optional[str]

The label for the input widget.

parent: Optional[QWidget]

The parent widget for the dialog.

dialog: Optional[QInputDialog]

The actual dialog widget instance.

accept_button: Optional[QPushButton]

The entry confirmation button.

reject_button: Optional[QPushButton]

The input cancellation button.

line_edit: Optional[QLineEdit]

The line edit that the user will enter the input into.

result: Optional[str]

The result of parsing the user input.

shown

See qtrio.dialogs.DialogProtocol.shown.

finished

See qtrio.dialogs.DialogProtocol.finished.

setup()[source]

See qtrio.dialogs.DialogProtocol.setup().

Return type

None

teardown()[source]

See qtrio.dialogs.DialogProtocol.teardown().

Return type

None

await wait()[source]

See qtrio.dialogs.DialogProtocol.wait().

Return type

str

class qtrio.dialogs.FileDialog(file_mode, accept_mode, default_directory=None, default_file=None, options=PySide2.QtWidgets.QFileDialog.Option(0), parent=None, dialog=None, accept_button=None, reject_button=None, result=None)[source]

Bases: object

Manage a dialog for allowing the user to select a file or directory. Generally instances should be built via qtrio.dialogs.create_file_save_dialog().

file_mode: <class ‘PySide2.QtWidgets.QFileDialog.FileMode’>

Controls whether the dialog is for picking an existing vs. new file or directory, etc.

accept_mode: <class ‘PySide2.QtWidgets.QFileDialog.AcceptMode’>

Specify an open vs. a save dialog.

default_directory: Optional[trio.Path]

The directory to be initially presented in the dialog.

default_file: Optional[trio.Path]

The file to be initially selected in the dialog.

options: <class ‘PySide2.QtWidgets.QFileDialog.Option’>

Miscellaneous options. See the Qt documentation.

parent: Optional[QWidget]

The parent widget for the dialog.

dialog: Optional[QFileDialog]

The actual dialog widget instance.

accept_button: Optional[QPushButton]

The confirmation button.

reject_button: Optional[QPushButton]

The cancellation button.

result: Optional[trio.Path]

The path selected by the user.

shown

See qtrio.dialogs.DialogProtocol.shown.

finished

See qtrio.dialogs.DialogProtocol.finished.

setup()[source]

See qtrio.dialogs.DialogProtocol.setup().

Return type

None

teardown()[source]

See qtrio.dialogs.DialogProtocol.teardown().

Return type

None

await wait()[source]

See qtrio.dialogs.DialogProtocol.wait().

Return type

Path

class qtrio.dialogs.MessageBox(title, text, icon, buttons, parent=None, dialog=None, accept_button=None, result=None)[source]

Bases: object

Manage a message box for notifying the user. Generally instances should be built via qtrio.dialogs.create_message_box().

title: str

The message box title.

text: str

The message text shown inside the dialog.

icon: <class ‘PySide2.QtWidgets.QMessageBox.Icon’>

The icon shown inside the dialog.

buttons: StandardButtons

The buttons to be shown in the dialog.

parent: Optional[QWidget]

The parent widget for the dialog.

dialog: Optional[QMessageBox]

The actual dialog widget instance.

accept_button: Optional[QPushButton]

The button to accept the dialog.

result: Optional[trio.Path]

Not generally relevant for a message box.

shown

See qtrio.dialogs.DialogProtocol.shown.

finished

See qtrio.dialogs.DialogProtocol.finished.

setup()[source]

See qtrio.dialogs.DialogProtocol.setup().

Return type

None

teardown()[source]

See qtrio.dialogs.DialogProtocol.teardown().

Return type

None

await wait()[source]

See qtrio.dialogs.DialogProtocol.wait().

Return type

None

Protocol

class qtrio.dialogs.DialogProtocol(*args, **kwds)[source]

Bases: typing.Protocol

The common interface used for working with QTrio dialogs. To check that a class implements this protocol see qtrio.dialogs.check_dialog_protocol().

shown: qtrio._qt.Signal

The signal to be emitted when the dialog is shown.

finished: qtrio._qt.Signal

The signal to be emitted when the dialog is finished.

setup()[source]

Setup and show the dialog. Emit qtrio.dialogs.DialogProtocol.shown when done.

Return type

None

teardown()[source]

Hide and teardown the dialog.

Return type

None

await wait()[source]

Show the dialog, wait for the user interaction, and return the result.

Raises
Return type

object

qtrio.dialogs.check_dialog_protocol(cls)[source]

Decorate a class with this to verify it implements the qtrio.dialogs.DialogProtocol when a type hint checker such as mypy is run against the code. At runtime the passed class is cleanly returned.

Parameters

cls (Type[~DialogProtocolT]) – The class to verify.

Return type

Type[~DialogProtocolT]