Skip to content

Commit 4d022ba

Browse files
committed
New APIs
* New APIs: `myWindow.set_kiosk` `myWindow.destroy` `myWindow.set_icon` `myWindow.set_hide` `myWindow.set_size` `myWindow.set_position` `myWindow.set_profile` `myWindow.get_parent_process_id` `myWindow.get_child_process_id` `myWindow.set_port` `webui.free` `webui.malloc` `webui.send_raw` `webui.clean` `webui.delete_all_profiles` `webui.delete_profile` `webui.set_tls_certificate`
1 parent d7efd5f commit 4d022ba

File tree

1 file changed

+128
-1
lines changed

1 file changed

+128
-1
lines changed

PyPI/Package/src/webui/webui.py

Lines changed: 128 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,86 @@ def set_public(self, status = True):
327327
ctypes.c_bool(status))
328328

329329

330+
#
331+
def set_kiosk(self, status: bool):
332+
if self.window == 0:
333+
_err_window_is_none('set_kiosk')
334+
return
335+
lib.webui_set_kiosk(self.window, ctypes.c_bool(status))
336+
337+
338+
#
339+
def destroy(self):
340+
if self.window == 0:
341+
_err_window_is_none('destroy')
342+
return
343+
lib.webui_destroy(self.window)
344+
345+
346+
#
347+
def set_icon(self, icon_path, icon_type):
348+
if self.window == 0:
349+
_err_window_is_none('set_icon')
350+
return
351+
lib.webui_set_icon(self.window, ctypes.c_char_p(icon_path.encode('utf-8')), ctypes.c_char_p(icon_type.encode('utf-8')))
352+
353+
354+
#
355+
def set_hide(self, status: bool):
356+
if self.window == 0:
357+
_err_window_is_none('set_hide')
358+
return
359+
lib.webui_set_hide(self.window, ctypes.c_bool(status))
360+
361+
362+
#
363+
def set_size(self, width: int, height: int):
364+
if self.window == 0:
365+
_err_window_is_none('set_size')
366+
return
367+
lib.webui_set_size(self.window, ctypes.c_uint(width), ctypes.c_uint(height))
368+
369+
370+
#
371+
def set_position(self, x: int, y: int):
372+
if self.window == 0:
373+
_err_window_is_none('set_position')
374+
return
375+
lib.webui_set_position(self.window, ctypes.c_uint(x), ctypes.c_uint(y))
376+
377+
378+
#
379+
def set_profile(self, name, path):
380+
if self.window == 0:
381+
_err_window_is_none('set_profile')
382+
return
383+
lib.webui_set_profile(self.window, ctypes.c_char_p(name.encode('utf-8')), ctypes.c_char_p(path.encode('utf-8')))
384+
385+
386+
#
387+
def set_port(self, port: int):
388+
if self.window == 0:
389+
_err_window_is_none('set_port')
390+
return
391+
lib.webui_set_port(self.window, ctypes.c_size_t(port))
392+
393+
394+
#
395+
def get_parent_process_id(self) -> int:
396+
if self.window == 0:
397+
_err_window_is_none('get_parent_process_id')
398+
return
399+
return int(lib.webui_get_parent_process_id(self.window))
400+
401+
402+
#
403+
def get_child_process_id(self) -> int:
404+
if self.window == 0:
405+
_err_window_is_none('get_child_process_id')
406+
return
407+
return int(lib.webui_get_child_process_id(self.window))
408+
409+
330410
def _get_current_folder() -> str:
331411
return os.path.dirname(os.path.abspath(__file__))
332412

@@ -408,13 +488,60 @@ def _load_library():
408488
else:
409489
print("Unsupported OS")
410490

411-
412491
# Close all opened windows. webui_wait() will break.
413492
def exit():
414493
global lib
415494
if lib is not None:
416495
lib.webui_exit()
417496

497+
#
498+
def free(ptr):
499+
global lib
500+
if lib is not None:
501+
lib.webui_free(ctypes.c_void_p(ptr))
502+
503+
504+
#
505+
def malloc(size: int) -> int:
506+
global lib
507+
if lib is not None:
508+
return int(lib.webui_malloc(ctypes.c_size_t(size)))
509+
510+
511+
#
512+
def send_raw(window, function, raw, size):
513+
global lib
514+
if lib is not None:
515+
lib.webui_send_raw(window, ctypes.c_char_p(function.encode('utf-8')), ctypes.c_void_p(raw), ctypes.c_size_t(size))
516+
517+
518+
#
519+
def clean():
520+
global lib
521+
if lib is not None:
522+
lib.webui_clean()
523+
524+
525+
#
526+
def delete_all_profiles():
527+
global lib
528+
if lib is not None:
529+
lib.webui_delete_all_profiles()
530+
531+
532+
#
533+
def delete_profile(window):
534+
global lib
535+
if lib is not None:
536+
lib.webui_delete_profile(ctypes.c_size_t(window))
537+
538+
539+
#
540+
def set_tls_certificate(certificate_pem, private_key_pem):
541+
global lib
542+
if lib is not None:
543+
lib.webui_set_tls_certificate(ctypes.c_char_p(certificate_pem.encode('utf-8')), ctypes.c_char_p(private_key_pem.encode('utf-8')))
544+
418545

419546
# Set startup timeout
420547
def set_timeout(second):

0 commit comments

Comments
 (0)