__init__.py 1.55 KB
Newer Older
1
import glob
2 3 4
import os
import platform

5 6 7
import wx

from MDANSE import PLATFORM
8
from MDANSE.Externals.pubsub import pub as PUBLISHER
9

10 11 12
# Hack for the (in)famous "(python:865): LIBDBUSMENU-GLIB-WARNING **: Trying to remove a child that doesn't believe we're it's parent."
if platform.dist()[0].lower() == "ubuntu":
    os.environ["UBUNTU_MENUPROXY"] = "0" 
13 14 15

if PLATFORM.name == "macos":
    wx.SystemOptions.SetOption("osx.openfiledialog.always-show-types","1")
16
        
17
from MDANSE import REGISTRY
18 19 20
from MDANSE.GUI.Plugins.DataPlugin import DataPlugin 
from MDANSE.GUI.Plugins.JobPlugin import JobPlugin

21 22 23
REGISTRY.update(os.path.join(os.path.dirname(__file__),"Handlers"))
REGISTRY.update(os.path.join(os.path.dirname(__file__),"Plugins"))
REGISTRY.update(os.path.join(os.path.dirname(__file__),"Widgets"))
24 25 26

for job in REGISTRY["job"].values():

27
    if not hasattr(job, "_type"):
28
        continue
29
                    
30
    attrs = {"_type"     : job._type,
31 32
             "ancestor"  : getattr(job,'ancestor',job.ancestor),
             "category"  : getattr(job, "category", ("Miscellaneous",)),
33
             "label"     : getattr(job, "label", job.__name__)}
34

35
    kls = type("%sPlugin" % job.__name__, (JobPlugin,), attrs)
36
    REGISTRY[job._type] = kls
37 38

for data in REGISTRY["input_data"].values():
39

40
    if not hasattr(data, "_type"):
41
        continue
42

43
    attrs = {"_type"    : data._type, 
44
             "label"    : " ".join("".split("_")).capitalize(),
45
             "ancestor" : ['empty_data']}
46
    kls = type("%sPlugin" % data.__name__, (DataPlugin,), attrs)
47
    REGISTRY[data._type] = kls