diff options
author | Friedemann Kleint <[email protected]> | 2024-12-18 13:09:49 +0100 |
---|---|---|
committer | Friedemann Kleint <[email protected]> | 2024-12-18 12:22:11 +0000 |
commit | d27ad166e888c52e5ec77eb9db85bf7da2ed9ddc (patch) | |
tree | 653e95af4d3eefeaa87faa98b99277914fb903ac /examples/widgets/dialogs | |
parent | 50cb1078f856d3282f62cb7b6e5b7077785ccf26 (diff) |
standarddialogs example: Fix error when checking dialog options
The helper widget displaying the dialog options used int(0)
as default value when building the options flags, causing:
standarddialogs.py", line 274, in set_color
options_value = self._color_options.value()
File "examples/widgets/dialogs/standarddialogs/standarddialogs.py", line 33, in value
result |= value
TypeError: unsupported operand type(s) for |=: 'int' and 'ColorDialogOption'
options_value = self._color_options.value()
Fix this by passing a zero value of the correct options type.
Pick-to: 6.8
Task-number: PYSIDE-1735
Change-Id: Ia82edb2403a9b4580fe3202d75e77da86290fdfe
Reviewed-by: Cristian Maureira-Fredes <[email protected]>
Diffstat (limited to 'examples/widgets/dialogs')
-rw-r--r-- | examples/widgets/dialogs/standarddialogs/standarddialogs.py | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/examples/widgets/dialogs/standarddialogs/standarddialogs.py b/examples/widgets/dialogs/standarddialogs/standarddialogs.py index c03a28a74..04f5fc838 100644 --- a/examples/widgets/dialogs/standarddialogs/standarddialogs.py +++ b/examples/widgets/dialogs/standarddialogs/standarddialogs.py @@ -21,13 +21,14 @@ from PySide6.QtWidgets import (QApplication, QColorDialog, QCheckBox, QDialog, class DialogOptionsWidget(QGroupBox): """Widget displaying a number of check boxes representing the dialog options.""" - def __init__(self, parent=None): + def __init__(self, zero_value, parent=None): super().__init__(parent) + self._zero_value = zero_value self._layout = QVBoxLayout(self) self._mapping = {} def value(self): - result = 0 + result = self._zero_value for checkbox, value in self._mapping.items(): if checkbox.isChecked(): result |= value @@ -73,7 +74,7 @@ class Dialog(QDialog): self._color_label = QLabel() self._color_label.setFrameStyle(frame_style) self._color_button = QPushButton("QColorDialog.get&Color()") - self._color_options = DialogOptionsWidget() + self._color_options = DialogOptionsWidget(QColorDialog.ColorDialogOption(0)) self._color_options.add_checkbox("Show alpha channel", QColorDialog.ShowAlphaChannel) self._color_options.add_checkbox("No buttons", @@ -82,7 +83,7 @@ class Dialog(QDialog): self._font_label = QLabel() self._font_label.setFrameStyle(frame_style) self._font_button = QPushButton("QFontDialog.get&Font()") - self._font_options = DialogOptionsWidget() + self._font_options = DialogOptionsWidget(QFontDialog.FontDialogOption(0)) self._font_options.add_checkbox("Do not use native dialog", QFontDialog.DontUseNativeDialog) self._font_options.add_checkbox("Show scalable fonts", @@ -111,7 +112,7 @@ class Dialog(QDialog): self._save_file_name_label.setFrameStyle(frame_style) self._save_file_name_button = QPushButton("QFileDialog.get&SaveFileName()") - self._file_options = DialogOptionsWidget() + self._file_options = DialogOptionsWidget(QFileDialog.Option(0)) self._file_options.add_checkbox("Do not use native dialog", QFileDialog.DontUseNativeDialog) self._file_options.add_checkbox("Show directories only", |