Hello I am trying to write a script that will view the contents of a file directory in a UI pannel based on the object selected. Here is what I have so far:
import bpy
class booknotes(bpy.types.Panel):
bl_label = "Book Notes"
bl_idname = "booknotes"
bl_space_type = "VIEW_3D"
bl_region_type = "UI"
@classmethod
def poll(self, context):
if(bpy.context.active_object.type == 'MESH'):
return(True)
def draw(self, context):
print("hello")
layout = self.layout
obj = context.object
row = layout.row()
row.label(text="Available Notes!", icon='WORLD_DATA')
row = layout.row()
row.label(text="Active object is: " + obj.name)
row = layout.row()
row.prop(obj, "name")
def register():
bpy.utils.register_class(booknotes)
def unregister():
bpy.utils.unregister_class(booknotes)
if __name__ == "__main__":
register()
For this code, when an object is selected I want to view the contents of “obj.name/notes”. I am making directories with the same name as the active objects name. I will be putting text files in these directories and I would like a list of these files to show up in the UI Pannel in a box. When i click on one of the list items, I would like it to open in the text editor. Thank you.