Skip to content

Commit

Permalink
refactor: change DialogButtons definition
Browse files Browse the repository at this point in the history
  • Loading branch information
zimolab committed Oct 9, 2024
1 parent f116cb1 commit 888b940
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
2 changes: 2 additions & 0 deletions examples/adapter/udialog_example_2.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from pyguiadapter.adapter import udialog
from pyguiadapter.exceptions import ParameterError
from pyguiadapter.extend_types import text_t, file_t
from pyguiadapter.utils import messagebox


def show_text_context_example(
Expand All @@ -15,6 +16,7 @@ def show_text_context_example(
title="Hello",
text_content=content,
text_format=text_format,
buttons=messagebox.DialogButtonYes | messagebox.DialogButtonNo,
size=(600, 400),
)

Expand Down
4 changes: 2 additions & 2 deletions pyguiadapter/adapter/udialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ def show_text_content(
size: Tuple[int, int] = None,
title: Optional[str] = "",
icon: IconType = None,
buttons: Union[DialogButtons, int, None] = DialogButtonOk,
buttons: Optional[DialogButtons] = DialogButtonOk,
resizeable: bool = True,
):
return show_custom_dialog(
Expand All @@ -144,7 +144,7 @@ def show_text_file(
size: Tuple[int, int] = None,
title: Optional[str] = "",
icon: IconType = None,
buttons: Union[DialogButtons, int, None] = DialogButtonOk,
buttons: Optional[DialogButtons] = DialogButtonOk,
resizeable: bool = True,
):
text_content = io.read_text_file(text_file)
Expand Down
8 changes: 4 additions & 4 deletions pyguiadapter/utils/messagebox.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
NoButton = QMessageBox.NoButton

DialogButton: Type[QDialogButtonBox.StandardButton] = QDialogButtonBox.StandardButton
DialogButtons: Type[QDialogButtonBox.StandardButtons] = QDialogButtonBox.StandardButtons
DialogButtons = Union[DialogButton, int]
DialogButtonYes = DialogButton.Yes
DialogButtonNo = DialogButton.No
DialogButtonCancel = DialogButton.Cancel
Expand Down Expand Up @@ -178,7 +178,7 @@ def __init__(
size: Optional[Tuple[int, int]] = None,
title: Optional[str] = None,
icon: IconType = None,
buttons: Union[DialogButtons, int, None] = DialogButtonYes,
buttons: Optional[DialogButtons] = DialogButtonYes,
resizeable: bool = True,
**kwargs,
):
Expand Down Expand Up @@ -249,7 +249,7 @@ def show_text_content(
size: Optional[Tuple[int, int]] = None,
title: Optional[str] = None,
icon: IconType = None,
buttons: Union[DialogButtons, int, None] = DialogButtonOk,
buttons: Optional[DialogButtons] = DialogButtonOk,
resizeable: bool = True,
):
return TextBrowserMessageBox.show_and_get_result(
Expand All @@ -271,7 +271,7 @@ def show_text_file(
size: Tuple[int, int] = None,
title: Optional[str] = "",
icon: IconType = None,
buttons: Union[DialogButtons, int, None] = DialogButtonOk,
buttons: Optional[DialogButtons] = DialogButtonOk,
resizeable: bool = True,
):
text_content = read_text_file(text_file)
Expand Down

0 comments on commit 888b940

Please sign in to comment.