unloading a sub module?

Please post any questions about developing your plugin here. Please use the search function before posting!
stonedegg
Senior Member
Posts: 141
Joined: Sun Aug 12, 2012 11:45 am

unloading a sub module?

Postby stonedegg » Sat Jan 17, 2015 12:23 pm

Hello, I'm currently working on a project with multiple submodules and I'm running into a problem.

Let's say I have it set up like this:

plugins/test/test.py
plugins/test/modules/module.py

And I'm importing module.py in test.py like this:

from test.modules import module

Now when I unload the main script, the unload() function in module.py won't be executed.
Is there any way I can do stuff in module.py when unloading test.py?
Predz
Senior Member
Posts: 158
Joined: Wed Aug 08, 2012 9:05 pm
Location: Bristol, United Kingdom

Postby Predz » Sat Jan 17, 2015 12:27 pm

Inside the "unload" function of "test.py". Just run "module.unload()".

The problem is that the only reason an "unload" function is called upon in your "test.py" file is because when you unload a add-on using SourcePython it is programmed to call them. Unlike when you import a file directly.
User avatar
Mahi
Senior Member
Posts: 236
Joined: Wed Aug 29, 2012 8:39 pm
Location: Finland

Postby Mahi » Sat Jan 17, 2015 12:27 pm

Simple solution would be to call module.py's unload() inside test.py's unload().
stonedegg
Senior Member
Posts: 141
Joined: Sun Aug 12, 2012 11:45 am

Postby stonedegg » Sat Jan 17, 2015 12:59 pm

Oh well, I could have guessed that myself.. thanks :D

Return to “Plugin Development Support”

Who is online

Users browsing this forum: No registered users and 45 guests