custom_shelf/ui.py

85 lines
2.2 KiB
Python
Raw Permalink Normal View History

2022-03-04 12:28:53 +01:00
2024-10-03 12:07:33 +02:00
import bpy
2022-03-04 12:28:53 +01:00
2024-10-03 12:07:33 +02:00
class CSHELF_MT_text_editor(bpy.types.Menu):
bl_label = "Shelves"
2022-03-04 12:28:53 +01:00
def draw(self, context):
layout = self.layout
2024-10-03 12:07:33 +02:00
layout.operator("customshelf.add_script", text='Add Script', icon="FILE_NEW")
2022-03-04 12:28:53 +01:00
"""
class CustomShelfPanel(bpy.types.Panel):
bl_label = "Custom Shelf"
bl_category = "SHELF"
bl_space_type = 'VIEW_3D'
bl_region_type = 'TOOLS'
# bl_context = "posemode"
def draw_header(self, context):
view = context.space_data
layout = self.layout
row=layout.row(align=True)
row.operator("customshelf.refresh", \
text='',emboss=False,icon= "FILE_REFRESH")
def draw(self, context):
layout = self.layout
window = context.window
scene = context.scene
rd = scene.render
shelves = bpy.context.scene.CustomShelf.folders
for key,value in sorted(shelves.items()) :
if key.startswith(('_','-')) :
continue
box = layout.box()
#box.alignment='EXPAND'
box_col = box.column(align =False)
if value['expand'] == True :
expandIcon = 'TRIA_DOWN'
else :
expandIcon = 'TRIA_RIGHT'
row = box_col.row(align = True)
row.operator("customshelf.expand",text=key.upper(), icon = expandIcon,emboss=False).folder = key
#subrow = row.row(align = True)
#subrow.alignment = 'CENTER'
#subrow.label(key.upper())
#col.separator()
if value['expand'] == True :
#text =' '.join([' ' for a in range(0,len(key))])
#row.prop(context.scene.CustomShelf,key,emboss = False,text=' ')
for script,settings in sorted(value['scripts'].items()) :
if script.startswith(('_','-')) :
continue
#print(s[1])
func = box_col.operator("customshelf.run_function", \
text=script,icon = settings['icon'])
func.path = settings['path']
#box_col.separator()
#layout.separator()
#col.separator()
"""