Program UI Slider

I would like to add a slider to my own panel. How can i do that and how can i then read the value from it and assign it to a variable? I already tried this:

row.prop(bpy.props.FloatProperty(name="maxdist", description="test", default=3.0, min=0.0, max=10.0, soft_min=0.0, soft_max=10.0, step=1, precision=1, unit='NONE', update=None, get=None, set=None))


And i get this error: TypeError: UILayout.prop(): error with argument 1, "data" - Function.data expected a AnyType type, not tuple

What am i doing wrong?

Thanks, Nebeig

To edit a value in a panel, the value needs to be a property of an item, such as the scene or object. You use bpy.props to add new properties to existing classes. For example :-
bpy.types.Object.myprop = bpy.props.FloatProperty()

You can then display that property in a panel. You add the slider=True option to have it display as a slider.
row.prop(context.object, 'myprop', slider=True)

• You don't import the bpy.context.object.myprop from another script. Both scripts have import bpy and directly read bpy.context.object.myprop. – sambler Jul 30 '18 at 18:45