From 1e044b40856fdbf81b42950d28a4a6fb7986ce7a Mon Sep 17 00:00:00 2001 From: CodeCrafter-TL Date: Wed, 22 Jan 2025 14:42:11 +0800 Subject: [PATCH 1/8] Update tkintertools --- maliang/core/containers.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/maliang/core/containers.py b/maliang/core/containers.py index bc1d23c1..9d81d6a3 100644 --- a/maliang/core/containers.py +++ b/maliang/core/containers.py @@ -307,6 +307,28 @@ def transparentcolor(self, value: str | None = None) -> str | None: """ result = self.wm_attributes("-transparentcolor", value) return None if result == "" else result + + elif platform.system() == "Darwin": + + def modified(self, value: bool | None = None) -> bool | None: + """Set or get the whether the window is modified + + * `value`: indicate whether the window is modified + + This method only works on macOS and OS X! + """ + result = self.wm_attributes("-modified", value) + return None if result == "" else result + + def transparent(self, value: bool | None = None) -> bool | None: + """Set or get the whether the window is transparent + + * `value`: indicate whether the window is transparent + + This method only works on macOS and OS X! + """ + result = self.wm_attributes("-transparent", value) + return None if result == "" else result @typing_extensions.override def destroy(self) -> None: From 8793095ce94edd6815d262bde8d1300a32e21a51 Mon Sep 17 00:00:00 2001 From: Zhikang Yan <2951256653@qq.com> Date: Wed, 22 Jan 2025 18:42:53 +0800 Subject: [PATCH 2/8] Update maliang/core/containers.py --- maliang/core/containers.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/maliang/core/containers.py b/maliang/core/containers.py index 9d81d6a3..76db9768 100644 --- a/maliang/core/containers.py +++ b/maliang/core/containers.py @@ -315,7 +315,7 @@ def modified(self, value: bool | None = None) -> bool | None: * `value`: indicate whether the window is modified - This method only works on macOS and OS X! + This method only works on macOS! """ result = self.wm_attributes("-modified", value) return None if result == "" else result From cff63f61a1f53e14725e631cf167d68e4becc6bb Mon Sep 17 00:00:00 2001 From: Zhikang Yan <2951256653@qq.com> Date: Wed, 22 Jan 2025 18:42:58 +0800 Subject: [PATCH 3/8] Update maliang/core/containers.py --- maliang/core/containers.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/maliang/core/containers.py b/maliang/core/containers.py index 76db9768..7beae9b6 100644 --- a/maliang/core/containers.py +++ b/maliang/core/containers.py @@ -325,7 +325,7 @@ def transparent(self, value: bool | None = None) -> bool | None: * `value`: indicate whether the window is transparent - This method only works on macOS and OS X! + This method only works on macOS! """ result = self.wm_attributes("-transparent", value) return None if result == "" else result From f6b35c4de481e691115b390ade766272fc9c9986 Mon Sep 17 00:00:00 2001 From: Meng Xinhong <143482922+CodeCrafter-TL@users.noreply.github.com> Date: Thu, 23 Jan 2025 13:22:58 +0800 Subject: [PATCH 4/8] Update mailing --- maliang/core/containers.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/maliang/core/containers.py b/maliang/core/containers.py index 7beae9b6..eccaf735 100644 --- a/maliang/core/containers.py +++ b/maliang/core/containers.py @@ -310,25 +310,25 @@ def transparentcolor(self, value: str | None = None) -> str | None: elif platform.system() == "Darwin": - def modified(self, value: bool | None = None) -> bool | None: - """Set or get the whether the window is modified - + def modified(self, value: int | None = None) -> int | None: + """Set or get whether the window is modified + * `value`: indicate whether the window is modified - This method only works on macOS! + This method only works on macOS and OS X! """ result = self.wm_attributes("-modified", value) - return None if result == "" else result - - def transparent(self, value: bool | None = None) -> bool | None: - """Set or get the whether the window is transparent + return None if result == 0 else result + + def transparent(self, value: int | None = None) -> int | None: + """Set or get whether the window is transparent * `value`: indicate whether the window is transparent - This method only works on macOS! + This method only works on macOS and OS X! """ result = self.wm_attributes("-transparent", value) - return None if result == "" else result + return None if result == 0 else result @typing_extensions.override def destroy(self) -> None: From 7319a479070ec666fa2a5146453ff03d593035a2 Mon Sep 17 00:00:00 2001 From: Meng Xinhong <143482922+CodeCrafter-TL@users.noreply.github.com> Date: Thu, 23 Jan 2025 13:54:37 +0800 Subject: [PATCH 5/8] Update containers.py --- maliang/core/containers.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/maliang/core/containers.py b/maliang/core/containers.py index eccaf735..c01c87e2 100644 --- a/maliang/core/containers.py +++ b/maliang/core/containers.py @@ -314,8 +314,8 @@ def modified(self, value: int | None = None) -> int | None: """Set or get whether the window is modified * `value`: indicate whether the window is modified - - This method only works on macOS and OS X! + + This method only works on macOS! """ result = self.wm_attributes("-modified", value) return None if result == 0 else result @@ -325,7 +325,7 @@ def transparent(self, value: int | None = None) -> int | None: * `value`: indicate whether the window is transparent - This method only works on macOS and OS X! + This method only works on macOS! """ result = self.wm_attributes("-transparent", value) return None if result == 0 else result From d06ae51f4e56b8321d85fdc4cf51b739da783874 Mon Sep 17 00:00:00 2001 From: Xiaokang2022 <2951256653@qq.com> Date: Thu, 23 Jan 2025 14:47:28 +0800 Subject: [PATCH 6/8] fix: Fix methods --- maliang/core/containers.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/maliang/core/containers.py b/maliang/core/containers.py index c01c87e2..15283d2e 100644 --- a/maliang/core/containers.py +++ b/maliang/core/containers.py @@ -307,10 +307,10 @@ def transparentcolor(self, value: str | None = None) -> str | None: """ result = self.wm_attributes("-transparentcolor", value) return None if result == "" else result - + elif platform.system() == "Darwin": - def modified(self, value: int | None = None) -> int | None: + def modified(self, value: bool | None = None) -> bool | None: """Set or get whether the window is modified * `value`: indicate whether the window is modified @@ -318,9 +318,9 @@ def modified(self, value: int | None = None) -> int | None: This method only works on macOS! """ result = self.wm_attributes("-modified", value) - return None if result == 0 else result + return None if result == "" else bool(result) - def transparent(self, value: int | None = None) -> int | None: + def transparent(self, value: bool | None = None) -> bool | None: """Set or get whether the window is transparent * `value`: indicate whether the window is transparent @@ -328,7 +328,7 @@ def transparent(self, value: int | None = None) -> int | None: This method only works on macOS! """ result = self.wm_attributes("-transparent", value) - return None if result == 0 else result + return None if result == "" else bool(result) @typing_extensions.override def destroy(self) -> None: From baa237d7b9340f9cd6c6b8a30b031a9331b78523 Mon Sep 17 00:00:00 2001 From: Xiaokang2022 <2951256653@qq.com> Date: Thu, 23 Jan 2025 14:48:19 +0800 Subject: [PATCH 7/8] style: Improve docstrings --- maliang/core/containers.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/maliang/core/containers.py b/maliang/core/containers.py index 15283d2e..4ddce47b 100644 --- a/maliang/core/containers.py +++ b/maliang/core/containers.py @@ -289,7 +289,7 @@ def fullscreen(self, value: bool | None = True) -> bool | None: @_fixed_theme def toolwindow(self, value: bool | None = True) -> bool | None: - """Set or get whether the window is tool-window + """Set or get whether the window is tool-window. * `value`: indicate whether the window is tool-window @@ -299,7 +299,7 @@ def toolwindow(self, value: bool | None = True) -> bool | None: return None if result == "" else bool(result) def transparentcolor(self, value: str | None = None) -> str | None: - """Set or get the penetration color of the window + """Set or get the penetration color of the window. * `value`: the penetration color of the window @@ -311,7 +311,7 @@ def transparentcolor(self, value: str | None = None) -> str | None: elif platform.system() == "Darwin": def modified(self, value: bool | None = None) -> bool | None: - """Set or get whether the window is modified + """Set or get whether the window is modified. * `value`: indicate whether the window is modified @@ -321,7 +321,7 @@ def modified(self, value: bool | None = None) -> bool | None: return None if result == "" else bool(result) def transparent(self, value: bool | None = None) -> bool | None: - """Set or get whether the window is transparent + """Set or get whether the window is transparent. * `value`: indicate whether the window is transparent From 1b5d7d211af947ac60dae445b1f2e0cc3cf3d0dc Mon Sep 17 00:00:00 2001 From: Xiaokang2022 <2951256653@qq.com> Date: Thu, 23 Jan 2025 14:53:07 +0800 Subject: [PATCH 8/8] test: Add tests for methods `Tk.modified` and `Tk.transparent` --- tests/test_core/test_containers.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tests/test_core/test_containers.py b/tests/test_core/test_containers.py index d251b978..8334f5ed 100644 --- a/tests/test_core/test_containers.py +++ b/tests/test_core/test_containers.py @@ -74,6 +74,20 @@ def test_transparentcolor(self) -> None: self.assertIsNone(tk.transparentcolor("")) self.assertEqual(tk.transparentcolor(), None) + @unittest.skipUnless(platform.system() == "Darwin", "Only works on Darwin") + def test_modified(self) -> None: + with containers.Tk() as tk: + self.assertFalse(tk.modified()) + self.assertIsNone(tk.modified(True)) + self.assertTrue(tk.modified()) + + @unittest.skipUnless(platform.system() == "Darwin", "Only works on Darwin") + def test_transparent(self) -> None: + with containers.Tk() as tk: + self.assertFalse(tk.transparent()) + self.assertIsNone(tk.transparent(True)) + self.assertTrue(tk.transparent()) + def test_center(self) -> None: with containers.Tk() as tk: tk.center()