BonPrinter v1.2.0
Thermal Printer tool
Loading...
Searching...
No Matches
Source.app Namespace Reference

Functions

tuple[APPLICATION|None, MainWindowstart_application (bool b_start_app=True, bool test_mode=False)
 Start application.

Variables

 close_event
 log = logging.getLogger(__title__)
 o_app
 o_window
 shared_memory = SHARED_MEMORY(__title__)

Detailed Description


Function Documentation

◆ start_application()

tuple[APPLICATION | None, MainWindow] start_application ( bool b_start_app = True,
bool test_mode = False )

Start application.

Parameters
b_start_app: [True] start application; [False] only app initialization for pytest
test_mode: status if application run in test mode
Returns
windows and application object

Definition at line 28 of file app.py.

28def start_application(b_start_app: bool = True, test_mode: bool = False) -> tuple[APPLICATION | None, MainWindow]:
29 """!
30 @brief Start application
31 @param b_start_app : [True] start application; [False] only app initialization for pytest
32 @param test_mode : status if application run in test mode
33 @return windows and application object
34 """
35 log_config = LogConfig(I_LOG_LEVEL_DEFAULT)
36 log_config.update_log_level(read_verbosity_settings())
37 log.debug("Starting application")
38 log.debug("Running from %s", os.getcwd())
39 if test_mode:
40 log.warning("Test mode is active")
41
42 # Application
43 if b_start_app:
44 app = APPLICATION
45 else:
46 app = None
47 if app is not None:
48 my_app = app(sys.argv)
49 config_app(my_app, icon=ICON_APP) # set icon direct
50 else:
51 my_app = None
52
53 # Set custom application id to show correct icon instead of Python in the task bar
54 try:
55 from ctypes import windll # only exists on windows. # pylint: disable=import-outside-toplevel
56 app_id = __title__ + "." + __version__
57 log.debug("Setting explicit app user model id: %s", app_id)
58 windll.shell32.SetCurrentProcessExplicitAppUserModelID(app_id)
59 except ImportError:
60 pass
61
62 splash = create_splash_screen()
63
64 f_start_time = time.time()
65 config_window(splash, show=True, thread=True)
66
67 if b_start_app and (my_app is not None):
68 config_app(my_app, process_events=True)
69
70 authenticated = True
71
72 # Exception Handler
73 qt_exception_hook = UncaughtHook()
74 window = MainWindow(qt_exception_hook, log_config, test_mode=test_mode, authenticated=authenticated)
75
76 config_window(window, icon=ICON_APP) # set icon again if not set before
77 qt_exception_hook.set_main_window_controller(window)
78
79 f_inti_time = time.time() - f_start_time
80 if f_inti_time < F_MIN_SPLASH_SCREEN_TIME:
81 time.sleep(F_MIN_SPLASH_SCREEN_TIME - f_inti_time)
82
83 config_window(splash, show=False, thread=True)
84
85 return my_app, window
86
87

Variable Documentation

◆ close_event

close_event

Definition at line 93 of file app.py.

◆ log

log = logging.getLogger(__title__)

Definition at line 25 of file app.py.

◆ o_app

o_app

Definition at line 92 of file app.py.

◆ o_window

o_window

Definition at line 92 of file app.py.

◆ shared_memory

shared_memory = SHARED_MEMORY(__title__)

Definition at line 89 of file app.py.