[Bf-python] Bf-python Digest, Vol 138, Issue 7

James Crowther jamesharrycrowther at gmail.com
Thu Dec 1 05:18:01 CET 2016


Hi Dalai! Thanks!
	Ok, so I placed a call to area.tag_redraw() inside the operator so that when the operator finishes, it will call tag_redraw(). There is an improvement, I don’t have to mouse over the button, but I still need to move the mouse. If I leave the mouse still, the button is not re-drawn until I move it. I did use a modal operator for this button, does that make a difference? 

Thanks!

James

> On 29 Nov. 2016, at 10:00 pm, bf-python-request at blender.org wrote:
> 
> Send Bf-python mailing list submissions to
> 	bf-python at blender.org
> 
> To subscribe or unsubscribe via the World Wide Web, visit
> 	https://lists.blender.org/mailman/listinfo/bf-python
> or, via email, send a message with subject or body 'help' to
> 	bf-python-request at blender.org
> 
> You can reach the person managing the list at
> 	bf-python-owner at blender.org
> 
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of Bf-python digest..."
> 
> 
> Today's Topics:
> 
>   1. Re: Layout.operator - update to draw (Dalai Felinto)
> 
> 
> ----------------------------------------------------------------------
> 
> Message: 1
> Date: Tue, 29 Nov 2016 11:24:48 +0100
> From: Dalai Felinto <dfelinto at gmail.com>
> Subject: Re: [Bf-python] Layout.operator - update to draw
> To: Blender Foundation Python list <bf-python at blender.org>
> Message-ID:
> 	<CAGjvzG1Sq+W0gtm=X0JLP26mwhKTV7zwsrE8eXn0eYxh+pSUfw at mail.gmail.com>
> Content-Type: text/plain; charset=UTF-8
> 
> Hi James,
> 
> The UI is only redraw when really needed. This is important for performance.
> 
> In your case, the correct approach is for you to manually tag the area
> (the panel where your button is) for redraw with:  `area.tag_redraw()`
> 
> If you run an operator from that 'area', you can get the area with context.area.
> 
> A more radical (and not recommended) approach is to force a global
> redraw: bpy.ops.wm.redraw_timer(type='DRAW', iterations=1)
> 
> Cheers,
> Dalai
> --
> blendernetwork.org/dalai-felinto
> www.dalaifelinto.com
> 
> 
> 2016-11-25 2:37 GMT+01:00 James Crowther <jamesharrycrowther at gmail.com>:
>> 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
>> Bf-python at blender.org
>> https://lists.blender.org/mailman/listinfo/bf-python
> 
> 
> ------------------------------
> 
> _______________________________________________
> Bf-python mailing list
> Bf-python at blender.org
> https://lists.blender.org/mailman/listinfo/bf-python
> 
> 
> End of Bf-python Digest, Vol 138, Issue 7
> *****************************************




More information about the Bf-python mailing list