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_open_dialog
(parent=None, default_directory=None, default_file=None, options=PySide2.QtWidgets.QFileDialog.Option(0))[source]¶ Create a file open 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_file_save_dialog
(parent=None, default_directory=None, default_file=None, options=PySide2.QtWidgets.QFileDialog.Option(0))[source]¶ Create a file 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
-
qtrio.dialogs.
create_progress_dialog
(title='', text='', cancel_button_text=None, minimum=0, maximum=0, parent=None)[source]¶ Create a progress dialog.
- Parameters
title (
str
) – Seeqtrio.dialogs.ProgressDialog.title
.text (
str
) – Seeqtrio.dialogs.ProgressDialog.text
.cancel_button_text (
Optional
[str
]) – Seeqtrio.dialogs.ProgressDialog.cancel_button_text
.minimum (
int
) – Seeqtrio.dialogs.ProgressDialog.minimum
.maximum (
int
) – Seeqtrio.dialogs.ProgressDialog.maximum
.parent (
Optional
[QWidget
]) – Seeqtrio.dialogs.ProgressDialog.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.BasicDialogProtocol.setup()
.- Return type
-
teardown
()[source]¶ See
qtrio.dialogs.BasicDialogProtocol.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.BasicDialogProtocol.setup()
.- Return type
-
teardown
()[source]¶ See
qtrio.dialogs.BasicDialogProtocol.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, file_name_line_edit=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
¶
-
await
set_path
(path)[source]¶ Set the directory and enter the file name in the text box. Note that this does not select the file in the file list.
-
setup
()[source]¶ See
qtrio.dialogs.BasicDialogProtocol.setup()
.- Return type
-
teardown
()[source]¶ See
qtrio.dialogs.BasicDialogProtocol.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.BasicDialogProtocol.setup()
.- Return type
-
teardown
()[source]¶ See
qtrio.dialogs.BasicDialogProtocol.teardown()
.- Return type
-
await
wait
()[source]¶ See
qtrio.dialogs.DialogProtocol.wait()
.- Return type
-
-
class
qtrio.dialogs.
ProgressDialog
(title, text, cancel_button_text, minimum, maximum, parent=None, dialog=None, cancel_button=None)[source]¶ Bases:
object
Manage a progress dialog for updating the user. Generally instances should be built via
qtrio.dialogs.create_progress_dialog()
.The cancel button text.
-
dialog
: Optional[QProgressDialog]¶ The actual dialog widget instance.
The cancellation button.
-
shown
¶
-
finished
¶
-
setup
()[source]¶ See
qtrio.dialogs.BasicDialogProtocol.setup()
.- Return type
-
teardown
()[source]¶ See
qtrio.dialogs.BasicDialogProtocol.teardown()
.- Return type
Protocols¶
-
class
qtrio.dialogs.
BasicDialogProtocol
(*args, **kwargs)[source]¶ Bases:
Protocol
The minimal common interface used for working with QTrio dialogs. To check that a class implements this protocol see
qtrio.dialogs.check_basic_dialog_protocol()
.-
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
-
-
class
qtrio.dialogs.
DialogProtocol
(*args, **kwargs)[source]¶ Bases:
qtrio.dialogs.BasicDialogProtocol
,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.
-
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
-
Protocol Checkers¶
These callables can be used if you want to verify that your own classes properly implement the associated protocols. They are simple pass through decorators at runtime but when checking type hints they will result in a failure if the class does not implement the protocol.
-
qtrio.dialogs.
check_basic_dialog_protocol
= <qtrio._util.ProtocolChecker object>¶ Assert proper implementation of
qtrio.dialogs.BasicDialogProtocol
when type hint checking.- Parameters
cls – The class to verify.
- Returns
The same class, unmodified, that was passed in.
-
qtrio.dialogs.
check_dialog_protocol
= <qtrio._util.ProtocolChecker object>¶ Assert proper implementation of
qtrio.dialogs.DialogProtocol
when type hint checking.- Parameters
cls – The class to verify.
- Returns
The same class, unmodified, that was passed in.