robotframework-platynui 0.0.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (122) hide show
  1. PlatynUI/ButtonKeywords.py +9 -0
  2. PlatynUI/TextKeywords.py +7 -0
  3. PlatynUI/__about__.py +4 -0
  4. PlatynUI/__init__.py +34 -0
  5. PlatynUI/core/__init__.py +13 -0
  6. PlatynUI/core/adapter.py +152 -0
  7. PlatynUI/core/adapterfactory.py +51 -0
  8. PlatynUI/core/adapterproxy.py +168 -0
  9. PlatynUI/core/contextbase.py +586 -0
  10. PlatynUI/core/exceptions.py +77 -0
  11. PlatynUI/core/internal/__init__.py +0 -0
  12. PlatynUI/core/internal/decorator.py +148 -0
  13. PlatynUI/core/locatorbase.py +197 -0
  14. PlatynUI/core/locatorscope.py +17 -0
  15. PlatynUI/core/predicate.py +15 -0
  16. PlatynUI/core/settings.py +63 -0
  17. PlatynUI/core/strategies/__init__.py +1 -0
  18. PlatynUI/core/strategies/strategies.py +26 -0
  19. PlatynUI/core/strategybase.py +8 -0
  20. PlatynUI/core/strategyimpl.py +102 -0
  21. PlatynUI/core/technology.py +25 -0
  22. PlatynUI/core/types.py +421 -0
  23. PlatynUI/core/wait_for.py +47 -0
  24. PlatynUI/core/weight_calculator.py +110 -0
  25. PlatynUI/py.typed +0 -0
  26. PlatynUI/robot/__init__.py +0 -0
  27. PlatynUI/robot/reporting.py +74 -0
  28. PlatynUI/technology/__init__.py +0 -0
  29. PlatynUI/technology/uiautomation/.gitignore +1 -0
  30. PlatynUI/technology/uiautomation/__init__.py +4 -0
  31. PlatynUI/technology/uiautomation/core/adapterfactory.py +88 -0
  32. PlatynUI/technology/uiautomation/core/displaydevice.py +23 -0
  33. PlatynUI/technology/uiautomation/core/impls/__init__.py +2 -0
  34. PlatynUI/technology/uiautomation/core/impls/control.py +31 -0
  35. PlatynUI/technology/uiautomation/core/impls/window.py +83 -0
  36. PlatynUI/technology/uiautomation/core/keyboarddevice.py +21 -0
  37. PlatynUI/technology/uiautomation/core/loader.py +117 -0
  38. PlatynUI/technology/uiautomation/core/mousedevice.py +29 -0
  39. PlatynUI/technology/uiautomation/core/technology.py +61 -0
  40. PlatynUI/technology/uiautomation/core/uiaadapter.py +197 -0
  41. PlatynUI/technology/uiautomation/core/uiabase.py +19 -0
  42. PlatynUI/technology/uiautomation/desktop.py +11 -0
  43. PlatynUI/technology/uiautomation/locator.py +435 -0
  44. PlatynUI/technology/uiautomation/runtime/Caliburn.Micro.Core.dll +0 -0
  45. PlatynUI/technology/uiautomation/runtime/Caliburn.Micro.Platform.Core.dll +0 -0
  46. PlatynUI/technology/uiautomation/runtime/Caliburn.Micro.Platform.dll +0 -0
  47. PlatynUI/technology/uiautomation/runtime/Microsoft.Xaml.Behaviors.dll +0 -0
  48. PlatynUI/technology/uiautomation/runtime/PlatynUI.Technology.UiAutomation.Spy.deps.json +266 -0
  49. PlatynUI/technology/uiautomation/runtime/PlatynUI.Technology.UiAutomation.Spy.dll +0 -0
  50. PlatynUI/technology/uiautomation/runtime/PlatynUI.Technology.UiAutomation.Spy.exe +0 -0
  51. PlatynUI/technology/uiautomation/runtime/PlatynUI.Technology.UiAutomation.Spy.runtimeconfig.json +19 -0
  52. PlatynUI/technology/uiautomation/runtime/PlatynUI.Technology.UiAutomation.dll +0 -0
  53. PlatynUI/technology/uiautomation/runtime/System.ComponentModel.Composition.dll +0 -0
  54. PlatynUI/technology/uiautomation/spy/__init__.py +0 -0
  55. PlatynUI/technology/uiautomation/spy/__main__.py +24 -0
  56. PlatynUI/ui/__init__.py +65 -0
  57. PlatynUI/ui/application.py +27 -0
  58. PlatynUI/ui/buttons.py +82 -0
  59. PlatynUI/ui/combobox.py +149 -0
  60. PlatynUI/ui/container.py +9 -0
  61. PlatynUI/ui/control.py +49 -0
  62. PlatynUI/ui/core/__init__.py +3 -0
  63. PlatynUI/ui/core/devices/__init__.py +6 -0
  64. PlatynUI/ui/core/devices/basedisplaydevice.py +25 -0
  65. PlatynUI/ui/core/devices/basekeyboarddevice.py +64 -0
  66. PlatynUI/ui/core/devices/basemousedevice.py +30 -0
  67. PlatynUI/ui/core/devices/basescreendevice.py +16 -0
  68. PlatynUI/ui/core/devices/displaydevice.py +113 -0
  69. PlatynUI/ui/core/devices/inputdevice.py +24 -0
  70. PlatynUI/ui/core/devices/keyboarddevice.py +279 -0
  71. PlatynUI/ui/core/devices/keyboardproxy.py +69 -0
  72. PlatynUI/ui/core/devices/mousebutton.py +11 -0
  73. PlatynUI/ui/core/devices/mousedevice.py +279 -0
  74. PlatynUI/ui/core/devices/mouseproxy.py +178 -0
  75. PlatynUI/ui/core/ui_technology.py +31 -0
  76. PlatynUI/ui/core/window_manager.py +59 -0
  77. PlatynUI/ui/desktopbase.py +56 -0
  78. PlatynUI/ui/dialog.py +10 -0
  79. PlatynUI/ui/edit.py +48 -0
  80. PlatynUI/ui/element.py +265 -0
  81. PlatynUI/ui/graphic.py +14 -0
  82. PlatynUI/ui/header.py +33 -0
  83. PlatynUI/ui/item.py +100 -0
  84. PlatynUI/ui/lists.py +37 -0
  85. PlatynUI/ui/menus.py +42 -0
  86. PlatynUI/ui/orientation.py +9 -0
  87. PlatynUI/ui/pane.py +14 -0
  88. PlatynUI/ui/proxies/__init__.py +4 -0
  89. PlatynUI/ui/proxies/standardproxies.py +391 -0
  90. PlatynUI/ui/scrollbar.py +9 -0
  91. PlatynUI/ui/strategies/__init__.py +19 -0
  92. PlatynUI/ui/strategies/activatable.py +27 -0
  93. PlatynUI/ui/strategies/application.py +28 -0
  94. PlatynUI/ui/strategies/closeable.py +22 -0
  95. PlatynUI/ui/strategies/control.py +16 -0
  96. PlatynUI/ui/strategies/editable.py +13 -0
  97. PlatynUI/ui/strategies/element.py +65 -0
  98. PlatynUI/ui/strategies/expandable.py +27 -0
  99. PlatynUI/ui/strategies/hasnativewindowhandle.py +14 -0
  100. PlatynUI/ui/strategies/hasorientation.py +15 -0
  101. PlatynUI/ui/strategies/maximizeable.py +27 -0
  102. PlatynUI/ui/strategies/minimizeable.py +27 -0
  103. PlatynUI/ui/strategies/movable.py +14 -0
  104. PlatynUI/ui/strategies/resizable.py +13 -0
  105. PlatynUI/ui/strategies/restorable.py +13 -0
  106. PlatynUI/ui/strategies/selectable.py +27 -0
  107. PlatynUI/ui/strategies/text.py +55 -0
  108. PlatynUI/ui/strategies/title.py +14 -0
  109. PlatynUI/ui/strategies/toggleable.py +23 -0
  110. PlatynUI/ui/strategies/value.py +15 -0
  111. PlatynUI/ui/table.py +56 -0
  112. PlatynUI/ui/tabs.py +28 -0
  113. PlatynUI/ui/text.py +14 -0
  114. PlatynUI/ui/togglestate.py +12 -0
  115. PlatynUI/ui/tree.py +99 -0
  116. PlatynUI/ui/unknown.py +9 -0
  117. PlatynUI/ui/window.py +177 -0
  118. robotframework_platynui-0.0.1.dist-info/METADATA +49 -0
  119. robotframework_platynui-0.0.1.dist-info/RECORD +122 -0
  120. robotframework_platynui-0.0.1.dist-info/WHEEL +4 -0
  121. robotframework_platynui-0.0.1.dist-info/entry_points.txt +2 -0
  122. robotframework_platynui-0.0.1.dist-info/licenses/LICENSE.txt +73 -0
