22from ctypes .wintypes import DWORD , WORD , SHORT
33from ..win_helper import (
44 WindowStyle as WS ,
5- EnableWindow , IsWindowEnabled
5+ EnableWindow , IsWindowEnabled ,
6+ ShowWindow , ShowWindowCommands as SWC , IsWindowVisible ,
67)
78
89from dataclasses import dataclass , field
@@ -29,6 +30,8 @@ class Control:
2930 registeredNotifications (Dict): A dictionary of registered notification messages and their associated handlers.
3031 isEnabled (bool): Indicates the state of the control.
3132 Returns True if the control is enabled, False otherwise
33+ isVisible (bool): Indicates the visible state of the control.
34+ Returns True if the control is visible, False otherwise
3235
3336 Methods:
3437 create(self) -> bytearray:
@@ -37,6 +40,9 @@ class Control:
3740 enable(self, state: bool) -> None:
3841 Enables or disables a control.
3942
43+ visible(self, state: bool) -> None:
44+ Makes a control visible or invisible.
45+
4046
4147 Note:
4248 Do not instantiate this class directly. It should be subclassed by specific controls.
@@ -101,3 +107,23 @@ def enable(self, state: bool):
101107 def isEnabled (self ) -> bool :
102108 return bool (IsWindowEnabled (self .hwnd ))
103109
110+ def visible (self , state : bool ):
111+ '''
112+ Makes a control visible or invisible.
113+
114+ Args:
115+ state (bool): Indicates whether to make the window visible or invisible.
116+ If this parameter is True, the window will be made visible (shown).
117+ If the parameter is False, the window will be made invisible (hidden).
118+
119+ Returns:
120+ None
121+
122+ '''
123+ ShowWindow (self .hwnd , SWC .SHOW if state else SWC .HIDE )
124+ return self .isVisible
125+
126+ @property
127+ def isVisible (self ) -> bool :
128+ return bool (IsWindowVisible (self .hwnd ))
129+
0 commit comments