=== Interface ===

Based on patch #5140 by Juho Vepsäläinen, this commit removes the requirement to type # at the start when you want to use Python expression evaluation when typing a value in a button.

In a nutshell, that means you can now type 3 + 5 in a numbut and see it change to 8.

Word of warning: The normal Python operator logic applies, so if you type in 1 / 3, you'll get 0 and not 0.333. There's no going around that.
This commit is contained in:
Martin Poirier 2006-12-03 18:59:13 +00:00
parent f60da54058
commit cbd84b26f4

@ -2057,13 +2057,12 @@ static int ui_act_as_text_but(uiBut *but)
but->max= max;
if(textleft==0) but->flag &= ~UI_TEXT_LEFT;
if(str[0] == '#') {
if(BPY_button_eval(str+1, &value)) { /* str+1 to skip the # sign */
error("Invalid Python expression, check console");
if(BPY_button_eval(str, &value)) {
/* Uncomment this if you want to see an error message (and annoy users) */
/* error("Invalid Python expression, check console");*/
value = 0.0f; /* Zero out value on error */
retval = 0; /* invalidate return value if eval failed */
}
}
else value = atof(str);
if(but->pointype!=FLO) value= (int)value;