I just need to know what code to use to create Dropdown Boxes and Sliders in a panel instead of a button.
EnumProps show as dropdowns when added to a panel via .prop().
For sliders use the subtypes ‘PERCENTAGE’ or ‘FACTOR’, or specify the .prop(…, slider=True) attribute to force it at layout level.
Thanks again!
If you wouldn’t mind giving me an example, that would be really helpful. I’m still very much a noob.
Better yet, do you know of a site where I can learn to Modify the UI? From what I can see the API doesn’t have much on the topic.
Not up-to-date and all that good style, but you get the idea:
http://wiki.blender.org/index.php/Dev:2.5/Py/Scripts/Cookbook/Code_snippets/Interface
API docs for layout methods and attributes (self.layout in panel classes’ draw() method):
http://www.blender.org/documentation/blender_python_api_2_70a_release/bpy.types.UILayout.html
import bpy
class HelloWorldPanel(bpy.types.Panel):
"""Creates a Panel in the Object properties window"""
bl_label = "Hello World Panel"
bl_idname = "OBJECT_PT_hello"
bl_space_type = 'PROPERTIES'
bl_region_type = 'WINDOW'
bl_context = "object"
def draw(self, context):
layout = self.layout
scene = context.scene
layout.label("The properties added to panel in a box:")
box = layout.box()
box.prop(scene, "prop1")
box.prop(scene, "prop2")
layout.label("What you selected:")
row = layout.row()
row.label(str(scene.prop1))
row.label(str(scene.prop2))
def register():
bpy.utils.register_module(__name__)
bpy.types.Scene.prop1 = bpy.props.EnumProperty(
name="Prop 1",
description="An enum property",
items=(
('ONE', 'One', 'First item'),
('TWO', 'Two', 'Second item'),
('THREE', 'Three', 'Third item')
),
default='ONE'
)
bpy.types.Scene.prop2 = bpy.props.IntProperty(
name="Prop 2",
min=0,
max=100,
soft_min=10,
soft_max=50,
subtype="FACTOR"
)
def unregister():
bpy.utils.unregister_module(__name__)
del bpy.types.Scene.prop1
del bpy.types.Scene.prop2
if __name__ == "__main__":
register()
Thanks for the links, I’ll check them out!
And sorry for wasting your time on that code… A bit before I replied to the last thread, I decided to rip some code out of the areas of the Blender UI that had what I was trying to accomplish and figured out how it ticks.
I really appreciate the help though!