Exemplo n.º 1
0
def init_pygubu_widgets():
    #initialize standard ttk widgets
    import pygubu.builder.ttkstdwidgets

    #initialize extra widgets
    widgets_pkg = 'pygubu.builder.widgets'
    mwidgets = importlib.import_module(widgets_pkg)
    mwpath = os.path.dirname(mwidgets.__file__)
    for mfile in os.listdir(mwpath):
        if mfile.endswith('.py') and not mfile.startswith('__'):
            modulename = "{0}.{1}".format(widgets_pkg, mfile[:-3])
            try:
                importlib.import_module(modulename)
            except Exception as e:
                logger.exception(e)
                msg = _("Failed to load widget module: \n'{0}'")
                msg = msg.format(modulename)
                messagebox.showerror(_('Error'), msg)

    #initialize custom widgets
    for path in get_custom_widgets():
        dirname, fname = os.path.split(path)
        if fname.endswith('.py'):
            if dirname not in sys.path:
                sys.path.append(dirname)
            modulename = fname[:-3]
            try:
                importlib.import_module(modulename)
            except Exception as e:
                logger.exception(e)
                msg = _("Failed to load custom widget module: \n'{0}'")
                msg = msg.format(path)
                messagebox.showerror(_('Error'), msg)
Exemplo n.º 2
0
def init_pygubu_widgets():
    import pkgutil
    #initialize standard ttk widgets
    import pygubu.builder.ttkstdwidgets

    #initialize extra widgets
    widgets_pkg = 'pygubu.builder.widgets'
    mwidgets = importlib.import_module(widgets_pkg)

    for x, modulename, x in pkgutil.iter_modules(mwidgets.__path__,
                                                 mwidgets.__name__ + "."):
        try:
            importlib.import_module(modulename)
        except Exception as e:
            logger.exception(e)
            msg = _("Failed to load widget module: '%s'")
            msg = msg % (modulename, )
            messagebox.showerror(_('Error'), msg)

    #initialize custom widgets
    for path in get_custom_widgets():
        dirname, fname = os.path.split(path)
        if fname.endswith('.py'):
            if dirname not in sys.path:
                sys.path.append(dirname)
            modulename = fname[:-3]
            try:
                importlib.import_module(modulename)
            except Exception as e:
                logger.exception(e)
                msg = _("Failed to load custom widget module: '%s'")
                msg = msg % (path, )
                messagebox.showerror(_('Error'), msg)
Exemplo n.º 3
0
def init_pygubu_widgets():
    import pkgutil

    # initialize standard ttk widgets
    import pygubu.builder.ttkstdwidgets

    # initialize extra widgets
    widgets_pkg = 'pygubu.builder.widgets'
    mwidgets = importlib.import_module(widgets_pkg)

    for __, modulename, __ in pkgutil.iter_modules(mwidgets.__path__,
                                                   mwidgets.__name__ + "."):
        try:
            importlib.import_module(modulename)
        except Exception as e:
            logger.exception(e)
            msg = _(f"Failed to load widget module: '{modulename}'")
            messagebox.showerror(_('Error'), msg)

    # initialize custom widgets
    for path in map(Path, pref.get_custom_widgets()):
        if not path.match("*.py"):
            continue

        dirname = str(path.parent)
        modulename = path.name[:-3]
        if dirname not in sys.path:
            sys.path.append(dirname)

        try:
            importlib.import_module(modulename)
        except Exception as e:
            logger.exception(e)
            msg = _(f"Failed to load custom widget module: '{path}'")
            messagebox.showerror(_("Error"), msg)

    # initialize custom widget plugins
    for finder, name, ispkg in pkgutil.iter_modules():
        if name.startswith('pygubu_'):
            # TODO: Define how the plugins will expose all builders
            #       to the designer.
            plugin_builders = f'{name}.builders'
            importlib.import_module(plugin_builders)
Exemplo n.º 4
0
Arquivo: main.py Projeto: DaZhu/pygubu
def init_pygubu_widgets():
    #initialize standard ttk widgets
    import pygubu.builder.ttkstdwidgets

    #initialize extra widgets
    widgets_pkg = 'pygubu.builder.widgets'
    mwidgets = importlib.import_module(widgets_pkg)
    mwpath = os.path.dirname(mwidgets.__file__)
    for mfile in os.listdir(mwpath):
        if mfile.endswith('.py') and not mfile.startswith('__'):
            modulename = "{0}.{1}".format(widgets_pkg, mfile[:-3])
            importlib.import_module(modulename)

    #initialize custom widgets
    for path in get_custom_widgets():
        dirname, fname = os.path.split(path)
        if fname.endswith('.py'):
            if dirname not in sys.path:
                sys.path.append(dirname)
            modulename = fname[:-3]
            importlib.import_module(modulename)
Exemplo n.º 5
0
def init_pygubu_widgets():
    #initialize standard ttk widgets
    import pygubu.builder.ttkstdwidgets

    #initialize extra widgets
    widgets_pkg = 'pygubu.builder.widgets'
    mwidgets = importlib.import_module(widgets_pkg)
    mwpath = os.path.dirname(mwidgets.__file__)
    for mfile in os.listdir(mwpath):
        if mfile.endswith('.py') and not mfile.startswith('__'):
            modulename = "{0}.{1}".format(widgets_pkg, mfile[:-3])
            importlib.import_module(modulename)

    #initialize custom widgets
    for path in get_custom_widgets():
        dirname, fname = os.path.split(path)
        if fname.endswith('.py'):
            if dirname not in sys.path:
                sys.path.append(dirname)
            modulename = fname[:-3]
            importlib.import_module(modulename)
Exemplo n.º 6
0
_ = translator

#initialize standard ttk widgets
import pygubu.builder.ttkstdwidgets

#initialize extra widgets
widgets_pkg = 'pygubu.builder.widgets'
mwidgets = importlib.import_module(widgets_pkg)
mwpath = os.path.dirname(mwidgets.__file__)
for mfile in os.listdir(mwpath):
    if mfile.endswith('.py') and not mfile.startswith('__'):
        modulename = "{0}.{1}".format(widgets_pkg, mfile[:-3])
        importlib.import_module(modulename)

#initialize custom widgets
for path in get_custom_widgets():
    dirname, fname = os.path.split(path)
    if fname.endswith('.py'):
        if dirname not in sys.path:
            sys.path.append(dirname)
        modulename = fname[:-3]
        importlib.import_module(modulename)

#Initialize images
DESIGNER_DIR = os.path.dirname(os.path.abspath(__file__))
IMAGES_DIR = os.path.join(DESIGNER_DIR, "images")
StockImage.register_from_dir(IMAGES_DIR)
StockImage.register_from_dir(
    os.path.join(IMAGES_DIR, 'widgets', '22x22'), '22x22-')
StockImage.register_from_dir(
    os.path.join(IMAGES_DIR, 'widgets', '16x16'), '16x16-')