-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtimeme_panel.py
48 lines (38 loc) · 1.71 KB
/
timeme_panel.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# Nikita Akimov
#
# GitHub
# https://github.com/Korchy/blender-timeme
from bpy.types import Panel, UIList
from bpy.utils import register_class, unregister_class
from .timeme import TimeMeStatic
class TIMEME_UL_cats_list(UIList):
def draw_item(self, context, layout, data, item, icon, active_data, active_property, index=0, flt_flag=0):
layout.label(text=item.category_name)
layout.label(text=item.category_time_str)
class TIMEME_PT_panel(Panel):
bl_idname = 'TIMEME_PT_panel'
bl_label = 'TimeMe'
bl_space_type = 'PROPERTIES'
bl_region_type = 'WINDOW'
bl_context = 'render'
def draw(self, context):
if hasattr(context.scene, 'timeme_vars'):
layout = self.layout
layout.template_list('TIMEME_UL_cats_list', 'Time Categories', context.scene.timeme_vars, 'categories', context.scene.timeme_vars, 'active_category', rows=3, type='DEFAULT')
row = layout.row()
row.operator('timeme.print', icon='FILE_TEXT', text='To Text')
row.operator('timeme.toclipboard', icon='COPYDOWN', text='To Clipboard')
if TimeMeStatic.status == 'RUNNING':
op = row.operator('timeme.pause_resume', icon='PAUSE', text='Pause')
op.switch_to = 'PAUSE'
elif TimeMeStatic.status == 'PAUSED':
op = row.operator('timeme.pause_resume', icon='PLAY', text='Resume')
op.switch_to = 'RESUME'
row.operator('timeme.reset', icon='X', text='Reset')
def register():
register_class(TIMEME_PT_panel)
register_class(TIMEME_UL_cats_list)
def unregister():
unregister_class(TIMEME_PT_panel)
unregister_class(TIMEME_UL_cats_list)