0
$\begingroup$

In the code below, I'm invoking a custom property that redefines itself every 1 second inside of a pie menu, but in the pie, nothing is in real time, it's "stuck in time", is there a way to make it real time?

import bpy
import datetime
from bpy.types import Menu

#delete me after the first run
def every_sec():
    #bpy.context.area.tag_redraw() #didnt work
    #bpy.context.scene.update() #didnt work
    bpy.context.scene["GGG"]=str(datetime.datetime.now())[-15:-7]
    return 1
bpy.app.timers.register(every_sec)
#delete me after the first run

class Pie_menu(Menu):
    bl_label = "Some Pie Menu"

    def draw(self, context):
        layout = self.layout
        pie = layout.menu_pie()
        ups = context.tool_settings.unified_paint_settings
        sculpt = context.tool_settings.sculpt

        col = pie.column(align=True)        
        col.prop(ups, "size", text="Radius", slider=False)
        col.operator("mesh.primitive_plane_add", text="Plane", icon="BLENDER")
        col.label(text=bpy.context.scene["GGG"])#THIS IS SUPPOSED TO BE REAL TIME 

def register():
    bpy.utils.register_class(Pie_menu)
def unregister():
    bpy.utils.unregister_class(Pie_menu)
if __name__ == "__main__":
    register()
    bpy.ops.wm.call_menu_pie(name="Pie_menu")
$\endgroup$
  • 1
    $\begingroup$ and bpy.context.area.tag_redraw()and'bpy.context.scene.update()didn't work either, but i did'nt know this line of code, thanks for letting me know (sorry i deleted your comment by mistake) $\endgroup$ – DB3D May 26 '19 at 9:30
  • $\begingroup$ I delete my self after finding out it is useless since the context is not the one we want. $\endgroup$ – HikariTW May 26 '19 at 9:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.