-
-
Notifications
You must be signed in to change notification settings - Fork 6
/
preferences.py
37 lines (29 loc) · 1.13 KB
/
preferences.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import bpy
class BlendmshPreferences(bpy.types.AddonPreferences):
bl_idname = __package__
def draw(self, context):
import importlib
from .utils_pip import Pip
Pip._ensure_user_site_package()
layout = self.layout
if importlib.util.find_spec('gmsh-api') is not None:
layout.label(text='gmsh-api loaded.', icon='INFO')
else:
layout.label(text='Blendmsh requires gmsh-api!', icon='ERROR')
row = layout.row()
row.operator('blendmsh.installer')
class BlendmshInstaller(bpy.types.Operator):
bl_idname = "blendmsh.installer"
bl_label = "Install gmsh-api"
bl_description = ("Install gmsh-api")
def execute(self, context):
try:
from .utils_pip import Pip
# Pip.upgrade_pip()
Pip.install('gmsh-api')
import gmsh_api
print(gmsh_api.__version__)
self.report({'INFO'}, 'Successfully installed gmsh-api.')
except ModuleNotFoundError:
self.report({'ERROR'}, 'Could not install gmsh-api, Kindly install it manually.')
return {'FINISHED'}