GUI refreshed with a special kind of event

Hi folks,

the GUI widgets (String, Button, etc.) activate his own events, that is, the gui is actualized every time the events associated with them are triggered, but i would like to put some specialized GUI widgets depending on the type of Blender.Object.GetSelected()[0], the trivial approach is put special if / elif / else clauses on the GUI function, but this is not refreshed until other events are triggered

I would like that every time Blender.Object.GetSelected()[0] changes ( which associated index is Blender.Object.GetSelected( 1 )[0] ) that triggers a refreshing event that actualize my gui to adapt to this particular object,

How can i do this?

Regards,

The only way that I can think of is by getting the selected object(s) inside the event handler without any special event associated with it, as well as continuous Window.Redraw. But even then it will only change display when you move the mouse over the GUI for instance.
Interaction with anything else in Blender does not generate any kind of events to update the GUI automatically.

Just to illustrate a bit what Eeshlo just said, this piece of code will display the name of the active object, but it only updates when an event is called in the Python window (usually, when you move your mouse over it).


from Blender.Draw import *
from Blender.BGL import *
import Blender.Object

ObjectName = ""

def gui():
        global ObjectName
        glClearColor(0.5,0.5,0.5,0.0)
        glClear(GL_COLOR_BUFFER_BIT)

        glRasterPos2i(100, 100)
        Text(ObjectName)

def bevent(evt):
        pass

def event(evt, val):
        global ObjectName
        ob = Blender.Object.GetSelected()
        if ob and ob[0].name != ObjectName:
                ObjectName = ob[0].name
                Redraw()


Register(gui, event, bevent)

Martin