Dialogs¶
Usage Pattern¶
Creation Functions¶
-
qtrio.dialogs.
create_integer_dialog
(parent=None)[source]¶ Create an integer input dialog.
- Parameters
parent (
Optional
[QWidget
]) – Seeqtrio.dialogs.IntegerDialog.parent
.- Return type
- 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
- 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
parent (
Optional
[QWidget
]) – Seeqtrio.dialogs.FileDialog.parent
.default_directory (
Optional
[Path
]) – Seeqtrio.dialogs.FileDialog.default_directory
.default_file (
Optional
[Path
]) – Seeqtrio.dialogs.FileDialog.default_file
.options (
Option
) – Seeqtrio.dialogs.FileDialog.options
.
- Return type
-
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
title (
str
) – Seeqtrio.dialogs.MessageBox.title
.text (
str
) – Seeqtrio.dialogs.MessageBox.text
.icon (
Icon
) – Seeqtrio.dialogs.MessageBox.icon
.buttons (
StandardButtons
) – Seeqtrio.dialogs.MessageBox.buttons
.parent (
Optional
[QWidget
]) – Seeqtrio.dialogs.MessageBox.parent
.
- Return type
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()
.-
dialog
: Optional[QInputDialog]¶ The actual dialog widget instance.
The entry confirmation button.
The input cancellation button.
-
shown
¶
-
finished
¶
-
setup
()[source]¶ See
qtrio.dialogs.DialogProtocol.setup()
.- Return type
-
teardown
()[source]¶ See
qtrio.dialogs.DialogProtocol.teardown()
.- Return type
-
await
wait
()[source]¶ See
qtrio.dialogs.DialogProtocol.wait()
.- Return type
-
-
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()
.-
dialog
: Optional[QInputDialog]¶ The actual dialog widget instance.
The entry confirmation button.
The input cancellation button.
-
shown
¶
-
finished
¶
-
setup
()[source]¶ See
qtrio.dialogs.DialogProtocol.setup()
.- Return type
-
teardown
()[source]¶ See
qtrio.dialogs.DialogProtocol.teardown()
.- Return type
-
await
wait
()[source]¶ See
qtrio.dialogs.DialogProtocol.wait()
.- Return type
-
-
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.
-
options
: <class ‘PySide2.QtWidgets.QFileDialog.Option’>¶ Miscellaneous options. See the Qt documentation.
-
dialog
: Optional[QFileDialog]¶ The actual dialog widget instance.
The confirmation button.
The cancellation button.
-
shown
¶
-
finished
¶
-
setup
()[source]¶ See
qtrio.dialogs.DialogProtocol.setup()
.- Return type
-
teardown
()[source]¶ See
qtrio.dialogs.DialogProtocol.teardown()
.- Return type
-
await
wait
()[source]¶ See
qtrio.dialogs.DialogProtocol.wait()
.- Return type
-
-
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()
.-
icon
: <class ‘PySide2.QtWidgets.QMessageBox.Icon’>¶ The icon shown inside the dialog.
The buttons to be shown in the dialog.
-
dialog
: Optional[QMessageBox]¶ The actual dialog widget instance.
The button to accept the dialog.
-
shown
¶
-
finished
¶
-
setup
()[source]¶ See
qtrio.dialogs.DialogProtocol.setup()
.- Return type
-
teardown
()[source]¶ See
qtrio.dialogs.DialogProtocol.teardown()
.- Return type
-
await
wait
()[source]¶ See
qtrio.dialogs.DialogProtocol.wait()
.- Return type
-
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
-
await
wait
()[source]¶ Show the dialog, wait for the user interaction, and return the result.
- Raises
qtrio.InvalidInputError – If the input can’t be parsed as an integer.
qtrio.UserCancelledError – If the user cancels the dialog.
- Return type
-
-
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.