Skip to content

Commit 33f0247

Browse files
committed
Add comments
1 parent 4a79009 commit 33f0247

File tree

1 file changed

+84
-0
lines changed

1 file changed

+84
-0
lines changed

PyPI/Package/src/webui/webui.py

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,19 @@ def get_bool(self, e: event, index: c_size_t = 0) -> bool:
327327

328328
# Run a JavaScript, and get the response back (Make sure your local buffer can hold the response).
329329
def script(self, script, timeout=0, response_size=(1024 * 8)) -> javascript:
330+
"""Run JavaScript and get the response back.
331+
332+
Args:
333+
script: The JavaScript code to be executed
334+
timeout: The execution timeout in seconds (0 means no timeout)
335+
response_size: The size of response buffer (default: 8KB)
336+
337+
Returns:
338+
javascript: Object containing response data and error status.
339+
340+
Note:
341+
Make sure your local buffer can hold the response.
342+
"""
330343
global lib
331344
if self.window == 0:
332345
_err_window_is_none('script')
@@ -353,6 +366,11 @@ def script(self, script, timeout=0, response_size=(1024 * 8)) -> javascript:
353366

354367
# Run JavaScript quickly with no waiting for the response
355368
def run(self, script):
369+
"""Run JavaScript quickly with no waiting for the response.
370+
371+
Args:
372+
script: The JavaScript code to be executed
373+
"""
356374
global lib
357375
if self.window == 0:
358376
_err_window_is_none('run')
@@ -367,6 +385,11 @@ def run(self, script):
367385

368386
# Set the web-server root folder path for a specific window
369387
def set_root_folder(self, path):
388+
"""Set the web-server root folder path for a specific window.
389+
390+
Args:
391+
path: The local folder full path to be used as root
392+
"""
370393
global lib
371394
if self.window == 0:
372395
_err_window_is_none('set_root_folder')
@@ -381,6 +404,11 @@ def set_root_folder(self, path):
381404

382405
# Allow a specific window address to be accessible from a public network
383406
def set_public(self, status = True):
407+
"""Allow a specific window address to be accessible from a public network.
408+
409+
Args:
410+
status: True to make window public, False for private (default: True)
411+
"""
384412
global lib
385413
if self.window == 0:
386414
_err_window_is_none('set_public')
@@ -395,6 +423,11 @@ def set_public(self, status = True):
395423

396424
#
397425
def set_kiosk(self, status: bool):
426+
"""Set the window in Kiosk mode (Full screen).
427+
428+
Args:
429+
status: True to enable kiosk mode, False to disable
430+
"""
398431
if self.window == 0:
399432
_err_window_is_none('set_kiosk')
400433
return
@@ -403,6 +436,7 @@ def set_kiosk(self, status: bool):
403436

404437
#
405438
def destroy(self):
439+
"""Close the window and free all memory resources."""
406440
if self.window == 0:
407441
_err_window_is_none('destroy')
408442
return
@@ -411,6 +445,12 @@ def destroy(self):
411445

412446
#
413447
def set_icon(self, icon_path, icon_type):
448+
"""Set the default embedded HTML favicon.
449+
450+
Args:
451+
icon_path: The icon file path or content
452+
icon_type: The icon type (e.g., 'image/svg+xml')
453+
"""
414454
if self.window == 0:
415455
_err_window_is_none('set_icon')
416456
return
@@ -419,6 +459,14 @@ def set_icon(self, icon_path, icon_type):
419459

420460
#
421461
def set_hide(self, status: bool):
462+
"""Set a window in hidden mode.
463+
464+
Args:
465+
status: True to hide window, False to show
466+
467+
Note:
468+
Should be called before show().
469+
"""
422470
if self.window == 0:
423471
_err_window_is_none('set_hide')
424472
return
@@ -427,6 +475,12 @@ def set_hide(self, status: bool):
427475

428476
#
429477
def set_size(self, width: int, height: int):
478+
"""Set the window size.
479+
480+
Args:
481+
width: The window width in pixels
482+
height: The window height in pixels
483+
"""
430484
if self.window == 0:
431485
_err_window_is_none('set_size')
432486
return
@@ -435,6 +489,12 @@ def set_size(self, width: int, height: int):
435489

436490
#
437491
def set_position(self, x: int, y: int):
492+
"""Set the window position.
493+
494+
Args:
495+
x: The window X coordinate
496+
y: The window Y coordinate
497+
"""
438498
if self.window == 0:
439499
_err_window_is_none('set_position')
440500
return
@@ -443,6 +503,15 @@ def set_position(self, x: int, y: int):
443503

444504
#
445505
def set_profile(self, name, path):
506+
"""Set the web browser profile to use.
507+
508+
Args:
509+
name: The web browser profile name
510+
path: The web browser profile full path
511+
512+
Note:
513+
Empty name and path means default user profile.
514+
"""
446515
if self.window == 0:
447516
_err_window_is_none('set_profile')
448517
return
@@ -451,6 +520,11 @@ def set_profile(self, name, path):
451520

452521
#
453522
def set_port(self, port: int):
523+
"""Set a custom web-server/websocket network port to be used by WebUI.
524+
525+
Args:
526+
port: The web-server network port WebUI should use
527+
"""
454528
if self.window == 0:
455529
_err_window_is_none('set_port')
456530
return
@@ -459,6 +533,11 @@ def set_port(self, port: int):
459533

460534
#
461535
def get_parent_process_id(self) -> int:
536+
"""Get the ID of the parent process.
537+
538+
Returns:
539+
int: The parent process id
540+
"""
462541
if self.window == 0:
463542
_err_window_is_none('get_parent_process_id')
464543
return
@@ -467,6 +546,11 @@ def get_parent_process_id(self) -> int:
467546

468547
#
469548
def get_child_process_id(self) -> int:
549+
"""Get the ID of the last child process.
550+
551+
Returns:
552+
int: The child process id
553+
"""
470554
if self.window == 0:
471555
_err_window_is_none('get_child_process_id')
472556
return

0 commit comments

Comments
 (0)