Skip to content

Commit 4a79009

Browse files
committed
Add comments
1 parent 10e2c8f commit 4a79009

File tree

1 file changed

+67
-0
lines changed

1 file changed

+67
-0
lines changed

PyPI/Package/src/webui/webui.py

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,15 @@ def _events(self, window: ctypes.c_size_t,
146146

147147
# Bind a specific html element click event with a function. Empty element means all events.
148148
def bind(self, element, func):
149+
"""Bind a specific HTML element click event with a function.
150+
151+
Args:
152+
element: The HTML element / JavaScript object. Empty element means all events.
153+
func: The callback function to be called when the event occurs.
154+
155+
Returns:
156+
The unique bind ID for this event binding.
157+
"""
149158
global lib
150159
if self.window == 0:
151160
_err_window_is_none('bind')
@@ -164,6 +173,18 @@ def bind(self, element, func):
164173

165174
# Show a window using a embedded HTML, or a file. If the window is already opened then it will be refreshed.
166175
def show(self, content="<html></html>", browser:int=browser.ChromiumBased):
176+
"""Show a window using embedded HTML, or a file.
177+
178+
If the window is already opened then it will be refreshed.
179+
This will refresh all windows in multi-client mode.
180+
181+
Args:
182+
content: The HTML content, URL, or a local file path
183+
browser: The web browser to be used (default: ChromiumBased)
184+
185+
Returns:
186+
True if showing the window succeeded.
187+
"""
167188
global lib
168189
if self.window == 0:
169190
_err_window_is_none('show')
@@ -177,6 +198,11 @@ def show(self, content="<html></html>", browser:int=browser.ChromiumBased):
177198

178199
# Chose between Deno and Nodejs runtime for .js and .ts files.
179200
def set_runtime(self, rt=runtime.deno):
201+
"""Choose between Deno and Nodejs runtime for .js and .ts files.
202+
203+
Args:
204+
rt: The runtime to use (deno, nodejs, or none)
205+
"""
180206
global lib
181207
if self.window == 0:
182208
_err_window_is_none('set_runtime')
@@ -190,6 +216,10 @@ def set_runtime(self, rt=runtime.deno):
190216

191217
# Close the window.
192218
def close(self):
219+
"""Close the window.
220+
221+
The window object will still exist but the window will be closed.
222+
"""
193223
global lib
194224
if lib is None:
195225
_err_library_not_found('close')
@@ -198,6 +228,11 @@ def close(self):
198228

199229

200230
def is_shown(self):
231+
"""Check if the window is still running.
232+
233+
Returns:
234+
bool: True if window is running, False otherwise.
235+
"""
201236
global lib
202237
if lib is None:
203238
_err_library_not_found('is_shown')
@@ -207,6 +242,11 @@ def is_shown(self):
207242

208243

209244
def get_url(self) -> str:
245+
"""Get current URL of a running window.
246+
247+
Returns:
248+
str: The full URL string of the window.
249+
"""
210250
global lib
211251
if lib is None:
212252
_err_library_not_found('get_url')
@@ -219,6 +259,15 @@ def get_url(self) -> str:
219259

220260

221261
def get_str(self, e: event, index: c_size_t = 0) -> str:
262+
"""Get an argument as string at a specific index.
263+
264+
Args:
265+
e: The event struct containing the arguments
266+
index: The argument position starting from 0
267+
268+
Returns:
269+
str: The argument value as string.
270+
"""
222271
global lib
223272
if lib is None:
224273
_err_library_not_found('get_str')
@@ -233,6 +282,15 @@ def get_str(self, e: event, index: c_size_t = 0) -> str:
233282

234283

235284
def get_int(self, e: event, index: c_size_t = 0) -> int:
285+
"""Get an argument as integer at a specific index.
286+
287+
Args:
288+
e: The event struct containing the arguments
289+
index: The argument position starting from 0
290+
291+
Returns:
292+
int: The argument value as integer.
293+
"""
236294
global lib
237295
if lib is None:
238296
_err_library_not_found('get_str')
@@ -246,6 +304,15 @@ def get_int(self, e: event, index: c_size_t = 0) -> int:
246304

247305

248306
def get_bool(self, e: event, index: c_size_t = 0) -> bool:
307+
"""Get an argument as boolean at a specific index.
308+
309+
Args:
310+
e: The event struct containing the arguments
311+
index: The argument position starting from 0
312+
313+
Returns:
314+
bool: The argument value as boolean.
315+
"""
249316
global lib
250317
if lib is None:
251318
_err_library_not_found('get_str')

0 commit comments

Comments
 (0)