How can I add custom icon for my operators in a specific addon? According to this question and this example I am trying to add some custom icons to my addon's operators. But I have an &quot;issue&quot;.
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 = {
    &quot;name&quot; : &quot;Blah blah blah&quot;,
    &quot;author&quot; : &quot;Simonetos The Greek &lt;simonetos.the.greek@gmail.com&gt;&quot;,
    &quot;description&quot; : &quot;Blah blah blah&quot;,
    &quot;blender&quot; : (2, 90, 1),
    &quot;version&quot; : (1, 0, 0),
    &quot;location&quot; : &quot;View3D&quot;,
    &quot;warning&quot; : &quot;&quot;,
    &quot;category&quot; : &quot;Generic&quot;
}

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():
    &quot;&quot;&quot;Main class&quot;&quot;&quot;

    class panel(bpy.types.Panel):
        &quot;&quot;&quot;Main panel class&quot;&quot;&quot;

        bl_idname = &quot;fu3dm.main_PT_Panel&quot;
        bl_label = &quot;Blah blah blah&quot;
        bl_space_type = &quot;VIEW_3D&quot;
        bl_region_type = &quot;UI&quot;
        bl_category = &quot;FU3DM&quot;

        @classmethod
        def poll(cls, context):
            return bpy.data.collections.get(&quot;FU3DM v20.0&quot;)

        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=&quot;Preferences:&quot;)
                box1_row1.operator(&quot;fu3dm.model_prefs&quot;)
            #   ┌┴────┐
            #   │ End │
            #   └─────┘
Well I found the solution from this attached file here, and here is a code example...
import os

import bpy
import bpy.utils.previews
from bpy.types import Panel


preview_collections = {}
# If you work with a simple script.
dir = os.path.dirname(bpy.data.filepath)
# If you work with an addon.
# dir = os.path.join(os.path.dirname(__file__), &quot;icons&quot;)

pcoll = bpy.utils.previews.new()

for entry in os.scandir(dir):
    if entry.name.endswith(&quot;.png&quot;):
        name = os.path.splitext(entry.name)[0]
        pcoll.load(name.upper(), entry.path, &quot;IMAGE&quot;)


class VIEW3D_PT_test(Panel):
    bl_label = &quot;TEST&quot;
    bl_category = &quot;TEST&quot;
    bl_space_type = &quot;VIEW_3D&quot;
    bl_region_type = &quot;UI&quot;

    def draw(self, context):
        layout = self.layout
        scene = context.scene

        layout.prop(scene, &quot;use_gravity&quot;, text=&quot;Enable Layout&quot;)

        col = layout.column()
        col.enabled = scene.use_gravity
        col.operator(&quot;object.duplicate_move&quot;, text=&quot;Custom Icon&quot;, icon_value=pcoll[&quot;ICON&quot;].icon_id)
        col.operator(&quot;object.duplicate_move&quot;, text=&quot;Built-in Icon&quot;, icon=&quot;OUTPUT&quot;)


bpy.utils.register_class(VIEW3D_PT_test)

Just note, that If you work on an addon, the dir should be like this dir = os.path.join(os.path.dirname(__file__), &quot;icons&quot;) and icons should be saved in .png format into folder icons into the same place where your .py file is.
And if you work on a simple script, dir should be like this dir = os.path.dirname(bpy.data.filepath) and icons should be into the same place where your .py and .blend file is.