예제 #1
0
파일: ac_widget.py 프로젝트: styinx/ACLIB
    def _on_id(self):
        self.size = self.size
        self.position = self.position
        self.visible = self.visible
        self.background = self.background
        self.border = self.border
        self.background_texture = self.background_texture
        self.background_color = self.background_color
        self.border_color = self.border_color
        self.parent = self._parent

        if self.has_id:
            if ac.addOnClickedListener(
                    self.id,
                    ACWidget._event_function(ACWidget.EVENT.ON_MOUSE_DOWN,
                                             self)) == -1:
                console(
                    'Failed to register onClick listener for {}.'.format(self))

        try:
            app_name = None if self.app not in ACWidget.IDS else ACWidget.IDS[
                self.app].title
            WidgetStyle.load_style_from_config(self, self.__class__.__name__,
                                               app_name)
        except Exception as e:
            console('Problems while loading style for class "{}"'.format(
                self.__class__.__name__))
            tb(e)
예제 #2
0
파일: ACLIB.py 프로젝트: styinx/ACLIB
def acUpdate(delta: float):
    ACLIB.TIMER += delta

    # Update every 10 milliseconds.
    if ACLIB.TIMER > 0.01:
        ACLIB.TIMER = 0

        try:
            ac.ext_perfBegin('ACLIB_Standalone')
            ACLIB.AC_DATA.update(delta)
            ac.ext_perfEnd('ACLIB_Standalone')

            # Call the update function for every app stored in the app list.
            for _, app in ACLIB.APPS.items():
                if app.active:
                    try:
                        if not app.no_update:
                            ac.ext_perfBegin(app.title)
                            app.update(delta)
                            ac.ext_perfEnd(app.title)
                    except Exception as e:
                        log('Problems while updating app "{0:s}"'.format(app.title))
                        tb(e)

        except Exception as e:
            tb(e)
예제 #3
0
파일: ACLIB.py 프로젝트: styinx/ACLIB
def acMain(version: int = 0):
    try:
        ACLIB.init()

        # Search for all 'ACLIB_<appname>.py' files in the apps directory.
        files_list = [str(m) for m in os.listdir(APP_DIR) if os.path.isfile(path(APP_DIR, m))]
        for file_name in files_list:
            try:
                # Filename without .py extension
                module = file_name[:file_name.rfind(".")]

                if module.find('ACLIB_') > -1:
                    # Import the app to the current program if not yet done.
                    if module not in sys.modules.keys():
                        importlib.import_module(module)

                    # Initialize the class with the constructor and store it in the app list.
                    class_ctor = getattr(sys.modules[module], module[module.find('ACLIB_') + 6:])

                    class_obj = class_ctor(ACLIB.AC_DATA, ACLIB.AC_META)
                    ACLIB.APPS[class_obj.title] = class_obj
                    log('Init {0:s}'.format(module))

            except Exception as e:
                log('Problems while initializing {0:s}'.format(file_name))
                tb(e)

        ACLIB.AC_DATA.init()

    except Exception as e:
        tb(e)

    return 'ACLIB'
예제 #4
0
파일: event.py 프로젝트: styinx/ACLIB
 def fire(self, event: str, *args):
     """
     Calls the given event name and executes all associated functions.
     :param event: str   Name of the event.
     :param args: tuple  Parameters that are given to the callback functions.
     """
     if event in self._callbacks:
         for _, callback in self._callbacks[event].items():
             try:
                 if len(args) > 0:
                     callback(*args)
                 else:
                     callback()
             except Exception as e:
                 tb(e)
예제 #5
0
파일: ACLIB.py 프로젝트: styinx/ACLIB
def acShutdown():
    try:
        ACLIB.AC_DATA.shutdown()

        # Call the update function for every app stored in the app list.
        for _, app in ACLIB.APPS.items():
            try:
                log('Shutdown {0:s}'.format(app.title))
                app.shutdown()
            except Exception as e:
                log('Problems while shutting down app "{0:s}"'.format(app.title))
                tb(e)

        CONFIG.write()
        ACLIB.shutdown()
    except Exception as e:
        tb(e)
    def __init__(self, model_type: str, source: Union[str, IO] = None):
        self._model_type = model_type
        self._services = {}
        self._valid = False

        if source:
            try:
                if not self.read(source):
                    print('Model was not read successful')
            except BaseException as e:
                print(tb(e))
                print('Something went wrong')
예제 #7
0
 def __init__(self):
     try:
         Devices.MOUSE = Mouse()
         Devices.KEYBOARD = Keyboard()
     except Exception as e:
         tb(e)