How to change an operator's icon from a timer event I have a panel with a play button, which starts a timer. Every time I click on the button, it changes from play to pause and vice versa:

class PlayPanel(bpy.types.Panel):
    is_playing = False

    def draw(self, context):
        play_panel_draw(context, self.layout)

def play_panel_draw(context, layout):
    row.operator("Play", text="", icon='PLAY' if not PlayPanel.is_playing else 'PAUSE')


Now, I want to change the icon also when the timer stops. How can I do that? In the draw function I'm passing the context and the layout. How can I pass them from the timer class?
The correct way to add a property to a class in blender is by using bpy.props, in your situation that doesn't help as adding bpy.props doesn't work with panels.

The solution would be to add your is_playing property to the scene and use that for your operator icon choice.

def play_panel_draw(context, layout):
    scn = context.scene
    row = layout.row()
    row.operator("scene.play", text="", icon='PLAY' if not scn.is_playing else 'PAUSE')


Here is a sample addon to demonstrate.