-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpicklevw.py
50 lines (36 loc) · 1.15 KB
/
picklevw.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
"""
This module initializes, runs and destroy a window object.
It also ensures thread safety.
"""
from __future__ import annotations
import ctypes
from src.widgets import set_options
from src.window import PicklevwTkWindow
from src.mediator import Mediator
from src.logic import output_queue, terminate_all_processes
# Initialize X11 threads for thread safety in GUI applications
ctypes.CDLL("libX11.so.6").XInitThreads()
# Set options for widgets
set_options()
# Instance of PicklevwTkWindow
pw = PicklevwTkWindow()
def exit_function():
"""
Function to terminate all processes and destroy the custom window.
Called when the window is requested to close.
"""
terminate_all_processes()
pw.destroy()
# Setup
pw.setup_frames()
pw.setup_widgets()
pw.setup_rows()
pw.setup_cols()
# Mediator
med = Mediator(pw.widgets["btn_load"], pw.widgets["btn_theme"], pw)
# Update the text widget
pw.loop_start_text_widget(pw.widgets["picklevw_tk_frame"], output_queue)
# Set the window protocol to call exit_function when the window is requested to close
pw.protocol("WM_DELETE_WINDOW", exit_function)
# Start the main loop of the custom window
pw.mainloop()