Exemplo n.º 1
0
def get_translation():
    # Set OS language if not already set
    lang = os.environ.get('LANGUAGE')

    if not lang:
        print('Setting language from OS.')
        os.environ.setdefault('LANGUAGE', get_ms_windows_language())
        print('Local Language detected: ' + os.environ.get('LANGUAGE'))

    locale_dir = os.path.join(get_current_modules_dir(), 'locale')

    return translation(APP_NAME, localedir=locale_dir, codeset='UTF-8')
Exemplo n.º 2
0
    def load_ui_resources(cls) -> bool:
        """ update app globals with GUI resource paths """
        ui_paths_file = Path(get_current_modules_dir()) / Path(UI_PATH) / Path(UI_PATHS_FILE)

        if not ui_paths_file.exists():
            print('Could not locate gui resource file: %s. Aborting application.',
                   ui_paths_file.absolute().as_posix())
            return False

        try:
            Settings.load(Resource, ui_paths_file)
        except Exception as e:
            print('Could not load GUI resources from file %s. Aborting application. Error:\n%s',
                   ui_paths_file.absolute().as_posix(), e)
            return False
        return True
Exemplo n.º 3
0
    def from_ui_file(widget_cls, ui_file, custom_widgets=dict()):
        """ Load a Qt .ui file to setup the provided widget """
        # Store current log level and set it to ERROR for Ui load
        LOGGER.info('Loading UI File: %s - %s', type(widget_cls), ui_file)

        current_log_level = logging.root.getEffectiveLevel()
        logging.root.setLevel(logging.ERROR)

        # Load the Ui file
        ui_file = Path(get_current_modules_dir()) / UI_PATH / ui_file
        file = QFile(ui_file.as_posix())
        file.open(QFile.ReadOnly)
        loadUi(file, widget_cls, custom_widgets)
        file.close()

        # Restore previous log level
        logging.root.setLevel(current_log_level)