Skip to Content
Menu
This question has been flagged
3 Replies
18411 Views

i need to make a attrs to a button when ((a = true and state = done) or (a= false and state = available)

what should i put in the button to make it works?

i tried

<button name = "button_a" string ="Button A" attrs="{'invisible':[('&',('a','=',True),('state','=','done')),('&',('a','=',False),('state','=','available'))]}"/>

and it says there is error 

Avatar
Discard
Best Answer

actually you've two errors:

1. you can't use special character & in XML directly, you should write it with it's xml code (we discussed it here)

2. conditional statement is not a valid prefix notation statement, you should write the statement in the prefix notation (we discussed it here)

correct the two errors and you're done:

<button name = "button_a" string ="Button A" attrs="{'invisible':['|','&amp;',('a','=',True),('state','=','done'),'&amp;',('a','=',False),('state','=','available')]}"/> 
Avatar
Discard
Best Answer

Use the Polish notation

About your question:

(A and B) or (C and D) 

should converted to the polish notation as

or and A B and C D

in your example:

['|','&',('a','=',True),('state','=','done'),'&',('a','=',False),('state','=','available')] 

in xml (see @Temur post)

['|','&amp;',('a','=',True),('state','=','done'),'&amp;',('a','=',False),('state','=','available')]

Avatar
Discard
Best Answer

Hi

Here you go!

By default & Operator applied so no need to use & operator

<button name = "button_a" string ="Button A" attrs="{'invisible':['|', '&',('a','=',True),('state','=','done'),'&',('a','=',False),('state','=','available')]}"/> 

Hope, This will help you

Rgds,

Anil.

Avatar
Discard