Hi, 
        I’ve been trying to create a button that begins a task to connect two 
blender sessions together on two separate machines, so far I have been able to 
get the backend to work, but I would like to change the appearance of the 
button to match the state my task is in. Its fairly basic, when the user 
presses the button it changes to a pending state, then a connected state if the 
connection works, or back to the ready state if the connection fails (there may 
also be a report to the console or info section in this case, separate issue 
thought).

I use a simple piece of code to do this in a custom panel class

def draw(self, context):

        button_operator = operators[client.status]
        button_icon = icons[client.status]
        button_text = text[client.status]

        layout.operator( button_operator, button_icon, button_text)


depending on the value of client.state, a different set of button operator, 
icon and text is displays. This kind of works, but the issue I am having is 
that the user has to mouse over the button in order to make the icon and text 
change. I also suspect this is the same for the operator, but since you have to 
mouse over to click the button, i never trigger the wrong operator. 

I have been searching for why the button only re-draws on mouseover and not 
when the values of button_operator, icon and text change, but I haven’t found 
anything to suggest why. 

So, I’d like to know, how can I create a button that does redraw when these 
properties change? What actually causes the operator to redraw other than a 
mouse over? I have experimented with layout.prop, this will change when the 
property changes and I don’t have to mouse over it, but I would rather have a 
button than a property since the button is used to connect, cancel and 
disconnect. 

Thanks!

James
_______________________________________________
Bf-python mailing list
[email protected]
https://lists.blender.org/mailman/listinfo/bf-python

Reply via email to