2
$\begingroup$

I am in the process of finishing an add-on I have been making and I am trying to work on some final tweaks. I am wondering how I can make a Python operator that is a Slider which controls the x, y, or z position of the selected object. Something like the image below except that controls position specifically. Thanks! - Brad

enter image description here

$\endgroup$
3
$\begingroup$

Set slider property to True

Consult the docs on UILayout.prop,

prop(data, property, text="", text_ctxt="", translate=True, icon='NONE', expand=False, slider=False,toggle=False, icon_only=False, event=False, full_event=False, emboss=True, index=-1, icon_value=0)

To display the property in the UI set it to True. The default is slider = False

slider (boolean, (optional)) – Use slider widget for numeric values

Sample code

def draw(self, context):
    self.layout(context.object, "prop", slider=True)

Make sure to set the minimum and maximum of the property, if unset the default values are +/- the maximum possible value on your system and as a result the slider will sit around the middle and be somewhat meaningless.

Tip: Right click and view source to see the code behind the UI.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.