# How to create a pop-up menu to get numerical input

I want to do it so that when they press a button a window comes up which says 'Subdivision Level' and then an input where whoever's using it can put in a number which changes how much subdivision to add.

Here's the code:

import bpy

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

layout.operator("bpy.ops.object.subdivision_set(level=1")
layout.operator("object.duplicate_move")

def register():

def unregister():

if __name__ == "__main__":
register()


I know how to do everything else I'm just confused about how to make something which allows people to put in inputs/make a slider/make a check box in blender python.

I don't mind if as an answer you just put the code on how to make these input types or if you link a wiki article or something. I'm just having problems finding the right website and I'm pretty sure it can be done.

Here's a link to the blender tutorial that I currently want the input for. So that when I click something on the mini-menu, another mini-menu-thing will open asking how much levels you want and if you want it simple or catmull-clark etc.

I'm sorry if it's obvious but I couldn't find an answer anywhere.

• you are creating an addon right ? – Chebhou May 23 '15 at 20:37
• @Chebhou not sure to be honest. I'm following a tutorial (I'll edit the question so it has a link to it) i think I'm just creating a little menu thing, like the ones where you press shift-a. – Chickenator May 23 '15 at 20:38
• possible duplicate of How to call invoke_popup? – p2or May 26 '15 at 8:58
• also related: blender.stackexchange.com/questions/23974/… – p2or May 26 '15 at 8:59

You can create an operator which will show a menu when called , this is the Simple Operator example edited to fit this case :

• Run the script to rigster the operator
• press Space and type Simple Object Operator

import bpy
from bpy.props import IntProperty

def main(self, context):
bpy.ops.object.subdivision_set(level=self.level)

class SimpleOperator(bpy.types.Operator):
"""Tooltip"""
bl_idname = "object.simple_operator"
bl_label = "Simple Object Operator"
bl_options = {'REGISTER', 'UNDO'}

level = IntProperty(default = 1, min = 0, max = 10)

@classmethod
def poll(cls, context):
return context.active_object is not None

def execute(self, context):
main(self, context)
return {'FINISHED'}

def invoke(self, context, event):
wm = context.window_manager
return wm.invoke_props_dialog(self)

def register():
bpy.utils.register_class(SimpleOperator)

def unregister():
bpy.utils.unregister_class(SimpleOperator)

if __name__ == "__main__":
register()

• I'll check it tomorrow. Sorry I can't do it today – Chickenator May 23 '15 at 21:24
• Wait where are you supposed to put this? I'll edit my finished code into the question so you can see. – Chickenator May 24 '15 at 6:29
• @Chickenator sorry this was for the operator but you are creating a menu I think it does not support this – Chebhou May 24 '15 at 11:09