I am trying to create a dropdownlist and a increment/decrement button in my custom UI Panel. I can't seem to find how to do this. Does anyone know how?
Here are visual Examples
Thank you in advance for your help and have a nice day! :)
Blender Stack Exchange is a question and answer site for people who use Blender to create 3D graphics, animations, or games. It only takes a minute to sign up.
Sign up to join this communityI am trying to create a dropdownlist and a increment/decrement button in my custom UI Panel. I can't seem to find how to do this. Does anyone know how?
Here are visual Examples
Thank you in advance for your help and have a nice day! :)
Here the code for this example:
bl_info = {
"name": "Test Addon",
"author": "Me myself and I",
"version": (0, 0, 1),
"blender": (2, 80, 0),
"location": "View3D > UI > MY TEST",
"description": "This is a test UI addon",
"warning": "",
"doc_url": "",
"category": "3D View",
}
import bpy
from bpy.types import Panel, PropertyGroup, Scene, WindowManager
from bpy.props import (
IntProperty,
EnumProperty,
StringProperty,
PointerProperty,
)
class MYTEST_PT_Panel(Panel):
bl_idname = "MYTEST_PT_Panel"
bl_label = "MY UI"
bl_space_type = "VIEW_3D"
bl_region_type = "UI"
bl_category = "MY TEST"
bl_options = {'DEFAULT_CLOSED'}
def draw(self, context):
layout = self.layout
placeholder = context.scene.placeholder
col = layout.column()
col.prop(placeholder, "inc_dec_int", text="Increment/Decrease")
col.prop(placeholder, "dropdown_box", text="Dropdown")
col.prop(placeholder, "file_path", text="Filepath")
class PlaceholderProperties(PropertyGroup):
inc_dec_int: IntProperty(
name="Incr-Decr", min=1, default=4, description="Tooltip for Incr-Decr"
)
dropdown_box: EnumProperty(
items=(
("A", "Ahh", "Tooltip for A"),
("B", "Be", "Tooltip for B"),
("C", "Ce", "Tooltip for C"),
),
name="Description for the Elements",
default="A",
description="Tooltip for the Dropdownbox",
)
file_path: StringProperty(
name="File",
default="",
description="Wanted File",
maxlen=1024,
subtype="FILE_PATH",
)
classes = (
PlaceholderProperties,
MYTEST_PT_Panel,
)
def register():
#the usual registration...
from bpy.utils import register_class
for cls in classes:
register_class(cls)
Scene.placeholder = PointerProperty(type=PlaceholderProperties)
def unregister():
#the usual unregistration in reverse order ...
from bpy.utils import unregister_class
for cls in reversed(classes):
unregister_class(cls)
del Scene.placeholder
if __name__ == "__main__":
register()
I believe this small example should be easy enough to follow through, i tried to use simple names to see what is used where.
The specific 3 Properties needed are the IntProperty, EnumProperty and StringProperty.