[Bf-python] Presets / help refreshing the Bpy menus

Matt Ebb matt at mke3.net
Thu Dec 9 06:46:37 CET 2004


Hi there,

Some of you may have seen stuff in the wiki  
(http://wiki.blender.org/bin/view.pl/Blenderdev/ 
ButtonsInformationArchitecture) about the work that's in progress with  
properly organising the buttons windows. As part of it, I'm integrating  
a presets system that uses Python, re-using Willian's great  
scripts-in-menus code.

I did a little proof-of-concept about this idea a while ago (  
http://mke3.net/archives/2004/07/python_presets.html ) which I had a  
chat to Willian about, and I would have been working with to integrate  
his theme saving code into the rest of the UI, had I not disappeared  
for a few months *blush* :)

Anyway, I'm back and being productive again and have now got the base  
functionality working quite nicely, you can see a little demo movie I  
recorded here:
http://mke3.net/blender/interface/layout/renderbuttonsWIP02.mp4

The problem though is the 'Update Menus' option. It's clunky and  
shouldn't be necessary - the menus should update automatically when a  
new preset is saved, but I can't figure out a good way to do this. What  
happens is that when the 'Save Preset' menu item is chosen, it runs  
this little script here (  
http://mke3.net/blender/interface/layout/pre_rdim_save.py ), which  
saves out a Python script similar to Willian's save_theme.py, that when  
run, sets all the values to what they should be. My problem is that I  
put the required lines of code to update the menus after the code that  
executes the Python script to save out the preset, but somehow the  
menu-updating code gets executed before the script does.

I'm not that experienced with C coding, so I'm not quite sure how to  
solve this. Talking to Ton about something like this before, he  
mentioned making some sort of function (callback?) that encapsulates it  
all to do it in the correct order. Another option too could be to wrap  
the menu-updating C code as a Bpy method (Window module?) and actually  
cause a menu update from the Python script that saves out the preset.

Does anyone here have advice on how this could be done? It would be  
much appreciated :)

Cheers,

Matt

(PS. I pasted and attached some of the relevant C code. I didn't do a  
full diff since there's way too much stuff changed all over the place  
for other things)

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: dimensions_presets_snippets.txt
URL: <http://lists.blender.org/pipermail/bf-python/attachments/20041209/2ae63807/attachment.txt>
-------------- next part --------------



-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 2355 bytes
Desc: not available
URL: <http://lists.blender.org/pipermail/bf-python/attachments/20041209/2ae63807/attachment.bin>


More information about the Bf-python mailing list