easywxpython 0.1.0__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.
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
'''
|
|
2
|
+
The UI creation section of this module.
|
|
3
|
+
'''
|
|
4
|
+
import easywxpython as ew
|
|
5
|
+
import wx
|
|
6
|
+
from typing import Union
|
|
7
|
+
|
|
8
|
+
def convert_WindowID_to_Window(input:Union[wx.Window, ew.WindowID])->wx.Window:
|
|
9
|
+
if type(input) == ew.WindowID:
|
|
10
|
+
return input.retrun()
|
|
11
|
+
return input
|
|
12
|
+
|
|
13
|
+
def create_window(input:wx.Window, parent:wx.Window):
|
|
14
|
+
from easywxpython import parent_child_component_manager_instance
|
|
15
|
+
temporary = input
|
|
16
|
+
parent_child_component_manager_instance.set_key_to_value(temporary.Id, {'content':temporary, 'parent_window':parent.Id})
|
|
17
|
+
return ew.WindowID(temporary.Id)
|
|
18
|
+
|
|
19
|
+
def StaticText(parent: Union[wx.Window, ew.WindowID], id: int=wx.ID_ANY, label: str='', pos: wx.Point=wx.DefaultPosition, size: wx.Size=wx.DefaultSize, style: int=0, name: str=wx.StaticTextNameStr):
|
|
20
|
+
'''
|
|
21
|
+
StaticText() -> None
|
|
22
|
+
StaticText(parent, id=ID_ANY, label='', pos=DefaultPosition, size=DefaultSize, style=0, name=StaticTextNameStr) -> None
|
|
23
|
+
|
|
24
|
+
A static text control displays one or more lines of read-only text.
|
|
25
|
+
'''
|
|
26
|
+
return create_window(wx.StaticText(parent=ew.recently_parent_panel(convert_WindowID_to_Window(parent).Id), id=id, label=label, pos=pos, size=size, style=style, name=name), parent)
|
|
27
|
+
|
|
28
|
+
def Button(parent: Union[wx.Window, ew.WindowID], id: int=wx.ID_ANY, label: str='', pos: wx.Point=wx.DefaultPosition, size: wx.Size=wx.DefaultSize, style: int=0, validator: wx.Validator=wx.DefaultValidator, name: str=wx.ButtonNameStr):
|
|
29
|
+
'''
|
|
30
|
+
Button() -> None
|
|
31
|
+
Button(parent, id=ID_ANY, label='', pos=DefaultPosition, size=DefaultSize, style=0, validator=DefaultValidator, name=ButtonNameStr) -> None
|
|
32
|
+
|
|
33
|
+
A button is a control that contains a text string, and is one of the
|
|
34
|
+
most common elements of a GUI.
|
|
35
|
+
'''
|
|
36
|
+
return create_window(wx.Button(parent=ew.recently_parent_panel(convert_WindowID_to_Window(parent).Id), id=id, label=label, pos=pos, size=size, style=style, validator=validator, name=name), parent)
|
|
37
|
+
|
|
38
|
+
def TextCtrl(parent: Union[wx.Window, ew.WindowID], id: int=wx.ID_ANY, value: str='', pos: wx.Point=wx.DefaultPosition, size: wx.Size=wx.DefaultSize, style: int=0, validator: wx.Validator=wx.DefaultValidator, name: str=wx.ButtonNameStr):
|
|
39
|
+
'''
|
|
40
|
+
TextCtrl() -> None
|
|
41
|
+
TextCtrl(parent, id=ID_ANY, value='', pos=DefaultPosition, size=DefaultSize, style=0, validator=DefaultValidator, name=TextCtrlNameStr) -> None
|
|
42
|
+
|
|
43
|
+
A text control allows text to be displayed and edited.
|
|
44
|
+
'''
|
|
45
|
+
return create_window(wx.TextCtrl(parent=ew.recently_parent_panel(convert_WindowID_to_Window(parent).Id), id=id, value=value, pos=pos, size=size, style=style, validator=validator, name=name), parent)
|
|
46
|
+
|
|
47
|
+
def Box(parent: Union[wx.Window, ew.WindowID], id: int=wx.ID_ANY):
|
|
48
|
+
'''
|
|
49
|
+
Box() -> None
|
|
50
|
+
Box(parent, id=ID_ANY) -> None
|
|
51
|
+
|
|
52
|
+
No effect, only used for management.
|
|
53
|
+
'''
|
|
54
|
+
return create_window(wx.StaticText(parent=ew.recently_parent_panel(convert_WindowID_to_Window(parent).Id), id=id), parent)
|
easywxpython/__init__.py
ADDED
|
@@ -0,0 +1,513 @@
|
|
|
1
|
+
'''
|
|
2
|
+
This module simply encapsulates `wxpython`, making it even simpler.
|
|
3
|
+
|
|
4
|
+
Regarding LICENSE, please refer to the corresponding document
|
|
5
|
+
'''
|
|
6
|
+
from . import Ui, Event
|
|
7
|
+
import wx
|
|
8
|
+
from typing import Union, Optional, TypeAlias, Tuple, overload
|
|
9
|
+
|
|
10
|
+
_TwoFloats: TypeAlias = Tuple[float, float]
|
|
11
|
+
|
|
12
|
+
class parent_child_component_manager:
|
|
13
|
+
def __init__(oneself):
|
|
14
|
+
oneself.content = {}
|
|
15
|
+
def set_key_to_value(oneself, key, value):
|
|
16
|
+
oneself.content[key] = value
|
|
17
|
+
# keyID,value{'content':content, 'parent_window':parent_window_ID}
|
|
18
|
+
|
|
19
|
+
def get_the_nearest_parent_window_ID(children_window_ID):
|
|
20
|
+
def internal_get_the_nearest_parent_window_ID(children_window_ID):
|
|
21
|
+
global parent_child_component_manager_instance
|
|
22
|
+
if children_window_ID in parent_child_component_manager_instance.content:
|
|
23
|
+
if type(parent_child_component_manager_instance.content[children_window_ID]['content']) == NewFrame:
|
|
24
|
+
return children_window_ID
|
|
25
|
+
if parent_child_component_manager_instance.content[children_window_ID]['parent_window'] is None:
|
|
26
|
+
return None
|
|
27
|
+
return internal_get_the_nearest_parent_window_ID(parent_child_component_manager_instance.content[children_window_ID]['parent_window'])
|
|
28
|
+
return internal_get_the_nearest_parent_window_ID(children_window_ID)
|
|
29
|
+
|
|
30
|
+
def recently_parent_panel(children_window_ID):
|
|
31
|
+
temporary = get_the_nearest_parent_window_ID(children_window_ID)
|
|
32
|
+
if temporary is not None:
|
|
33
|
+
return WindowID(temporary).retrun().pnl
|
|
34
|
+
return None
|
|
35
|
+
|
|
36
|
+
class WindowAbsent(Exception):
|
|
37
|
+
pass
|
|
38
|
+
|
|
39
|
+
class NewFrame(wx.Frame):
|
|
40
|
+
"""
|
|
41
|
+
A Frame that says Hello World
|
|
42
|
+
"""
|
|
43
|
+
|
|
44
|
+
def __init__(self, *args, **kw):
|
|
45
|
+
# ensure the parent's __init__ is called
|
|
46
|
+
super(NewFrame, self).__init__(*args, **kw)
|
|
47
|
+
|
|
48
|
+
# create a panel in the frame
|
|
49
|
+
self.pnl = wx.Panel(self)
|
|
50
|
+
|
|
51
|
+
# put some text with a larger bold font on it
|
|
52
|
+
# st = wx.StaticText(pnl, label="Hello World!")
|
|
53
|
+
# font = st.GetFont()
|
|
54
|
+
# font.PointSize += 10
|
|
55
|
+
# font = font.Bold()
|
|
56
|
+
# st.SetFont(font)
|
|
57
|
+
|
|
58
|
+
# and create a sizer to manage the layout of child widgets
|
|
59
|
+
self.sizer = wx.BoxSizer(wx.VERTICAL)
|
|
60
|
+
# sizer.Add(st, wx.SizerFlags().Border(wx.TOP|wx.LEFT, 25))
|
|
61
|
+
self.pnl.SetSizer(self.sizer)
|
|
62
|
+
|
|
63
|
+
# and a status bar
|
|
64
|
+
# self.CreateStatusBar()
|
|
65
|
+
# self.SetStatusText("Welcome to wxPython!")
|
|
66
|
+
|
|
67
|
+
def __init__():
|
|
68
|
+
global app
|
|
69
|
+
global parent_child_component_manager_instance
|
|
70
|
+
global additional_data_for_window
|
|
71
|
+
try:
|
|
72
|
+
app
|
|
73
|
+
except:
|
|
74
|
+
app = wx.App()
|
|
75
|
+
parent_child_component_manager_instance = parent_child_component_manager()
|
|
76
|
+
additional_data_for_window = {}
|
|
77
|
+
|
|
78
|
+
class WindowID:
|
|
79
|
+
def __init__(oneself, Id:int):
|
|
80
|
+
global parent_child_component_manager_instance
|
|
81
|
+
oneself.Id = Id
|
|
82
|
+
if oneself.Id not in parent_child_component_manager_instance.content:
|
|
83
|
+
pass
|
|
84
|
+
|
|
85
|
+
def __str__(oneself):
|
|
86
|
+
return str(oneself.Id)
|
|
87
|
+
|
|
88
|
+
def retrun(oneself) -> wx.Window:
|
|
89
|
+
global parent_child_component_manager_instance
|
|
90
|
+
if oneself.Id not in parent_child_component_manager_instance.content:
|
|
91
|
+
raise WindowAbsent('window with ID '+str(oneself.Id)+' does not exist')
|
|
92
|
+
return parent_child_component_manager_instance.content[oneself.Id]['content']
|
|
93
|
+
|
|
94
|
+
def SetTitle(oneself, title: str):
|
|
95
|
+
'''
|
|
96
|
+
SetTitle(title) -> None
|
|
97
|
+
|
|
98
|
+
Sets the window title.
|
|
99
|
+
'''
|
|
100
|
+
if type(oneself.retrun()) == NewFrame:
|
|
101
|
+
oneself.retrun().SetTitle(title)
|
|
102
|
+
else:
|
|
103
|
+
raise TypeError(str(oneself)+'is not frame.')
|
|
104
|
+
|
|
105
|
+
def Show(oneself, show: bool=True):
|
|
106
|
+
'''
|
|
107
|
+
Show(show=True) -> bool
|
|
108
|
+
|
|
109
|
+
Shows or hides the window.
|
|
110
|
+
'''
|
|
111
|
+
oneself.retrun().Show(show)
|
|
112
|
+
|
|
113
|
+
def TimerCreate(oneself, id:int=-1, timer_variable_name:object='__timer__'):
|
|
114
|
+
'''
|
|
115
|
+
TimerCreate(id=-1, timer_variable_name='__timer__') -> None
|
|
116
|
+
|
|
117
|
+
The wxTimer class allows you to execute code at specified intervals.
|
|
118
|
+
'''
|
|
119
|
+
oneself.SetWindowVariables(timer_variable_name, wx.Timer(oneself.retrun(), id))
|
|
120
|
+
|
|
121
|
+
def TimerBind(oneself, handler:function, source=None, id=wx.ID_ANY, id2=wx.ID_ANY):
|
|
122
|
+
'''
|
|
123
|
+
Bind an event to an event handler.
|
|
124
|
+
|
|
125
|
+
:param handler: A callable object to be invoked when the
|
|
126
|
+
event is delivered to self. Pass ``None`` to
|
|
127
|
+
disconnect an event handler.
|
|
128
|
+
|
|
129
|
+
:param source: Sometimes the event originates from a
|
|
130
|
+
different window than self, but you still
|
|
131
|
+
want to catch it in self. (For example, a
|
|
132
|
+
button event delivered to a frame.) By
|
|
133
|
+
passing the source of the event, the event
|
|
134
|
+
handling system is able to differentiate
|
|
135
|
+
between the same event type from different
|
|
136
|
+
controls.
|
|
137
|
+
|
|
138
|
+
:param id: Used to spcify the event source by ID instead
|
|
139
|
+
of instance.
|
|
140
|
+
|
|
141
|
+
:param id2: Used when it is desirable to bind a handler
|
|
142
|
+
to a range of IDs, such as with EVT_MENU_RANGE.
|
|
143
|
+
'''
|
|
144
|
+
oneself.retrun().Bind(wx.EVT_TIMER, handler, source=source, id=id, id2=id2)
|
|
145
|
+
|
|
146
|
+
def TimerStart(oneself, milliseconds: int=-1, oneShot: bool=wx.TIMER_CONTINUOUS, timer_variable_name:object='__timer__')->bool:
|
|
147
|
+
'''
|
|
148
|
+
TimerStart(milliseconds=-1, oneShot=TIMER_CONTINUOUS) -> bool
|
|
149
|
+
|
|
150
|
+
(Re)starts the timer.
|
|
151
|
+
'''
|
|
152
|
+
return oneself.GetWindowVariables(timer_variable_name).Start(milliseconds=milliseconds,oneShot=oneShot)
|
|
153
|
+
|
|
154
|
+
def Timer(oneself, handler:function, timerid:int=-1, timer_variable_name:object='__timer__', source=None, bindid=wx.ID_ANY, bindid2=wx.ID_ANY, milliseconds: int=-1, oneShot: bool=wx.TIMER_CONTINUOUS)->bool:
|
|
155
|
+
oneself.SetWindowVariables(timer_variable_name, wx.Timer(oneself.retrun(), timerid))
|
|
156
|
+
oneself.retrun().Bind(wx.EVT_TIMER, handler, source=source, id=bindid, id2=bindid2)
|
|
157
|
+
return oneself.GetWindowVariables(timer_variable_name).Start(milliseconds=milliseconds,oneShot=oneShot)
|
|
158
|
+
|
|
159
|
+
def GetParent(oneself):
|
|
160
|
+
'''
|
|
161
|
+
GetParent() -> WindowID | None
|
|
162
|
+
|
|
163
|
+
Returns the parent of the window, or nullptr if there is no parent.
|
|
164
|
+
'''
|
|
165
|
+
global parent_child_component_manager_instance
|
|
166
|
+
if oneself.Id in parent_child_component_manager_instance.content:
|
|
167
|
+
if parent_child_component_manager_instance.content[oneself.Id]['parent_window'] is not None:
|
|
168
|
+
return WindowID(parent_child_component_manager_instance.content[oneself.Id]['parent_window'])
|
|
169
|
+
|
|
170
|
+
def GetChildren(oneself):
|
|
171
|
+
'''
|
|
172
|
+
GetChildren() -> List[WindowID]
|
|
173
|
+
|
|
174
|
+
Returns a reference to the list of the window's children.
|
|
175
|
+
'''
|
|
176
|
+
global parent_child_component_manager_instance
|
|
177
|
+
output:list[WindowID] = []
|
|
178
|
+
for key, value in parent_child_component_manager_instance.content.items():
|
|
179
|
+
if value['parent_window'] == oneself.Id:
|
|
180
|
+
output.append(WindowID(key))
|
|
181
|
+
return output
|
|
182
|
+
|
|
183
|
+
def GetWindowVariables(oneself, key):
|
|
184
|
+
global additional_data_for_window
|
|
185
|
+
return additional_data_for_window[oneself.Id][key]
|
|
186
|
+
|
|
187
|
+
def SetWindowVariables(oneself, key, value):
|
|
188
|
+
global additional_data_for_window
|
|
189
|
+
if oneself.Id not in additional_data_for_window:
|
|
190
|
+
additional_data_for_window[oneself.Id] = {}
|
|
191
|
+
additional_data_for_window[oneself.Id][key] = value
|
|
192
|
+
|
|
193
|
+
def Bind(oneself, event, handler, source=None, id=wx.ID_ANY, id2=wx.ID_ANY):
|
|
194
|
+
'''
|
|
195
|
+
Bind an event to an event handler.
|
|
196
|
+
|
|
197
|
+
:param event: One of the ``EVT_*`` event binder objects that
|
|
198
|
+
specifies the type of event to bind.
|
|
199
|
+
|
|
200
|
+
:param handler: A callable object to be invoked when the
|
|
201
|
+
event is delivered to self. Pass ``None`` to
|
|
202
|
+
disconnect an event handler.
|
|
203
|
+
|
|
204
|
+
:param source: Sometimes the event originates from a
|
|
205
|
+
different window than self, but you still
|
|
206
|
+
want to catch it in self. (For example, a
|
|
207
|
+
button event delivered to a frame.) By
|
|
208
|
+
passing the source of the event, the event
|
|
209
|
+
handling system is able to differentiate
|
|
210
|
+
between the same event type from different
|
|
211
|
+
controls.
|
|
212
|
+
|
|
213
|
+
:param id: Used to spcify the event source by ID instead
|
|
214
|
+
of instance.
|
|
215
|
+
|
|
216
|
+
:param id2: Used when it is desirable to bind a handler
|
|
217
|
+
to a range of IDs, such as with EVT_MENU_RANGE.
|
|
218
|
+
'''
|
|
219
|
+
oneself.retrun().Bind(event=event, handler=handler, source=source, id=id, id2=id2)
|
|
220
|
+
|
|
221
|
+
def Clear(oneself):
|
|
222
|
+
'''
|
|
223
|
+
Clear() -> None
|
|
224
|
+
|
|
225
|
+
Destroy all the descendants of the window, but not this window.
|
|
226
|
+
'''
|
|
227
|
+
def internal_clear(clear_target:WindowID):
|
|
228
|
+
for traverse in clear_target.GetChildren():
|
|
229
|
+
internal_clear(traverse)
|
|
230
|
+
clear_target.Destroy()
|
|
231
|
+
for traverse in oneself.GetChildren():
|
|
232
|
+
internal_clear(traverse)
|
|
233
|
+
|
|
234
|
+
def Destroy(oneself):
|
|
235
|
+
'''
|
|
236
|
+
Destroy() -> bool
|
|
237
|
+
|
|
238
|
+
Destroys the window safely.
|
|
239
|
+
'''
|
|
240
|
+
global parent_child_component_manager_instance
|
|
241
|
+
global additional_data_for_window
|
|
242
|
+
oneself.Clear()
|
|
243
|
+
temporary = oneself.retrun().Destroy()
|
|
244
|
+
if temporary:
|
|
245
|
+
if oneself.Id in additional_data_for_window:
|
|
246
|
+
del additional_data_for_window[oneself.Id]
|
|
247
|
+
del parent_child_component_manager_instance.content[oneself.Id]
|
|
248
|
+
return temporary
|
|
249
|
+
|
|
250
|
+
def window_ID(组件):
|
|
251
|
+
if isinstance(组件, wx.Window):
|
|
252
|
+
return 组件.Id
|
|
253
|
+
elif type(组件) == WindowID:
|
|
254
|
+
return 组件.Id
|
|
255
|
+
return None
|
|
256
|
+
|
|
257
|
+
def Frame(show:bool=False, parent: Union[wx.Window, None, WindowID]=None, id: int=wx.ID_ANY, title: str='', pos: wx.Point=wx.DefaultPosition, size: wx.Size=wx.DefaultSize, style: int=wx.DEFAULT_FRAME_STYLE, name: str=wx.FrameNameStr):
|
|
258
|
+
'''
|
|
259
|
+
Frame() -> None
|
|
260
|
+
Frame(parent, id=ID_ANY, title='', pos=DefaultPosition, size=DefaultSize, style=DEFAULT_FRAME_STYLE, name=FrameNameStr) -> None
|
|
261
|
+
|
|
262
|
+
A frame is a window whose size and position can (usually) be changed
|
|
263
|
+
by the user.
|
|
264
|
+
'''
|
|
265
|
+
global parent_child_component_manager_instance
|
|
266
|
+
__init__()
|
|
267
|
+
if type(parent) == WindowID:
|
|
268
|
+
parent = parent.retrun()
|
|
269
|
+
temporary = NewFrame(parent=parent, id=id, title=title, pos=pos, size=size, style=style, name=name)
|
|
270
|
+
if show:
|
|
271
|
+
temporary.Show()
|
|
272
|
+
parent_child_component_manager_instance.content[temporary.Id] = {'content':temporary, 'parent_window':window_ID(parent)}
|
|
273
|
+
return WindowID(temporary.Id)
|
|
274
|
+
|
|
275
|
+
def SetTitle(window_id:Union[wx.Window, WindowID], title: str):
|
|
276
|
+
'''
|
|
277
|
+
SetTitle(window_id, title) -> None
|
|
278
|
+
|
|
279
|
+
Sets the window title.
|
|
280
|
+
'''
|
|
281
|
+
if isinstance(window_id, wx.Window):
|
|
282
|
+
window_id = WindowID(window_id.Id)
|
|
283
|
+
if type(window_id.retrun()) == NewFrame:
|
|
284
|
+
window_id.retrun().SetTitle(title)
|
|
285
|
+
else:
|
|
286
|
+
raise TypeError(str(window_id)+'is not frame.')
|
|
287
|
+
|
|
288
|
+
def Show(window_id:Union[wx.Window, WindowID], show: bool=True):
|
|
289
|
+
'''
|
|
290
|
+
Show(window_id, show=True) -> bool
|
|
291
|
+
|
|
292
|
+
Shows or hides the window.
|
|
293
|
+
'''
|
|
294
|
+
if isinstance(window_id, wx.Window):
|
|
295
|
+
window_id = WindowID(window_id.Id)
|
|
296
|
+
window_id.retrun().Show(show)
|
|
297
|
+
|
|
298
|
+
def TimerCreate(window_id:Union[wx.Window, WindowID], id:int=-1, timer_variable_name:object='__timer__'):
|
|
299
|
+
'''
|
|
300
|
+
TimerCreate(window_id, id=-1, timer_variable_name='__timer__') -> None
|
|
301
|
+
|
|
302
|
+
The wxTimer class allows you to execute code at specified intervals.
|
|
303
|
+
'''
|
|
304
|
+
if isinstance(window_id, wx.Window):
|
|
305
|
+
window_id = WindowID(window_id.Id)
|
|
306
|
+
window_id.SetWindowVariables(timer_variable_name, wx.Timer(window_id.retrun(), id))
|
|
307
|
+
|
|
308
|
+
def TimerBind(window_id:Union[wx.Window, WindowID], handler:function, source=None, id=wx.ID_ANY, id2=wx.ID_ANY):
|
|
309
|
+
'''
|
|
310
|
+
Bind an event to an event handler.
|
|
311
|
+
|
|
312
|
+
:param handler: A callable object to be invoked when the
|
|
313
|
+
event is delivered to self. Pass ``None`` to
|
|
314
|
+
disconnect an event handler.
|
|
315
|
+
|
|
316
|
+
:param source: Sometimes the event originates from a
|
|
317
|
+
different window than self, but you still
|
|
318
|
+
want to catch it in self. (For example, a
|
|
319
|
+
button event delivered to a frame.) By
|
|
320
|
+
passing the source of the event, the event
|
|
321
|
+
handling system is able to differentiate
|
|
322
|
+
between the same event type from different
|
|
323
|
+
controls.
|
|
324
|
+
|
|
325
|
+
:param id: Used to spcify the event source by ID instead
|
|
326
|
+
of instance.
|
|
327
|
+
|
|
328
|
+
:param id2: Used when it is desirable to bind a handler
|
|
329
|
+
to a range of IDs, such as with EVT_MENU_RANGE.
|
|
330
|
+
'''
|
|
331
|
+
if isinstance(window_id, wx.Window):
|
|
332
|
+
window_id = WindowID(window_id.Id)
|
|
333
|
+
window_id.retrun().Bind(wx.EVT_TIMER, handler, source=source, id=id, id2=id2)
|
|
334
|
+
def TimerStart(window_id:Union[wx.Window, WindowID], milliseconds: int=-1, oneShot: bool=wx.TIMER_CONTINUOUS, timer_variable_name:object='__timer__'):
|
|
335
|
+
'''
|
|
336
|
+
TimerStart(window_id, milliseconds=-1, oneShot=TIMER_CONTINUOUS) -> bool
|
|
337
|
+
|
|
338
|
+
(Re)starts the timer.
|
|
339
|
+
'''
|
|
340
|
+
if isinstance(window_id, wx.Window):
|
|
341
|
+
window_id = WindowID(window_id.Id)
|
|
342
|
+
return window_id.GetWindowVariables(timer_variable_name).Start(milliseconds=milliseconds,oneShot=oneShot)
|
|
343
|
+
|
|
344
|
+
def Timer(window_id:Union[wx.Window, WindowID], handler:function, timerid:int=-1, timer_variable_name:object='__timer__', source=None, bindid=wx.ID_ANY, bindid2=wx.ID_ANY, milliseconds: int=-1, oneShot: bool=wx.TIMER_CONTINUOUS)->bool:
|
|
345
|
+
if isinstance(window_id, wx.Window):
|
|
346
|
+
window_id = WindowID(window_id.Id)
|
|
347
|
+
window_id.SetWindowVariables(timer_variable_name, wx.Timer(window_id.retrun(), timerid))
|
|
348
|
+
window_id.retrun().Bind(wx.EVT_TIMER, handler, source=source, id=bindid, id2=bindid2)
|
|
349
|
+
return window_id.GetWindowVariables(timer_variable_name).Start(milliseconds=milliseconds,oneShot=oneShot)
|
|
350
|
+
|
|
351
|
+
def GetParent(window_id:Union[wx.Window, WindowID]):
|
|
352
|
+
'''
|
|
353
|
+
GetParent(window_id) -> WindowID | None
|
|
354
|
+
|
|
355
|
+
Returns the parent of the window, or nullptr if there is no parent.
|
|
356
|
+
'''
|
|
357
|
+
global parent_child_component_manager_instance
|
|
358
|
+
if isinstance(window_id, wx.Window):
|
|
359
|
+
window_id = WindowID(window_id.Id)
|
|
360
|
+
if window_id.Id in parent_child_component_manager_instance.content:
|
|
361
|
+
if parent_child_component_manager_instance.content[window_id.Id]['parent_window'] is not None:
|
|
362
|
+
return WindowID(parent_child_component_manager_instance.content[window_id.Id]['parent_window'])
|
|
363
|
+
|
|
364
|
+
def GetChildren(window_id:Union[wx.Window, WindowID]):
|
|
365
|
+
'''
|
|
366
|
+
GetChildren(window_id) -> List[WindowID]
|
|
367
|
+
|
|
368
|
+
Returns a reference to the list of the window's children.
|
|
369
|
+
'''
|
|
370
|
+
global parent_child_component_manager_instance
|
|
371
|
+
if isinstance(window_id, wx.Window):
|
|
372
|
+
window_id = WindowID(window_id.Id)
|
|
373
|
+
output:list[WindowID] = []
|
|
374
|
+
for key, value in parent_child_component_manager_instance.content.items():
|
|
375
|
+
if value['parent_window'] == window_id.Id:
|
|
376
|
+
output.append(WindowID(key))
|
|
377
|
+
return output
|
|
378
|
+
|
|
379
|
+
def GetWindowVariables(window_id:Union[wx.Window, WindowID], key):
|
|
380
|
+
global additional_data_for_window
|
|
381
|
+
if isinstance(window_id, wx.Window):
|
|
382
|
+
window_id = WindowID(window_id.Id)
|
|
383
|
+
return additional_data_for_window[window_id.Id][key]
|
|
384
|
+
|
|
385
|
+
def SetWindowVariables(window_id:Union[wx.Window, WindowID], key, value):
|
|
386
|
+
global additional_data_for_window
|
|
387
|
+
if isinstance(window_id, wx.Window):
|
|
388
|
+
window_id = WindowID(window_id.Id)
|
|
389
|
+
additional_data_for_window[window_id.Id][key] = value
|
|
390
|
+
|
|
391
|
+
def Bind(window_id:Union[wx.Window, WindowID], event, handler, source=None, id=wx.ID_ANY, id2=wx.ID_ANY):
|
|
392
|
+
'''
|
|
393
|
+
Bind an event to an event handler.
|
|
394
|
+
|
|
395
|
+
:param event: One of the ``EVT_*`` event binder objects that
|
|
396
|
+
specifies the type of event to bind.
|
|
397
|
+
|
|
398
|
+
:param handler: A callable object to be invoked when the
|
|
399
|
+
event is delivered to self. Pass ``None`` to
|
|
400
|
+
disconnect an event handler.
|
|
401
|
+
|
|
402
|
+
:param source: Sometimes the event originates from a
|
|
403
|
+
different window than self, but you still
|
|
404
|
+
want to catch it in self. (For example, a
|
|
405
|
+
button event delivered to a frame.) By
|
|
406
|
+
passing the source of the event, the event
|
|
407
|
+
handling system is able to differentiate
|
|
408
|
+
between the same event type from different
|
|
409
|
+
controls.
|
|
410
|
+
|
|
411
|
+
:param id: Used to spcify the event source by ID instead
|
|
412
|
+
of instance.
|
|
413
|
+
|
|
414
|
+
:param id2: Used when it is desirable to bind a handler
|
|
415
|
+
to a range of IDs, such as with EVT_MENU_RANGE.
|
|
416
|
+
'''
|
|
417
|
+
if isinstance(window_id, wx.Window):
|
|
418
|
+
window_id = WindowID(window_id.Id)
|
|
419
|
+
window_id.retrun().Bind(event=event, handler=handler, source=source, id=id, id2=id2)
|
|
420
|
+
|
|
421
|
+
def Clear(window_id:Union[wx.Window, WindowID]):
|
|
422
|
+
'''
|
|
423
|
+
Clear(window_id) -> None
|
|
424
|
+
|
|
425
|
+
Destroy all the descendants of the window, but not this window.
|
|
426
|
+
'''
|
|
427
|
+
if isinstance(window_id, wx.Window):
|
|
428
|
+
window_id = WindowID(window_id.Id)
|
|
429
|
+
def internal_clear(clear_target:WindowID):
|
|
430
|
+
for traverse in clear_target.GetChildren():
|
|
431
|
+
internal_clear(traverse)
|
|
432
|
+
clear_target.Destroy()
|
|
433
|
+
for traverse in window_id.GetChildren():
|
|
434
|
+
internal_clear(traverse)
|
|
435
|
+
|
|
436
|
+
def Destroy(window_id:Union[wx.Window, WindowID]):
|
|
437
|
+
'''
|
|
438
|
+
Destroy(window_id) -> bool
|
|
439
|
+
|
|
440
|
+
Destroys the window safely.
|
|
441
|
+
'''
|
|
442
|
+
global parent_child_component_manager_instance
|
|
443
|
+
global additional_data_for_window
|
|
444
|
+
if isinstance(window_id, wx.Window):
|
|
445
|
+
window_id = WindowID(window_id.Id)
|
|
446
|
+
window_id.Clear()
|
|
447
|
+
temporary = window_id.retrun().Destroy()
|
|
448
|
+
if temporary:
|
|
449
|
+
if window_id.Id in additional_data_for_window:
|
|
450
|
+
del additional_data_for_window[window_id.Id]
|
|
451
|
+
del parent_child_component_manager_instance.content[window_id.Id]
|
|
452
|
+
return temporary
|
|
453
|
+
|
|
454
|
+
def MainLoop():
|
|
455
|
+
'''
|
|
456
|
+
Execute the main GUI event loop
|
|
457
|
+
'''
|
|
458
|
+
global app
|
|
459
|
+
app.MainLoop()
|
|
460
|
+
|
|
461
|
+
def Point1(x: int, y: int):
|
|
462
|
+
"""
|
|
463
|
+
Point()
|
|
464
|
+
Point(x, y)
|
|
465
|
+
Point(pt)
|
|
466
|
+
|
|
467
|
+
A wxPoint is a useful data structure for graphics operations.
|
|
468
|
+
"""
|
|
469
|
+
return wx.Point(x=x, y=y)
|
|
470
|
+
|
|
471
|
+
def Point2(pt: Union[wx.RealPoint, _TwoFloats]):
|
|
472
|
+
"""
|
|
473
|
+
Point()
|
|
474
|
+
Point(x, y)
|
|
475
|
+
Point(pt)
|
|
476
|
+
|
|
477
|
+
A wxPoint is a useful data structure for graphics operations.
|
|
478
|
+
"""
|
|
479
|
+
return wx.Point(pt)
|
|
480
|
+
|
|
481
|
+
def Point3():
|
|
482
|
+
"""
|
|
483
|
+
Point()
|
|
484
|
+
Point(x, y)
|
|
485
|
+
Point(pt)
|
|
486
|
+
|
|
487
|
+
A wxPoint is a useful data structure for graphics operations.
|
|
488
|
+
"""
|
|
489
|
+
return wx.Point()
|
|
490
|
+
|
|
491
|
+
def Size1(width: int, height: int):
|
|
492
|
+
'''
|
|
493
|
+
Size() -> None
|
|
494
|
+
Size(width, height) -> None
|
|
495
|
+
|
|
496
|
+
A wxSize is a useful data structure for graphics operations.
|
|
497
|
+
'''
|
|
498
|
+
return wx.Size(width, height)
|
|
499
|
+
|
|
500
|
+
def Size2():
|
|
501
|
+
'''
|
|
502
|
+
Size() -> None
|
|
503
|
+
Size(width, height) -> None
|
|
504
|
+
|
|
505
|
+
A wxSize is a useful data structure for graphics operations.
|
|
506
|
+
'''
|
|
507
|
+
return wx.Size()
|
|
508
|
+
|
|
509
|
+
def convert_window_id_to_window(input:WindowID):
|
|
510
|
+
return input.retrun()
|
|
511
|
+
|
|
512
|
+
def convert_window_to_window_id(input:wx.Window):
|
|
513
|
+
return WindowID(input.Id)
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: easywxpython
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: This is a simple wrapper for wxpython
|
|
5
|
+
Home-page: https://codeberg.org/mulp/easywxPython
|
|
6
|
+
Author: mulp
|
|
7
|
+
Author-email: sugmulfsluxppns@eclipso.ch
|
|
8
|
+
License: MIT
|
|
9
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
10
|
+
Classifier: Operating System :: MacOS
|
|
11
|
+
Classifier: Operating System :: MacOS :: MacOS X
|
|
12
|
+
Classifier: Operating System :: Microsoft :: Windows
|
|
13
|
+
Classifier: Operating System :: Microsoft :: Windows :: Windows 7
|
|
14
|
+
Classifier: Operating System :: Microsoft :: Windows :: Windows 10
|
|
15
|
+
Classifier: Operating System :: Microsoft :: Windows :: Windows 11
|
|
16
|
+
Classifier: Operating System :: POSIX
|
|
17
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
18
|
+
Classifier: Topic :: Software Development :: User Interfaces
|
|
19
|
+
Classifier: Development Status :: 3 - Alpha
|
|
20
|
+
Classifier: Programming Language :: Python :: 3
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
23
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
24
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
25
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
26
|
+
Classifier: Environment :: MacOS X :: Cocoa
|
|
27
|
+
Classifier: Environment :: Win32 (MS Windows)
|
|
28
|
+
Classifier: Environment :: X11 Applications :: GTK
|
|
29
|
+
Requires-Dist: wxPython>=4.0
|
|
30
|
+
Dynamic: author
|
|
31
|
+
Dynamic: author-email
|
|
32
|
+
Dynamic: classifier
|
|
33
|
+
Dynamic: description
|
|
34
|
+
Dynamic: home-page
|
|
35
|
+
Dynamic: license
|
|
36
|
+
Dynamic: requires-dist
|
|
37
|
+
Dynamic: summary
|
|
38
|
+
|
|
39
|
+
This is a simple wrapper for wxpython (using only Python), which is not yet fully developed, but supports the most basic dynamic layout functionality.
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
easywxpython/__init__.py,sha256=gHOCblCh4PGtF7KI4CNZ7NqZ5OGh18Vci3kw0Ij368o,20242
|
|
2
|
+
easywxpython/Event/__init__.py,sha256=BECTlCr3aKPyUXUAO7szh4KOPRSvwHMW8e0Lg45YNhQ,234
|
|
3
|
+
easywxpython/Ui/__init__.py,sha256=ZS5Alu9BgW4uqGGGO3pm7L9-ugbBVEt2LxWe8uqdSY0,3001
|
|
4
|
+
easywxpython-0.1.0.dist-info/METADATA,sha256=mlkn8oFUbAi0DHek6OnUY2CW-FRgAzN-cp6em-vtrj8,1620
|
|
5
|
+
easywxpython-0.1.0.dist-info/WHEEL,sha256=YVMoNqKzERt-wjUZwJ33xBGAwnFl-4cqbYkTtWa4itE,91
|
|
6
|
+
easywxpython-0.1.0.dist-info/top_level.txt,sha256=HiYrYiW3BQqW1eBdyTFmJ1ANzfEaMBZ8MHov6SoHe8U,13
|
|
7
|
+
easywxpython-0.1.0.dist-info/RECORD,,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
easywxpython
|