In case Alice’s rabbit is right, it’s always good to have your eyes at the current time. I was never a fan of arm’s watches and I do use Blender in fullscreen (alt+F11). So what to do?
You are right, an addon to show the current time in the Info header. Download the file here, or copy and past the code below. Have fun.
bl_info = {
"name": "Clock",
"author": "Dalai Felinto (dfelinto)",
"version": (1,0),
"blender": (2, 6, 6),
"location": "Info header",
"description": "Shows the current time",
"warning": "",
"wiki_url": "",
"tracker_url": "",
"category": "Useless"}
import bpy
import time
def header_info(self, context):
t = time.localtime()
self.layout.label("%02d:%02d:%02d" % (t.tm_hour, t.tm_min, t.tm_sec))
@bpy.app.handlers.persistent
def clock_hack(context):
# hack to update UI
for area in bpy.context.screen.areas:
if area.type == 'INFO':
area.tag_redraw()
def register():
bpy.app.handlers.scene_update_pre.append(clock_hack)
bpy.types.INFO_HT_header.append(header_info)
def unregister():
bpy.app.handlers.scene_update_pre.remove(clock_hack)
bpy.types.INFO_HT_header.remove(header_info)
if __name__ == "__main__":
register()
"name": "Clock",
"author": "Dalai Felinto (dfelinto)",
"version": (1,0),
"blender": (2, 6, 6),
"location": "Info header",
"description": "Shows the current time",
"warning": "",
"wiki_url": "",
"tracker_url": "",
"category": "Useless"}
import bpy
import time
def header_info(self, context):
t = time.localtime()
self.layout.label("%02d:%02d:%02d" % (t.tm_hour, t.tm_min, t.tm_sec))
@bpy.app.handlers.persistent
def clock_hack(context):
# hack to update UI
for area in bpy.context.screen.areas:
if area.type == 'INFO':
area.tag_redraw()
def register():
bpy.app.handlers.scene_update_pre.append(clock_hack)
bpy.types.INFO_HT_header.append(header_info)
def unregister():
bpy.app.handlers.scene_update_pre.remove(clock_hack)
bpy.types.INFO_HT_header.remove(header_info)
if __name__ == "__main__":
register()
hi D,
it’s not work!
It does work (I just re-tested it) but you are supposed to install it as an addon.
If you are running it from the Text Editor you need to add this last line:
if __name__ == “__main__”: register()
I updated the example in the post. Thanks for reading/testing/reporting by the way 😉
Dalai, It is interesting idea, but your hack to update panel cost me ~20% of one CPU thread. By updating only once per second, you would save a lot of CPU resources.
That’s a clever idea indeed. I may implement it eventually.