'I've created a tab via blender python interface but it doesn't appear when script executed
I just started out learning script making in blender and created a code that suppose to create new tab in object preferences tab when executed. But it does not happen. But according to console messages the script is successfully executed. I tried out Python template for UI panel that was directly in Blender Text editor space but it does not work either. What am I missing?
Here's the code itself:
import bpy
class Testpanel (bpy.types.Panel):
bl_label = "Testpanel"
bl_idname = "PT_testpanel"
bl_space_type = 'ViEW_3D'
bl_region_type = 'UI'
bl_category = "NewTab"
def draw (self, context):
layout = self.layout
row = layout.row ()
row.label (text= "Sample text")
def register ():
bpy.utils.register_class (Testpanel)
def unregister ():
bpy.utils.unregister_class (Testpanel)
if __name__ == '__main__':
register ()
Also the code I tried running that was from Blender python templates menu. Which also does not seem to work
import bpy
class Testpanel (bpy.types.Panel):
bl_label = "Testpanel"
bl_idname = "PT_testpanel"
bl_space_type = 'ViEW_3D'
bl_region_type = 'UI'
bl_category = "NewTab"
def draw (self, context):
layout = self.layout
row = layout.row ()
row.label (text= "Sample text")
def register ():
bpy.utils.register_class (Testpanel)
def unregister ():
bpy.utils.unregister_class (Testpanel)
if __name__ == '__main__':
register ()
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|