Python Strike Back
G'day!
I've been taking a short break from complex decimator code today and fiddling with some more fun stuff.
Py Buttons!
Basicly, it evaluates the text as a python expression as if using eval() and puts the value back in the button as usual (meaning it checks for limits and all that). The execution is done sandboxed, it only has access to __builtin__ as well as the Blender and math modules (if it can import them).
Branching to the python evaluation code is based on the presence of the hash (#) symbol as first character. I thought it would be ironic to use the Python comment sign to signal Python evaluation. The irony is nice for memory :P. This is very faculative though, it could very well evaluate everything if it is wanted.
Right now (meaning after capturing the video), it pops the normal Python error message if it hits and error and prints the traceback in the console. It could be done silently though (as shown in the video).
Python Powa!
Martin
I've been taking a short break from complex decimator code today and fiddling with some more fun stuff.
Py Buttons!
Basicly, it evaluates the text as a python expression as if using eval() and puts the value back in the button as usual (meaning it checks for limits and all that). The execution is done sandboxed, it only has access to __builtin__ as well as the Blender and math modules (if it can import them).
Branching to the python evaluation code is based on the presence of the hash (#) symbol as first character. I thought it would be ironic to use the Python comment sign to signal Python evaluation. The irony is nice for memory :P. This is very faculative though, it could very well evaluate everything if it is wanted.
Right now (meaning after capturing the video), it pops the normal Python error message if it hits and error and prints the traceback in the console. It could be done silently though (as shown in the video).
Python Powa!
Martin