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
@@ -0,0 +1,11 @@
1
+ from enum import IntEnum
2
+
3
+ __all__ = ["MouseButton"]
4
+
5
+
6
+ class MouseButton(IntEnum):
7
+ left = 0
8
+ middle = 1
9
+ right = 2
10
+ x1 = 3
11
+ x2 = 4
@@ -0,0 +1,279 @@
1
+ import abc
2
+ import time
3
+ from typing import Any, Iterator, Optional
4
+
5
+ from ....core.settings import Settings
6
+ from ....core.types import Point, Rect
7
+ from ....robot.reporting import report_as_keyword
8
+ from .basemousedevice import BaseMouseDevice
9
+ from .inputdevice import InputDevice
10
+ from .mousebutton import MouseButton
11
+
12
+ __all__ = ["MouseDevice", "DefaultMouseDevice"]
13
+
14
+
15
+ class MouseDevice(InputDevice):
16
+ __double_click_time: float = 0.4
17
+ __multi_click_delay: Optional[float] = None
18
+ __press_release_delay: Optional[float] = None
19
+ __after_move_delay: Optional[float] = None
20
+ __move_delay: Optional[float] = None
21
+ __move_time: Optional[float] = None
22
+ __after_click_delay: Optional[float] = None
23
+ __before_next_click_delay: Optional[float] = None
24
+
25
+ default_button = MouseButton.left
26
+
27
+ @property
28
+ def double_click_time(self) -> float:
29
+ return self.__double_click_time
30
+
31
+ @double_click_time.setter
32
+ def double_click_time(self, value: float) -> None:
33
+ self.__double_click_time = value
34
+
35
+ @property
36
+ def before_next_click_delay(self) -> float:
37
+ if self.__before_next_click_delay is None:
38
+ return self.double_click_time * Settings.current().mouse_before_next_click_delay_multiplicator
39
+ return self.__before_next_click_delay
40
+
41
+ @before_next_click_delay.setter
42
+ def before_next_click_delay(self, value: Optional[float]) -> None:
43
+ self.__before_next_click_delay = value
44
+
45
+ @property
46
+ def after_click_delay(self) -> float:
47
+ if self.__after_click_delay is None:
48
+ return Settings.current().mouse_after_click_delay
49
+ return self.__after_click_delay
50
+
51
+ @after_click_delay.setter
52
+ def after_click_delay(self, value: Optional[float]) -> None:
53
+ self.__after_click_delay = value
54
+
55
+ @property
56
+ def multi_click_delay(self) -> float:
57
+ if self.__multi_click_delay is None:
58
+ return self.double_click_time * Settings.current().mouse_multi_click_delay_multiplicator
59
+ return self.__multi_click_delay
60
+
61
+ @multi_click_delay.setter
62
+ def multi_click_delay(self, value: Optional[float]) -> None:
63
+ self.__multi_click_delay = value
64
+
65
+ @property
66
+ def press_release_delay(self) -> float:
67
+ if self.__press_release_delay is None:
68
+ return Settings.current().mouse_press_release_delay
69
+ return self.__press_release_delay
70
+
71
+ @press_release_delay.setter
72
+ def press_release_delay(self, value: Optional[float]) -> None:
73
+ self.__press_release_delay = value
74
+
75
+ @property
76
+ def after_move_delay(self) -> float:
77
+ if self.__after_move_delay is None:
78
+ return Settings.current().mouse_after_move_delay
79
+ return self.__after_move_delay
80
+
81
+ @after_move_delay.setter
82
+ def after_move_delay(self, value: Optional[float]) -> None:
83
+ self.__move_time = value
84
+
85
+ @property
86
+ def move_time(self) -> float:
87
+ if self.__move_time is None:
88
+ return Settings.current().mouse_move_time
89
+ return self.__move_time
90
+
91
+ @move_time.setter
92
+ def move_time(self, value: Optional[float]) -> None:
93
+ self.__move_time = value
94
+
95
+ @property
96
+ def move_delay(self) -> float:
97
+ if self.__move_delay is None:
98
+ return Settings.current().mouse_move_delay
99
+ return self.__move_delay
100
+
101
+ @move_delay.setter
102
+ def move_delay(self, value: Optional[float]) -> None:
103
+ self.__move_delay = value
104
+
105
+ def add_context(self, context: Any) -> None:
106
+ pass
107
+
108
+ def remove_context(self, context: Any) -> None:
109
+ pass
110
+
111
+ @abc.abstractmethod
112
+ def get_position(self) -> Point:
113
+ pass
114
+
115
+ @abc.abstractmethod
116
+ def move_to(
117
+ self, pos: Point = None, x: Optional[float] = None, y: Optional[float] = None, raise_exception: bool = True
118
+ ) -> Optional[Point]:
119
+ pass
120
+
121
+ @abc.abstractmethod
122
+ def press(
123
+ self, pos: Point = None, x: Optional[float] = None, y: Optional[float] = None, button: MouseButton = None
124
+ ) -> Optional[Point]:
125
+ pass
126
+
127
+ @abc.abstractmethod
128
+ def release(
129
+ self, pos: Point = None, x: Optional[float] = None, y: Optional[float] = None, button: MouseButton = None
130
+ ) -> Optional[Point]:
131
+ pass
132
+
133
+ @abc.abstractmethod
134
+ def click(
135
+ self,
136
+ pos: Point = Point(),
137
+ x: Optional[float] = None,
138
+ y: Optional[float] = None,
139
+ button: MouseButton = None,
140
+ times: int = 1,
141
+ ) -> Optional[Point]:
142
+ pass
143
+
144
+
145
+ class DefaultMouseDevice(MouseDevice):
146
+ __base_mouse_device = None # type: BaseMouseDevice
147
+
148
+ def __init__(self, base_mouse_device: BaseMouseDevice):
149
+ self.__base_mouse_device = base_mouse_device
150
+ self.double_click_time = self.__base_mouse_device.double_click_time
151
+
152
+ @property
153
+ def base_mouse_device(self) -> BaseMouseDevice:
154
+ return self.__base_mouse_device
155
+
156
+ def get_position(self) -> Point:
157
+ return self.__base_mouse_device.get_position()
158
+
159
+ def _generate_move_events(self, start_pos: Point, end_pos: Point) -> Iterator[Point]:
160
+ start_time = time.monotonic()
161
+ end_time = start_time + self.move_time
162
+
163
+ while True:
164
+ current_time = end_time - time.monotonic()
165
+ if current_time > 0:
166
+ step = current_time / self.move_time
167
+
168
+ yield Point((1 - step) * end_pos.x + step * start_pos.x, (1 - step) * end_pos.y + step * start_pos.y)
169
+ else:
170
+ break
171
+
172
+ @report_as_keyword
173
+ def move_to(
174
+ self, pos: Point = None, x: Optional[float] = None, y: Optional[float] = None, raise_exception: bool = True
175
+ ) -> Point:
176
+ if pos is None:
177
+ pos = Point()
178
+
179
+ start_pos = self.get_position()
180
+ if not pos:
181
+ pos = start_pos.clone()
182
+
183
+ if x is not None:
184
+ pos.x = x
185
+ if y is not None:
186
+ pos.y = y
187
+
188
+ if pos and pos != start_pos:
189
+ if self.move_time > 0 and self.move_delay < self.move_time:
190
+ for p in self._generate_move_events(start_pos, pos):
191
+ self.__base_mouse_device.move_to(p)
192
+ self.delay(self.move_delay)
193
+
194
+ self.__base_mouse_device.move_to(pos)
195
+
196
+ self.delay(self.after_move_delay)
197
+ self.delay(self.after_input_delay)
198
+ else:
199
+ if not pos and raise_exception:
200
+ raise Exception("invalid position %s" % pos)
201
+
202
+ return pos
203
+
204
+ @report_as_keyword
205
+ def press(
206
+ self, pos: Point = None, x: Optional[float] = None, y: Optional[float] = None, button: MouseButton = None
207
+ ) -> Optional[Point]:
208
+ if button is None:
209
+ button = self.default_button
210
+
211
+ result = self.move_to(pos=pos, x=x, y=y, raise_exception=False)
212
+
213
+ self.__base_mouse_device.press(button)
214
+
215
+ self.delay(self.press_release_delay)
216
+ self.delay(self.after_input_delay)
217
+
218
+ return result
219
+
220
+ @report_as_keyword
221
+ def release(
222
+ self, pos: Point = None, x: Optional[float] = None, y: Optional[float] = None, button: MouseButton = None
223
+ ) -> Optional[Point]:
224
+ if button is None:
225
+ button = self.default_button
226
+
227
+ result = self.move_to(pos=pos, x=x, y=y, raise_exception=False)
228
+
229
+ self.__base_mouse_device.release(button)
230
+
231
+ self.delay(self.press_release_delay)
232
+ self.delay(self.after_input_delay)
233
+
234
+ return result
235
+
236
+ _last_click_time: float = 0
237
+ _last_click_pos: Point = Point()
238
+ _last_click_rect = Rect()
239
+
240
+ def _calc_last_click_rect(self, p: Point) -> Rect:
241
+ size = self.__base_mouse_device.double_click_size
242
+
243
+ return Rect(p.x - size.width / 2, p.y - size.height / 2, size.width, size.height)
244
+
245
+ @report_as_keyword
246
+ def click(
247
+ self,
248
+ pos: Point = Point(),
249
+ x: Optional[float] = None,
250
+ y: Optional[float] = None,
251
+ button: Optional[MouseButton] = None,
252
+ times: int = 1,
253
+ ) -> Optional[Point]:
254
+ last_click_time_span = time.time() - self._last_click_time
255
+
256
+ if button is None:
257
+ button = self.default_button
258
+
259
+ result = self.move_to(pos=pos, x=x, y=y, raise_exception=False)
260
+
261
+ if self._last_click_rect.contains(result) and last_click_time_span < self.before_next_click_delay:
262
+ self.delay(self.before_next_click_delay - last_click_time_span)
263
+
264
+ for i in range(times):
265
+ if i > 0:
266
+ self.delay(self.multi_click_delay)
267
+
268
+ self.__base_mouse_device.press(button)
269
+ self.delay(self.press_release_delay)
270
+ self.__base_mouse_device.release(button)
271
+
272
+ self._last_click_time = time.time()
273
+ self._last_click_pos = result
274
+ self._last_click_rect = self._calc_last_click_rect(result)
275
+
276
+ self.delay(self.after_click_delay)
277
+ self.delay(self.after_input_delay)
278
+
279
+ return result
@@ -0,0 +1,178 @@
1
+ import enum
2
+ from abc import ABCMeta, abstractmethod
3
+ from typing import Any, Optional, cast
4
+
5
+ from ....core import Adapter, InvalidArgumentError
6
+ from ....core.types import Point, Rect, VirtualPoint
7
+ from ... import strategies
8
+ from ..ui_technology import UiTechnology
9
+ from .mousebutton import MouseButton
10
+ from .mousedevice import MouseDevice
11
+
12
+ __all__ = ["MouseProxy", "MouseButton", "AdapterMouseProxy"]
13
+
14
+
15
+ class MouseProxy(metaclass=ABCMeta):
16
+ def __init__(self, mouse_device: MouseDevice):
17
+ self._mouse_device = mouse_device
18
+
19
+ def __enter__(self) -> "MouseProxy":
20
+ return self
21
+
22
+ def __exit__(self, exc_type: Any, exc_val: Any, exc_tb: Any) -> None:
23
+ pass
24
+
25
+ @property
26
+ def mouse_device(self) -> MouseDevice:
27
+ return self._mouse_device
28
+
29
+ @property
30
+ @abstractmethod
31
+ def base_point(self) -> Point: ...
32
+
33
+ @property
34
+ @abstractmethod
35
+ def base_rect(self) -> Rect: ...
36
+
37
+ @property
38
+ def default_click_position(self) -> Point:
39
+ return Point(0, 0)
40
+
41
+ class Action(enum.Enum):
42
+ MOVE = 1
43
+ PRESS = 2
44
+ RELEASE = 3
45
+ CLICK = 4
46
+ DOUBLE_CLICK = 6
47
+
48
+ def before_action(self, action: Action) -> None:
49
+ pass
50
+
51
+ def after_action(self, action: Action) -> None:
52
+ pass
53
+
54
+ def _calc_mouse_point(
55
+ self, pos: Optional[Point] = None, x: Optional[float] = None, y: Optional[float] = None
56
+ ) -> Point:
57
+ if pos is None:
58
+ pos = Point()
59
+ if not isinstance(pos, Point):
60
+ raise InvalidArgumentError("pos must be of type Point")
61
+
62
+ if isinstance(pos, VirtualPoint):
63
+ default = pos.calc_rect(self.base_rect)
64
+ base = self._mouse_device.get_position()
65
+ if not default.x_is_valid():
66
+ default.x = base.x
67
+ if not default.y_is_valid():
68
+ default.y = base.y
69
+ pos = Point(default.x if x is None else base.x, default.y if y is None else base.y)
70
+ elif not pos:
71
+ default = self.default_click_position
72
+ base = self.base_point
73
+ pos.x = default.x if x is None else base.x
74
+ pos.y = default.y if y is None else base.y
75
+ else:
76
+ pos = self.base_point + pos if self.base_point is not None else pos
77
+
78
+ if x is not None:
79
+ pos.x += x
80
+
81
+ if y is not None:
82
+ pos.y += y
83
+
84
+ return pos
85
+
86
+ def move_to(self, pos: Point = None, x: Optional[float] = None, y: Optional[float] = None) -> Optional[Point]:
87
+ self.before_action(MouseProxy.Action.MOVE)
88
+
89
+ result = self.mouse_device.move_to(self._calc_mouse_point(pos, x, y))
90
+
91
+ self.after_action(MouseProxy.Action.MOVE)
92
+
93
+ return result
94
+
95
+ def press(
96
+ self,
97
+ pos: Point = None,
98
+ x: Optional[float] = None,
99
+ y: Optional[float] = None,
100
+ button: Optional[MouseButton] = None,
101
+ ) -> Optional[Point]:
102
+ self.before_action(MouseProxy.Action.PRESS)
103
+
104
+ result = self.mouse_device.press(self._calc_mouse_point(pos, x, y), button=button)
105
+
106
+ self.after_action(MouseProxy.Action.PRESS)
107
+
108
+ return result
109
+
110
+ def release(
111
+ self,
112
+ pos: Point = None,
113
+ x: Optional[float] = None,
114
+ y: Optional[float] = None,
115
+ button: Optional[MouseButton] = None,
116
+ ) -> Optional[Point]:
117
+ self.before_action(MouseProxy.Action.RELEASE)
118
+
119
+ result = self.mouse_device.release(self._calc_mouse_point(pos, x, y), button=button)
120
+
121
+ self.after_action(MouseProxy.Action.RELEASE)
122
+
123
+ return result
124
+
125
+ def click(
126
+ self,
127
+ pos: Point = None,
128
+ x: Optional[float] = None,
129
+ y: Optional[float] = None,
130
+ button: Optional[MouseButton] = None,
131
+ times: int = 1,
132
+ ) -> Optional[Point]:
133
+ self.before_action(MouseProxy.Action.CLICK)
134
+
135
+ result = self.mouse_device.click(self._calc_mouse_point(pos, x, y), button=button, times=times)
136
+
137
+ self.after_action(MouseProxy.Action.CLICK)
138
+
139
+ return result
140
+
141
+ def double_click(
142
+ self,
143
+ pos: Point = None,
144
+ x: Optional[float] = None,
145
+ y: Optional[float] = None,
146
+ button: Optional[MouseButton] = None,
147
+ ) -> Optional[Point]:
148
+ self.before_action(MouseProxy.Action.DOUBLE_CLICK)
149
+
150
+ result = self.click(pos, x, y, button, 2)
151
+
152
+ self.after_action(MouseProxy.Action.DOUBLE_CLICK)
153
+
154
+ return result
155
+
156
+
157
+ class AdapterMouseProxy(MouseProxy):
158
+ def __init__(self, adapter: Adapter, mouse_device: MouseDevice = None):
159
+ super().__init__(mouse_device or cast(UiTechnology, adapter.technology).mouse_device)
160
+ self._adapter = adapter
161
+
162
+ @property
163
+ def base_point(self) -> Point:
164
+ return self._adapter.get_strategy(strategies.Element).bounding_rectangle.top_left
165
+
166
+ @property
167
+ def base_rect(self) -> Rect:
168
+ return self._adapter.get_strategy(strategies.Element).bounding_rectangle
169
+
170
+ @property
171
+ def default_click_position(self) -> Point:
172
+ return self._adapter.get_strategy(strategies.Element).default_click_position
173
+
174
+ def before_action(self, action: MouseProxy.Action) -> None:
175
+ self.mouse_device.add_context(self._adapter)
176
+
177
+ def after_action(self, action: MouseProxy.Action) -> None:
178
+ self.mouse_device.remove_context(self._adapter)
@@ -0,0 +1,31 @@
1
+ from abc import abstractmethod
2
+
3
+ from ...core.technology import Technology
4
+ from .devices.displaydevice import DisplayDevice
5
+ from .devices.keyboarddevice import KeyboardDevice
6
+ from .devices.mousedevice import MouseDevice
7
+ from .window_manager import WindowManager
8
+
9
+ __all__ = ["UiTechnology"]
10
+
11
+
12
+ class UiTechnology(Technology):
13
+ @property
14
+ @abstractmethod
15
+ def mouse_device(self) -> MouseDevice:
16
+ pass
17
+
18
+ @property
19
+ @abstractmethod
20
+ def keyboard_device(self) -> KeyboardDevice:
21
+ pass
22
+
23
+ @property
24
+ @abstractmethod
25
+ def display_device(self) -> DisplayDevice:
26
+ pass
27
+
28
+ @property
29
+ @abstractmethod
30
+ def window_manager(self) -> WindowManager:
31
+ pass
@@ -0,0 +1,59 @@
1
+ from abc import abstractmethod
2
+
3
+ from ...core import StrategyBase
4
+ from ...core.types import Point, Size
5
+
6
+ __all__ = ["WindowManager"]
7
+
8
+
9
+ # noinspection PyShadowingBuiltins
10
+ class WindowManager(StrategyBase):
11
+ strategy_name = "org.platynui.WindowManager"
12
+
13
+ @property
14
+ @abstractmethod
15
+ def window_manager_present(self) -> bool:
16
+ pass
17
+
18
+ @property
19
+ @abstractmethod
20
+ def window_manager_name(self) -> str:
21
+ pass
22
+
23
+ @property
24
+ @abstractmethod
25
+ def root_window_id(self) -> bytes:
26
+ pass
27
+
28
+ @property
29
+ @abstractmethod
30
+ def active_window(self) -> bytes:
31
+ pass
32
+
33
+ @abstractmethod
34
+ def activate_window(self, id: bytes) -> None:
35
+ pass
36
+
37
+ @abstractmethod
38
+ def maximize_window(self, id: bytes) -> None:
39
+ pass
40
+
41
+ @abstractmethod
42
+ def minimize_window(self, id: bytes) -> None:
43
+ pass
44
+
45
+ @abstractmethod
46
+ def restore_window(self, id: bytes) -> None:
47
+ pass
48
+
49
+ @abstractmethod
50
+ def close_window(self, id: bytes) -> None:
51
+ pass
52
+
53
+ @abstractmethod
54
+ def move_window(self, id: bytes, pos: Point) -> None:
55
+ pass
56
+
57
+ @abstractmethod
58
+ def resize_window(self, id: bytes, size: Size) -> None:
59
+ pass
@@ -0,0 +1,56 @@
1
+ from ..core import Point, Rect
2
+ from .core.devices import KeyboardDevice, MouseDevice
3
+ from .core.devices.keyboardproxy import KeyboardProxy
4
+ from .core.devices.mouseproxy import MouseProxy
5
+ from .element import Element
6
+
7
+ __all__ = ["DesktopBase"]
8
+
9
+
10
+ class DesktopBase(Element):
11
+ default_role = "Desktop"
12
+
13
+ class _DesktopMouseProxy(MouseProxy):
14
+ def __init__(self, element: "DesktopBase", mouse_device: MouseDevice):
15
+ super().__init__(mouse_device)
16
+ self._element = element
17
+
18
+ @property
19
+ def base_point(self) -> Point:
20
+ return self._element.bounding_rectangle.top_left
21
+
22
+ @property
23
+ def base_rect(self) -> Rect:
24
+ return self._element.bounding_rectangle
25
+
26
+ @property
27
+ def default_click_position(self) -> Point:
28
+ return self._element.default_click_position
29
+
30
+ def before_action(self, action: MouseProxy.Action) -> None:
31
+ self._element.ensure_that(self._element._adapter_exists)
32
+ self.mouse_device.add_context(self._element)
33
+
34
+ def after_action(self, action: MouseProxy.Action) -> None:
35
+ self.mouse_device.remove_context(self._element)
36
+
37
+ def _create_mouse_proxy(self, mouse_device: MouseDevice) -> MouseProxy:
38
+ return self._DesktopMouseProxy(self, mouse_device)
39
+
40
+ class _DesktopKeyboardProxy(KeyboardProxy):
41
+ def __init__(self, element: "DesktopBase", keyboard_device: KeyboardDevice):
42
+ super().__init__(keyboard_device)
43
+ self._element = element
44
+
45
+ def before_action(self, action: KeyboardProxy.Action) -> None:
46
+ self._element.ensure_that(self._element._adapter_exists)
47
+ self.keyboard_device.add_context(self._element)
48
+
49
+ def after_action(self, action: KeyboardProxy.Action) -> None:
50
+ self.keyboard_device.remove_context(self._element)
51
+
52
+ def _create_keyboard_proxy(self, keyboard_device: KeyboardDevice) -> KeyboardProxy:
53
+ return self._DesktopKeyboardProxy(self, keyboard_device)
54
+
55
+ def _before_get_screenshot(self) -> None:
56
+ pass
PlatynUI/ui/dialog.py ADDED
@@ -0,0 +1,10 @@
1
+ from ..core import context
2
+ from .window import *
3
+
4
+ __all__ = ["Dialog"]
5
+
6
+
7
+ @context
8
+ class Dialog(Window):
9
+ # TODO: modal state and so on
10
+ pass
PlatynUI/ui/edit.py ADDED
@@ -0,0 +1,48 @@
1
+ from ..core import context
2
+ from . import strategies
3
+ from .text import Text
4
+
5
+ __all__ = ["Edit"]
6
+
7
+
8
+ @context
9
+ class Edit(Text):
10
+
11
+ @property
12
+ def text(self) -> str:
13
+ return super().text
14
+
15
+ @text.setter
16
+ def text(self, value: str) -> None:
17
+ self.set_text(value)
18
+
19
+ def set_text(self, value: str) -> None:
20
+ self.ensure_that(
21
+ self._toplevel_parent_is_active,
22
+ self._element_is_in_view,
23
+ self._element_is_enabled,
24
+ self._element_is_not_readonly,
25
+ self._control_has_focus,
26
+ )
27
+ try:
28
+ self.adapter.get_strategy(strategies.EditableText).set_text(value)
29
+ finally:
30
+ self.ensure_that(self._application_is_ready, raise_exception=False)
31
+
32
+ def clear(self) -> None:
33
+ self.ensure_that(
34
+ self._toplevel_parent_is_active,
35
+ self._element_is_in_view,
36
+ self._element_is_enabled,
37
+ self._element_is_not_readonly,
38
+ self._control_has_focus,
39
+ )
40
+ try:
41
+ self.adapter.get_strategy(strategies.Clearable).clear()
42
+ finally:
43
+ self.ensure_that(self._application_is_ready, raise_exception=False)
44
+
45
+ def is_multiline(self) -> bool:
46
+ self.ensure_that(self._application_is_ready)
47
+
48
+ return self.adapter.get_strategy(strategies.HasMultiLine).is_multi_line