According to this question and this example I am trying to add some custom icons to my addon's operators. But I have an "issue".
In both examples, functions draw
, register
and unregister
are in the same file. In my case, register
and unregister
functions located into my __init__.py
file and looks totally different and the draw
function located into an other file I have create by the name fu3dm_main.py
. Can anyone help me on how I'll apply this example in my case?
Here is how my __init__.py
file looks:
bl_info = {
"name" : "Blah blah blah",
"author" : "Simonetos The Greek <[email protected]>",
"description" : "Blah blah blah",
"blender" : (2, 90, 1),
"version" : (1, 0, 0),
"location" : "View3D",
"warning" : "",
"category" : "Generic"
}
import bpy
from . fu3dm import *
from . fu3dm_main import *
ops = fu3dm.ops
classes = (
fu3dm.ops.view.front,
fu3dm.ops.view.back,
fu3dm.ops.view.right,
fu3dm.ops.view.left,
fu3dm.ops.view.top,
fu3dm.ops.view.bottom,
fu3dm.ops.preferences.model,
fu3dm_main.panel
)
register, unregister = bpy.utils.register_classes_factory(classes)
And here is how my fu3dm_main.py
file looks:
import bpy
from . fu3dm import *
class fu3dm_main():
"""Main class"""
class panel(bpy.types.Panel):
"""Main panel class"""
bl_idname = "fu3dm.main_PT_Panel"
bl_label = "Blah blah blah"
bl_space_type = "VIEW_3D"
bl_region_type = "UI"
bl_category = "FU3DM"
@classmethod
def poll(cls, context):
return bpy.data.collections.get("FU3DM v20.0")
def draw(self, context):
layout = self.layout
# ┌────────┐
# │ Box #1 │
# └┬───────┘
box1 = layout.box()
box1_col1 = box1.column()
box1_row1 = box1_col1.split()
box1_row1.label(text="Preferences:")
box1_row1.operator("fu3dm.model_prefs")
# ┌┴────┐
# │ End │
# └─────┘
fu3dm_main.fu3dm_main
? Lastly usingfrom foo import *
is rarely recommended. $\endgroup$from foo import *
it's just temporary, I'll fix it later. $\endgroup$