I am new to writing UI for Blender (2.92) and I am having a really difficult time understanding what is going on. I would like to add a panel for integer input by the user. When I look at reference code snippets they don't make sense to me and copying these bits of code across also doesn't seem to work.
I would appreciate some help in this regard so I can figure out what I have to do here. The examples I have attached are some last desperate attempts to copy across work from other examples found on the web (marked as blue) + the panel I am working on with a blue dashed line showing where I would like to display a user input.
A description would be nice instead of a vague example. I actually want to understand what is happening.
import bpy
from bpy.types import Panel
from bpy.props import IntProperty
class SMG_PT_Buttons(Panel):
bl_space_type = "VIEW_3D"
bl_region_type = "UI"
bl_label = "SMG Naming Button"
bl_category = "SMG"
bl_idname = "smg.naming"
def draw(self, context):
layout = self.layout
bpy.types.Scene.my_use_x = bpy.props.IntProperty()
# Button 1
layout.label(text="Parent Object")
row = layout.row()
row.operator('smg.write_region', text = "Write Regions")
row = layout.row()
row.prop(context.scene, 'my_use_x')
row = layout.row()
row.operator('smg.write_territory', text = "Write Territories")

bpy.types.Foo.prop = BarProperty(...)outside the draw method, is most often seen in an addonsregistermethod. https://blender.stackexchange.com/questions/57306/how-to-create-a-custom-ui/57332?r=SearchResults&s=1|0.0000#57332 – batFINGER Sep 14 '21 at 11:13AttributeError: pyrna_struct_meta_idprop_setattro() can't set in readonly state 'Scene.my_use_x'ie you cannot set (or declare ID types properties from within a draw method.context.scene.my_use_x = 10will throw the same error. There is also a warning on running scriptWarning: 'smg.naming' doesn't contain '_PT_' with prefix & suffixsuggesting you leave outbl_idname, defaulting to the class name, which in this case follows the naming convention. – batFINGER Sep 14 '21 at 11:47