I am trying to import the modules from my subfolders. Normally I would just import them at the top of the script, but there are going to be a lot, and they are going to be directly related to buttons on a ui.
The folders/modules are laid out like this:
smiles_toolkit |__init__.py |__smiles_tool_kit.py | ----frequent |__init__.py | ----center_pivot |__init__.py |center_pivot.py # inside class named MainFunc() | ----conform |__init__.py |conform.py # inside class named MainFunc() | ----set_to_face |__init__.py |set_to_face.py # inside class named MainFunc()
I am calling the modules with
section = "frequent" btn_name = "center_pivot" btn_module = "smiles_toolkit." + section + "." + btn_name + "." + btn_name try: btn_code = __import__(btn_module, 0) btn_main = btn_code.MainFunc()
At this point I get an
# AttributeError: 'module' object has no attribute 'MainFunc' #
Would anyone know how to deal with this?