I have a panel in 3D_View that shows the current file and allows the selection of a new file. When the file is selected, the panel needs to redraw. How do I force a redraw?
In Operator.py file
class OT_TestOpenFilebrowser(Operator, ImportHelper):
#https://sinestesia.co/blog/tutorials/using-blenders-filebrowser-with-python/
bl_idname = "file.open_filebrowser"
bl_label = "Open the file browser (yay)"
filter_glob: StringProperty( default='*.xml', options={'HIDDEN'} )
run=0
def execute(self, context):
if not 'PMTfileName' in globals():
global PMTfileName
PMTfileName = "None2"
self.report({'INFO'}, PMTfileName+ " created in op")
PMTfileName, extension = os.path.splitext(self.filepath)
head_tail = os.path.split(self.filepath)
PMTfileName = head_tail[1]
print(PMTfileName)
self.report({'INFO'}, PMTfileName)
self.report({'INFO'}, extension)
self.report({'INFO'}, self.filepath)
context.area.tag_redraw()
self.__class__.run += 1
"""Do something with the selected file(s)."""
return {'FINISHED'}
bpy.utils.register_class(OT_TestOpenFilebrowser)
If Panel file:
class PMT_PT_Pannel(Panel):
bl_space_type = "VIEW_3D"
bl_region_type = "UI"
bl_label = "PMT Builder"
bl_category = "21Geo Builder"
def draw(self, context):
global PMTfileName
layout = self.layout
#2 Columns with Buttons
box = layout.box()
box.label(text="Open File: "+PMTfileName)
row = layout.row()
row2 = layout.row()
col3 = row.column()
col3.operator("file.open_filebrowser", text="Select File" )
col = row2.column()
col.operator("object.apply_all_mods", text="Apply all")
col2 = row2.column()
col2.operator("export.some_data", text="Export")

my_path) within the panel class...? If so, please study my demo code. OR What part of my demo code do you have changed to get this error? Tested on 2.91 but I don't see any reason why it should not work for versions pre 2.91 @doby Can not help much based on your comment, I suggest edit your question and add more detail about what you're doing exactly. – brockmann Feb 20 '21 at 08:21Thank you!
– doby Feb 21 '21 at 16:15