How to make a value slider.

I just started learning to use the bpy module and I am making an addon. The addon is on the toolbar panel. I want to add a value slider to the panel. How can I use the value the user enters as a variable that will be used in another function in another class?

can you show part of you script for panel or using add mesh menu !

for panel need to define scene properties

for add mesh it is properties !

check the templates in script editor !

happy bl

Here is my script so far:





class bgeCellShading(bpy.types.Panel):


    bl_label = "BGE Cell Shading"
    bl_space_type = 'VIEW_3D'
    bl_region_type = 'TOOLS'
    bl_category = "Cell Shading"
    #bl_options = {'REGISTER', 'UNDO'}
    


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

        self.layout.operator("solidify.on")
        self.layout.label("The new object is on the second layer")

        

        #I want an input slider so the user can enter a value here.



class OBJECT_OT_Cell(bpy.types.Operator):
    
    bl_label = "Add Cell Shading"
    bl_idname = "solidify.on"
    bl_description = "Add Cell Shading"
    bl_options = {'REGISTER', 'UNDO'}



    
    def execute(self, context):
#I want to access the value from the class above, that the user entered, here.

        

 
        return{"FINISHED"}



did not say if for panel or operator add mesh type ?

but for operator add mesh type



###
 
class Archimedean_spiral1(bpy.types.Operator):
 
 '''Add Archimedean Spiral'''
 
 bl_idname = "mesh.primitive_archimedean_spiral1_add"
 bl_label = "Archimedean Spiral"
 bl_options = {'REGISTER', 'UNDO','BLOCKING'}
 
 
 seg1 = IntProperty(name="Segments", description="Number  segments", default=16, min=4, max=100)
 nturn = FloatProperty(name="nturn", description="nturn",default=2.5, min=0.1, max=100.0)
 ht= FloatProperty(name="Height/turn",description="Height/turn", default=0.0, min=0.0, max=100.0)
 a1 = FloatProperty(name="a1",description="a1",default=0.1, min=0.001, max=100.0)
 
 def execute(self, context):
 
  global  layers
  verts,edges,faces,vid= [],[],[],0
  bm = bmesh.new()         # Create new Bmesh mesh
  named1="Archimedes Spiral1"
 
  seg1 = self.properties.seg1
  nturn = self.properties.nturn
  ht= self.properties.ht
  a1= self.properties.a1
 



if script is not long show it all

happy bl

But is there a way to have it in the draw function so it can be displayed before activation?

it should be there
but don’t know what else your doing in script !

can you show all the script if not 1000 lines

thanks
happy bl

Here is the entire script:
It solidifies the selected object and assigns a material to make it look cell shaded for the BGE.

bl_info = {
    "name": "BGE  Cell Shading Addon",
    "author": "Nicholas Anderson",
    "version": (1, 0),
    "blender": (2, 76, 11),
    "location": "View3D > Cell Shading",
    "description": "Add Cell Shading to objects for the Blender Game Engine.",
    "warning": "",
    "wiki_url": "",
    "category": "Game Engine"}


import bpy


addon_keymaps = []


class bgeCellShading(bpy.types.Panel):


    bl_label = "BGE Cell Shading"
    bl_space_type = 'VIEW_3D'
    bl_region_type = 'TOOLS'
    bl_category = "Cell Shading"


    def draw(self, context):

        layout = self.layout

        cell = context.object
        split = layout.split()
        col = split.column()
        col.prop(cell, "color", text="Cell Color")

        self.layout.operator("solidify.on")

        self.layout.label("The new object is on the second layer")

class OBJECT_OT_Cell(bpy.types.Operator):

    bl_label = "Add Cell Shading"
    bl_idname = "solidify.on"
    bl_description = "Add Cell Shading"
    bl_options = {'REGISTER', 'UNDO'}


    cell_color = bpy.props.FloatVectorProperty(
    name = "Color",
    subtype = "COLOR",
    default=(bpy.context.scene.objects.active.color[:3]),
    min=0.0, max=1.0,
    description="color picker"
    )
    

    total = bpy.props.FloatProperty(name="Thickness", default=0.2, min=0.0)
    
    def execute(self, context):
        
        if bpy.context.scene.objects.active.type == 'MESH':
        
            bpy.ops.object.duplicate_move()
            bpy.ops.object.move_to_layer(layers=(False, True, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False))

            bpy.ops.object.modifier_add(type="SOLIDIFY")
            bpy.context.object.modifiers["Solidify"].name = "Cell"

            bpy.context.object.modifiers["Cell"].thickness = self.total*-1
            
            index = 0
            
            for material in context.scene.objects.active.data.materials:
                index += 1
            
            bpy.context.object.modifiers["Cell"].material_offset = index
            bpy.context.object.modifiers["Cell"].use_flip_normals = True


            mat = bpy.data.materials.new("service")
            mat.use_shadeless = True
            mat.use_transparency = True
            

            bpy.context.object.data.materials.append(mat)
            
            mat.diffuse_color = (context.object.color[:3])        
            mat.alpha = (context.object.color[3])

            
            bpy.ops.object.modifier_apply(apply_as='DATA', modifier="Cell")
     
            return{"FINISHED"}
        


def register():
    bpy.utils.register_module(__name__)
    
    wm = bpy.context.window_manager
    km = wm.keyconfigs.addon.keymaps.new(name = "Object Mode", space_type = "EMPTY")
    kmi = km.keymap_items.new(OBJECT_OT_Cell.bl_idname, "S", "PRESS", alt = True, shift = True)
    addon_keymaps.append(km)


def unregister():
    bpy.utils.unregister_module(__name__)


if __name__ == "__main__":
    register()

don’t think you can set prop with other var
bpy.context.scene.objects.active.color[:3]

these prop are defined only ounce when class is registered !

not certain why prop in operator are not appearing in tool panel!

sorry but not certain why prop don’t appear in panel!
never done one like that before

hope some one can help on this structure of panel and operator class!

note: you could move all your prop in panel and use scene prop instead !

happy bl