39 lines
991 B
Python
39 lines
991 B
Python
import importlib
|
|
import FreeCADGui as Gui
|
|
import os
|
|
import sys
|
|
|
|
from .. import settings
|
|
from ..project import Project
|
|
|
|
class Reload:
|
|
def GetResources(self):
|
|
tooltip = '<p>Reload KiConnect Workbench for development.\nNOTE: Does not reload toolbars.</p>'
|
|
iconFile = os.path.join(settings.ICONPATH, 'kiconnect.svg')
|
|
|
|
return {
|
|
'MenuText': 'Reload KiConnect',
|
|
'ToolTip': tooltip,
|
|
'Pixmap' : iconFile
|
|
}
|
|
|
|
def Activated(self):
|
|
try:
|
|
Gui.activateWorkbench('PartWorkbench')
|
|
except:
|
|
print('failed to switch to Part WB')
|
|
|
|
try:
|
|
Gui.removeWorkbench('KiConnect')
|
|
except:
|
|
print('failed to remove KiConnect')
|
|
|
|
for mod in [mod for mod in sys.modules if 'kicon' in mod]:
|
|
print(f'Reloading {mod}')
|
|
|
|
importlib.reload(sys.modules[mod])
|
|
|
|
Gui.activateWorkbench('KiConnect')
|
|
|
|
|
|
Gui.addCommand('kiconn_reload', Reload())
|