Files
Python-With-Gtk-Template/src/__init__.py

51 lines
1.4 KiB
Python
Raw Normal View History

2020-05-07 19:07:33 -05:00
# Python imports
2022-01-23 16:56:27 -06:00
import os, inspect, time
2020-05-07 19:07:33 -05:00
2022-01-23 16:56:27 -06:00
# Lib imports
2020-05-07 19:07:33 -05:00
# Application imports
from utils import Settings
2022-01-23 16:56:27 -06:00
from signal_classes import Controller
2021-10-10 23:28:19 -05:00
from __builtins__ import Builtins
2020-05-07 19:07:33 -05:00
2022-01-23 16:56:27 -06:00
2021-10-10 23:28:19 -05:00
class Main(Builtins):
2022-01-23 16:56:27 -06:00
def __init__(self, args, unknownargs):
if not debug:
event_system.create_ipc_server()
time.sleep(0.2)
if not trace_debug:
if not event_system.is_ipc_alive:
if unknownargs:
for arg in unknownargs:
if os.path.isdir(arg):
message = f"FILE|{arg}"
event_system.send_ipc_message(message)
raise Exception("IPC Server Exists: Will send data to it and close...")
2020-05-07 19:07:33 -05:00
settings = Settings()
2022-01-23 16:56:27 -06:00
settings.create_window()
2020-05-07 19:07:33 -05:00
2022-01-23 17:33:52 -06:00
controller = Controller(settings, args, unknownargs)
2022-01-23 16:56:27 -06:00
if not controller:
raise Exception("Controller exited and doesn't exist...")
2020-05-07 19:07:33 -05:00
2022-01-23 16:56:27 -06:00
# Gets the methods from the classes and sets to handler.
# Then, builder from settings will connect to any signals it needs.
classes = [controller]
2020-05-07 19:07:33 -05:00
handlers = {}
for c in classes:
2021-03-18 00:24:08 -05:00
methods = None
try:
methods = inspect.getmembers(c, predicate=inspect.ismethod)
handlers.update(methods)
except Exception as e:
2022-01-23 16:56:27 -06:00
print(repr(e))
2020-05-07 19:07:33 -05:00
2022-01-23 16:56:27 -06:00
settings.get_builder().connect_signals(handlers)