I'm trying to use a StringProperty on a Panel I've created but the properties can't be found. I --EDIT: the bpy.props docs show custom properties on an Operator which is where I got the idea.--
I have 2 StringProperties: one that I want to be user-editable, another that will essentially be a dynamic label. Basically the second be the user-editable string with a naming convention prefix/postfix applied. Why I want to do this: the next thing in the UI (stripped for the purposes of just showing my problem) is a button that the user presses to create an instance of an object using the calculated name. Storing these strings on the panel makes sense to me because they only "exist" to render stuff to the UI. I don't need to create a whole separate object and store it in the scene like what seems to always be done in the Blender examples.
class XXX_PT_propTest(bpy.types.Panel):
## Side Question: why does this ID throw a [Warning: 'xxx.proptest' does not contain '_PT_' with prefix and suffix] ??
bl_idname = "xxx.proptest"
bl_label = "Test Panel"
bl_space_type = "VIEW_3D"
bl_region_type = "UI"
bl_category = "Test Category"
userAssignedName: bpy.props.StringProperty(name="<User editable>")
calculatedName: bpy.props.StringProperty(name='<Not user editable>')
def draw(self, context):
lyt = self.layout
nextRow = lyt.row()
# When the panel opens, the following line throws this error:
# rna_uiItemR: property not found: xxx.proptest.userAssignedName
nextRow.prop(self, "userAssignedName", text="---")
nextRow = lyt.row()
nextRow.label(text="Exported Name:")
# When the panel opens, the following line throws this error:
# AttributeError: 'XXX_PT_propTest' object has no attribute 'calculatedName'
nextRow.label(text=self.calculatedName)
## An operator will be added to take the calculatedName and instantiate a new custom class object with it
def register():
bpy.utils.register_class(XXX_PT_propTest)
def unregister():
bpy.utils.unregister_class(XXX_PT_propTest)
if __name__ == "__main__":
register()
```