PlatynUI/ui/element.py ADDED
@@ -0,0 +1,265 @@
1
+ from typing import Optional, cast
2
+
3
+ from ..core import ContextBase, ContextFactory, context
4
+ from ..core.exceptions import NoKeyboardProxyError, NoMouseProxyError
5
+ from ..core.predicate import predicate
6
+ from ..core.settings import Settings
7
+ from ..core.types import Point, Rect
8
+ from ..ui.core import UiTechnology
9
+ from ..ui.core.devices.displaydevice import DisplayDevice
10
+ from ..ui.core.devices.keyboarddevice import KeyboardDevice
11
+ from ..ui.core.devices.keyboardproxy import KeyboardProxy
12
+ from ..ui.core.devices.mousedevice import MouseDevice
13
+ from ..ui.core.devices.mouseproxy import MouseProxy
14
+ from . import strategies
15
+
16
+ __all__ = ["Element"]
17
+
18
+
19
+ @context
20
+ class Element(ContextBase):
21
+ default_prefix = "element"
22
+
23
+ def invalidate(self) -> None:
24
+ super().invalidate()
25
+ self._mouse_proxy = None
26
+ self._keyboard_proxy = None
27
+
28
+ @property
29
+ def is_readonly(self) -> bool:
30
+ self.ensure_that(self._application_is_ready)
31
+
32
+ return self.adapter.get_strategy(strategies.Element).is_readonly
33
+
34
+ @property
35
+ def is_enabled(self) -> bool:
36
+ self.ensure_that(self._application_is_ready)
37
+
38
+ return self.adapter.get_strategy(strategies.Element).is_enabled
39
+
40
+ @property
41
+ def is_visible(self) -> bool:
42
+ self.ensure_that(self._application_is_ready)
43
+
44
+ return self.adapter.get_strategy(strategies.Element).is_visible
45
+
46
+ @property
47
+ def is_in_view(self) -> bool:
48
+ self.ensure_that(self._application_is_ready)
49
+
50
+ return self.adapter.get_strategy(strategies.Element).is_in_view
51
+
52
+ @property
53
+ def toplevel_parent_is_active(self) -> bool:
54
+ from .window import Window
55
+
56
+ self.ensure_that(self._application_is_ready)
57
+ top_level_window = self.top_level_parent
58
+ if isinstance(top_level_window, Window):
59
+ return top_level_window.is_active
60
+
61
+ return self.adapter.get_strategy(strategies.Element).toplevel_parent_is_active
62
+
63
+ @property
64
+ def bounding_rectangle(self) -> Rect:
65
+ self.ensure_that(self._application_is_ready)
66
+
67
+ return self.adapter.get_strategy(strategies.Element).bounding_rectangle
68
+
69
+ @property
70
+ def visible_rectangle(self) -> Rect:
71
+ self.ensure_that(self._application_is_ready)
72
+
73
+ return self.adapter.get_strategy(strategies.Element).visible_rectangle
74
+
75
+ @property
76
+ def default_click_position(self) -> Point:
77
+ self.ensure_that(self._application_is_ready)
78
+
79
+ return self.adapter.get_strategy(strategies.Element).default_click_position
80
+
81
+ @predicate("element {0} is visible")
82
+ def _element_is_visible(self) -> bool:
83
+ self.ensure_that(self._application_is_ready)
84
+
85
+ return self.adapter.get_strategy(strategies.Element).try_ensure_visible()
86
+
87
+ @predicate("element {0} is enabled")
88
+ def _element_is_enabled(self) -> bool:
89
+ self.ensure_that(self._application_is_ready)
90
+
91
+ return self.adapter.get_strategy(strategies.Element).is_enabled
92
+
93
+ @predicate("element {0} is not readonly")
94
+ def _element_is_not_readonly(self) -> bool:
95
+ self.ensure_that(self._application_is_ready)
96
+
97
+ return not self.adapter.get_strategy(strategies.Element).is_readonly
98
+
99
+ @predicate("application for {0} is ready")
100
+ def _application_is_ready(self) -> bool:
101
+ if not self.is_valid:
102
+ return True
103
+ return self.adapter.get_strategy(strategies.Element).try_ensure_application_is_ready()
104
+
105
+ def is_top_level_element(self) -> bool:
106
+ strategy = self.adapter.get_strategy(strategies.TopLevelElement, False)
107
+ if strategy is None:
108
+ return False
109
+
110
+ return strategy.is_top_level_element
111
+
112
+ @property
113
+ def top_level_parent(self) -> Optional["Element"]:
114
+ self.ensure_that(self._adapter_exists)
115
+
116
+ if not self.is_valid:
117
+ return None
118
+
119
+ parent = self.adapter.get_strategy(strategies.Element).top_level_parent
120
+ if parent is None:
121
+ return None
122
+
123
+ loc = self.locator.create_top_level_locator(parent)
124
+ if loc is None:
125
+ return None
126
+
127
+ result = loc.create_context(None, ContextFactory.find_context_class_for(parent))
128
+ result.adapter = parent
129
+
130
+ return result if isinstance(result, Element) else None
131
+
132
+ @predicate("parent top level parent of element {0} is active")
133
+ def _toplevel_parent_is_active(self) -> bool:
134
+ self.ensure_that(self._application_is_ready)
135
+
136
+ return self.adapter.get_strategy(strategies.Element).try_ensure_toplevel_parent_is_active()
137
+
138
+ def activate_parent_window(self) -> bool:
139
+ return self.ensure_that(self._toplevel_parent_is_active)
140
+
141
+ @predicate("element {0} is in view")
142
+ def _element_is_in_view(self) -> bool:
143
+ self.ensure_that(self._element_is_visible)
144
+
145
+ return self.adapter.get_strategy(strategies.Element).try_bring_into_view()
146
+
147
+ def bring_to_view(self) -> bool:
148
+ return self.ensure_that(self._toplevel_parent_is_active, self._element_is_in_view)
149
+
150
+ def highlight(self, rect: Optional[Rect] = None, time: Optional[float] = None) -> None:
151
+ if time is None:
152
+ time = Settings.current().element_highlight_time
153
+ if rect is None:
154
+ rect = self.bounding_rectangle
155
+ if self.is_visible:
156
+ self.ensure_that(
157
+ self._toplevel_parent_is_active,
158
+ self._element_is_in_view,
159
+ raise_exception=False,
160
+ timeout=Settings.current().element_highlight_ensure_timeout,
161
+ )
162
+
163
+ if self.toplevel_parent_is_active and self.is_in_view:
164
+ cast(UiTechnology, self.adapter.technology).display_device.highlight_rect(rect, time)
165
+
166
+ class _ElementMouseProxy(MouseProxy):
167
+ def __init__(self, element: "Element", mouse_device: MouseDevice):
168
+ super().__init__(mouse_device)
169
+ self._element = element
170
+
171
+ @property
172
+ def base_point(self) -> Point:
173
+ return self._element.bounding_rectangle.top_left
174
+
175
+ @property
176
+ def base_rect(self) -> Rect:
177
+ return self._element.bounding_rectangle
178
+
179
+ @property
180
+ def default_click_position(self) -> Point:
181
+ return self._element.default_click_position
182
+
183
+ def before_action(self, action: MouseProxy.Action) -> None:
184
+ self._element.ensure_that(self._element._toplevel_parent_is_active, self._element._element_is_in_view)
185
+ self.mouse_device.add_context(self._element)
186
+
187
+ def after_action(self, action: MouseProxy.Action) -> None:
188
+ self.mouse_device.remove_context(self._element)
189
+ self._element.ensure_that(self._element._application_is_ready, raise_exception=False)
190
+
191
+ _mouse_proxy: Optional[MouseProxy] = None
192
+
193
+ def _create_mouse_proxy(self, mouse_device: MouseDevice) -> MouseProxy:
194
+ return self._ElementMouseProxy(self, mouse_device)
195
+
196
+ @property
197
+ def mouse(self) -> MouseProxy:
198
+ if self._mouse_proxy is None:
199
+ self._mouse_proxy = self._create_mouse_proxy(cast(UiTechnology, self.adapter.technology).mouse_device)
200
+
201
+ if self._mouse_proxy is None:
202
+ raise NoMouseProxyError("cannot get a valid mouse device")
203
+
204
+ return self._mouse_proxy
205
+
206
+ class _ElementKeyboardProxy(KeyboardProxy):
207
+ def __init__(self, element: "Element", keyboard_device: KeyboardDevice):
208
+ super().__init__(keyboard_device)
209
+ self._element = element
210
+
211
+ def before_action(self, action: KeyboardProxy.Action) -> None:
212
+ self._element.ensure_that(
213
+ self._element._toplevel_parent_is_active,
214
+ self._element._element_is_visible,
215
+ self._element._element_is_in_view,
216
+ )
217
+ self.keyboard_device.add_context(self._element)
218
+
219
+ def after_action(self, action: KeyboardProxy.Action) -> None:
220
+ self.keyboard_device.remove_context(self._element)
221
+ self._element.ensure_that(self._element._application_is_ready, raise_exception=False)
222
+
223
+ _keyboard_proxy: Optional[KeyboardProxy] = None
224
+
225
+ def _create_keyboard_proxy(self, keyboard_device: KeyboardDevice) -> KeyboardProxy:
226
+ return self._ElementKeyboardProxy(self, keyboard_device)
227
+
228
+ @property
229
+ def keyboard(self) -> KeyboardProxy:
230
+ if self._keyboard_proxy is None:
231
+ self._keyboard_proxy = self._create_keyboard_proxy(
232
+ cast(UiTechnology, self.adapter.technology).keyboard_device
233
+ )
234
+
235
+ if self._keyboard_proxy is None:
236
+ raise NoKeyboardProxyError("cannot get a valid keyboard device")
237
+
238
+ return self._keyboard_proxy
239
+
240
+ @property
241
+ def display(self) -> DisplayDevice:
242
+ return cast(UiTechnology, self.adapter.technology).display_device
243
+
244
+ def _before_get_screenshot(self) -> None:
245
+ self.ensure_that(self._toplevel_parent_is_active, self._element_is_in_view)
246
+
247
+ def get_screenshot(
248
+ self, rect: Optional[Rect] = None, format: Optional[str] = None, quality: Optional[int] = None
249
+ ) -> bytearray:
250
+ self._before_get_screenshot()
251
+
252
+ return self.display.get_screenshot(rect if rect is not None else self.bounding_rectangle, format, quality)
253
+
254
+ def save_screenshot(
255
+ self,
256
+ filename: Optional[str] = None,
257
+ rect: Optional[Rect] = None,
258
+ format: Optional[str] = None,
259
+ quality: Optional[int] = None,
260
+ ) -> str:
261
+ self._before_get_screenshot()
262
+
263
+ return self.display.save_screenshot(
264
+ filename, rect if rect is not None else self.bounding_rectangle, format, quality
265
+ )
PlatynUI/ui/graphic.py ADDED
@@ -0,0 +1,14 @@
1
+ from ..core import context
2
+ from .element import *
3
+
4
+ __all__ = ["Graphic"]
5
+
6
+
7
+ @context
8
+ class Graphic(Element):
9
+ pass
10
+
11
+
12
+ @context
13
+ class GraphicItem(Element):
14
+ default_prefix = "item"
PlatynUI/ui/header.py ADDED
@@ -0,0 +1,33 @@
1
+ import typing
2
+
3
+ from ..core import LocatorScope, context
4
+ from . import strategies
5
+ from .control import Control
6
+ from .item import Item
7
+ from .orientation import Orientation
8
+
9
+ __all__ = ["Header", "HeaderItem", "Orientation"]
10
+
11
+
12
+ @context
13
+ class HeaderItem(Item):
14
+ pass
15
+
16
+
17
+ @context
18
+ class Header(Control):
19
+
20
+ @property
21
+ def orientation(self) -> Orientation:
22
+ self.ensure_that(self._application_is_ready)
23
+
24
+ return self.adapter.get_strategy(strategies.HasOrientation).orientation
25
+
26
+ def get_items(self, *args, **kwargs) -> typing.List[HeaderItem]:
27
+ return self.get_all(HeaderItem, scope=LocatorScope.Children, *args, **kwargs)
28
+
29
+ def iter_items(self, *args, **kwargs) -> typing.Iterator[HeaderItem]:
30
+ return self.iter_all(HeaderItem, scope=LocatorScope.Children, *args, **kwargs)
31
+
32
+ def get_item(self, *args, **kwargs) -> HeaderItem:
33
+ return self.get(HeaderItem, scope=LocatorScope.Children, *args, **kwargs)
PlatynUI/ui/item.py ADDED
@@ -0,0 +1,100 @@
1
+ from ..core import context
2
+ from ..core.predicate import predicate
3
+ from . import strategies
4
+ from .element import Element
5
+
6
+ __all__ = ["Item"]
7
+
8
+
9
+ @context
10
+ class Item(Element):
11
+ default_prefix = "item"
12
+
13
+ @predicate("item {0} is editable")
14
+ def _item_is_editable(self):
15
+ return not self.is_readonly
16
+
17
+ @property
18
+ def text(self) -> str:
19
+ self.ensure_that(self._application_is_ready)
20
+
21
+ return self.adapter.get_strategy(strategies.Text).text
22
+
23
+ def activate(self):
24
+ if not self.is_active:
25
+ self.ensure_that(self._element_is_enabled, self._element_is_in_view)
26
+
27
+ self.adapter.get_strategy(strategies.Activatable).activate()
28
+
29
+ self.ensure_that(self._application_is_ready, raise_exception=False)
30
+
31
+ def deactivate(self):
32
+ if self.is_active:
33
+ self.ensure_that(self._element_is_enabled, self._element_is_in_view)
34
+
35
+ self.adapter.get_strategy(strategies.Deactivatable).deactivate()
36
+
37
+ self.ensure_that(self._application_is_ready, raise_exception=False)
38
+
39
+ @property
40
+ def is_active(self) -> bool:
41
+ self.ensure_that(self._application_is_ready)
42
+
43
+ return self.adapter.get_strategy(strategies.HasIsActive).is_active
44
+
45
+ def _item_is_active(self) -> bool:
46
+ if not self.is_active:
47
+ self.activate()
48
+
49
+ return False
50
+ return self.is_active
51
+
52
+ @text.setter
53
+ def text(self, value: str):
54
+ self.set_text(value)
55
+
56
+ def set_text(self, value):
57
+ self.ensure_that(self._item_is_editable, self._item_is_active)
58
+
59
+ self.adapter.get_strategy(strategies.HasEditor).open_editor()
60
+ self.adapter.get_strategy(strategies.EditableText).set_text(value)
61
+ self.adapter.get_strategy(strategies.HasEditor).accept()
62
+
63
+ self.ensure_that(self._application_is_ready, raise_exception=False)
64
+
65
+ def clear(self):
66
+ self.ensure_that(self._item_is_editable)
67
+
68
+ self.adapter.get_strategy(strategies.HasEditor).open_editor()
69
+ self.adapter.get_strategy(strategies.Clearable).clear()
70
+ self.adapter.get_strategy(strategies.HasEditor).accept()
71
+
72
+ self.ensure_that(self._application_is_ready, raise_exception=False)
73
+
74
+ @property
75
+ def is_selectable(self) -> bool:
76
+ self.ensure_that(self._application_is_ready)
77
+
78
+ return self.adapter.get_strategy(strategies.HasSelected).is_selectable
79
+
80
+ @predicate("item {0} is selectable")
81
+ def _item_is_selectable(self):
82
+ return self.is_selectable
83
+
84
+ @property
85
+ def is_selected(self) -> bool:
86
+ self.ensure_that(self._application_is_ready)
87
+
88
+ return self.adapter.get_strategy(strategies.HasSelected).is_selected
89
+
90
+ def select(self):
91
+ self.ensure_that(
92
+ self._toplevel_parent_is_active, self._element_is_in_view, self._element_is_enabled, self._item_is_selectable
93
+ )
94
+
95
+ if not self.is_selected:
96
+ self.adapter.get_strategy(strategies.Selectable).select()
97
+
98
+ self.ensure_that(self._application_is_ready, raise_exception=False)
99
+
100
+ self.ensure_that(self._application_is_ready, raise_exception=False)
PlatynUI/ui/lists.py ADDED
@@ -0,0 +1,37 @@
1
+ import typing
2
+
3
+ from ..core import LocatorScope, context
4
+ from . import strategies
5
+ from .control import Control
6
+ from .item import Item
7
+
8
+ __all__ = ["List", "ListItem"]
9
+
10
+
11
+ @context
12
+ class ListItem(Item):
13
+ def select(self, check_selected: bool = True):
14
+ self.ensure_that(self._toplevel_parent_is_active, self._element_is_in_view, self._element_is_enabled)
15
+
16
+ if not check_selected or not self.is_selected:
17
+ self.adapter.get_strategy(strategies.Selectable).select()
18
+
19
+ self.ensure_that(self._application_is_ready, raise_exception=False)
20
+
21
+
22
+ @context
23
+ class List(Control):
24
+
25
+ def get_items(self, *args, **kwargs) -> typing.List[ListItem]:
26
+ return self.get_all(ListItem, scope=LocatorScope.Children, *args, **kwargs)
27
+
28
+ def iter_items(self, *args, **kwargs) -> typing.Iterator[ListItem]:
29
+ return self.iter_all(ListItem, scope=LocatorScope.Children, *args, **kwargs)
30
+
31
+ def get_item(self, *args, **kwargs) -> ListItem:
32
+ return self.get(ListItem, scope=LocatorScope.Children, *args, **kwargs)
33
+
34
+ def select(self, *args, **kwargs) -> ListItem:
35
+ result = self.get_item(*args, **kwargs)
36
+ result.select(False)
37
+ return result
PlatynUI/ui/menus.py ADDED
@@ -0,0 +1,42 @@
1
+ from typing import Optional
2
+
3
+ from ..core import ContextBase, context
4
+ from . import strategies
5
+ from .control import Control
6
+ from .desktopbase import DesktopBase
7
+ from .window import Window
8
+
9
+ __all__ = ["Menu", "MenuBar", "MenuItem"]
10
+
11
+
12
+ @context
13
+ class Menu(Control):
14
+ pass
15
+
16
+
17
+ @context
18
+ class MenuBar(Control):
19
+ pass
20
+
21
+
22
+ @context
23
+ class MenuItem(Control):
24
+
25
+ def activate(self) -> None:
26
+ items = []
27
+ p: Optional[ContextBase] = self
28
+ while p is not None and not isinstance(p, (Window, DesktopBase)):
29
+ if isinstance(p, MenuItem):
30
+ items.append(p)
31
+
32
+ p = p.parent
33
+
34
+ for i in reversed(items[1:]):
35
+ if not self.toplevel_parent_is_active:
36
+ i.activate()
37
+
38
+ self.ensure_that(self._toplevel_parent_is_active, self._element_is_in_view)
39
+ try:
40
+ self.adapter.get_strategy(strategies.Activatable).activate()
41
+ finally:
42
+ self.ensure_that(self._application_is_ready, raise_exception=False)
@@ -0,0 +1,9 @@
1
+ from enum import IntEnum
2
+
3
+ __all__ = ["Orientation"]
4
+
5
+
6
+ class Orientation(IntEnum):
7
+ NoOrientation = 0
8
+ Horizontal = 1
9
+ Vertical = 2
PlatynUI/ui/pane.py ADDED
@@ -0,0 +1,14 @@
1
+ from ..core import context
2
+ from .control import Control
3
+
4
+ __all__ = ["Pane", "Group"]
5
+
6
+
7
+ @context
8
+ class Pane(Control):
9
+ pass
10
+
11
+
12
+ @context
13
+ class Group(Control):
14
+ pass
@@ -0,0 +1,4 @@
1
+ from .standardproxies import *
2
+
3
+ # this should be empty, proxies should only be registered
4
+ __all__ = []