Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Addon Preferences #187

Closed
ly29 opened this issue May 28, 2014 · 14 comments
Closed

Addon Preferences #187

ly29 opened this issue May 28, 2014 · 14 comments

Comments

@ly29
Copy link
Collaborator

ly29 commented May 28, 2014

I added the preferences in __init__.py. Right now only print timings options is there.
preferences

This is an test picture not showing the version on github, layout of course needs some fixing. changing these values have no effect right now.

Of course there should be settings for more things here.

I don't want to put in __init__.py because it will most likely grow a bit. However if put somewhere else _package__ doesn't seem to work to define the addon name, which has to match bl_idname. This should be solved, any ideas?
http://www.blender.org/documentation/blender_python_api_2_70a_release/bpy.types.AddonPreferences.html

The preferences are available via

bpy.context.user_preferences.addons['sverchok-master'].preferences

but I think we should make some simple way of getting preferences set from def init(self, context): Any suggestions?

One suggestion:

def set_pref(node):
    pref_list = pref_dict[node.bl_idname]
    for name,value in pref_list:
         setattr(node,name,value)

Where the pref_dict is generated in some clever way on startup, I imagine with bl_idname as key.
Buttons that should be here, Apply preferences and Reset to default.

def apply_preferences():
     node_groups = [ng for ng in bpy.data.node_groups if ng.bl_idname == "SverchokCustomTreeType"]
     for ng in node_groups:
       for node_type in pref_dict:
            nodes =[ n for n in ng.nodes if n.bl_idname == node_type]
            for node in nodes:
                 set_pref(node)

Furthermore preferences aren't saved if the plugin is disabled so we should save it to a local file somewhere...

Also theme support for FAIL_COLOR, and different node types.

@zeffii
Copy link
Collaborator

zeffii commented Jun 19, 2014

I have no experience using Addon preferences, so i'm scratching the head in complete ignorance

@ly29
Copy link
Collaborator Author

ly29 commented Jun 19, 2014

It is slowly clearing for me, for example print update timings should bet applied via the post load handler. Nodes that have preferences should get the defaults from def init.

@zeffii
Copy link
Collaborator

zeffii commented Jun 19, 2014

wonder how that will work with the update mechanism. If we store preferences locally in the addon directory, we'd want to add such file to the gitignore so we don't accidentally upload a personal preferences file.

@zeffii
Copy link
Collaborator

zeffii commented Jun 19, 2014

sublime text editor does something neat, it generates a default_settings dict on startup each time (or is read only), so it can't be edited. and the user then makes a user_settings dict which overrides any settings in default_settings

edit: here i use dict to mean .json file

@ly29
Copy link
Collaborator Author

ly29 commented Jun 19, 2014

Well I don't develop directly there so no problem for me, but good point about it there.
Something like that is what I have in mined also, the defaults are set in addon preferences class (or rather via property groups in it) which is then modified by the user dict if exists.

@nortikin
Copy link
Owner

ok
1.color schemes
2.def init defines default color after placing node in layout
3.post load color autopicking
4.some timing coloring defnition in every node called after post load from update mechanism? or better just define definition inside update function.

@ly29
Copy link
Collaborator Author

ly29 commented Jun 19, 2014

1 yes as discussed earlier
2 yes, we should make some code to make this simple/standard
3 please explain. apply defaults?
4 better done inside the update system, the nodes shouldn't have deal with that.

@nortikin
Copy link
Owner

3 - is how color is determined. i see this is problem, what color asssigned to node with it's timing. correctly to pick particular color

@nortikin
Copy link
Owner

here should be placed upgrade function. today i will try to do this

@ly29
Copy link
Collaborator Author

ly29 commented Jun 28, 2014

Okay got __package__ properly working, the sverchok directory can be called anything, so can access prefs in stable although hackish way...

    __package__ = bpy.types.SverchokPreferences.bl_idname
    addon = bpy.context.user_preferences.addons.get(__package__)

@ly29
Copy link
Collaborator Author

ly29 commented Jun 28, 2014

Added setting for frame change handler, pre, post and none.

@ly29
Copy link
Collaborator Author

ly29 commented Jun 29, 2014

pref-update
The UI in prefs needs some love...

@nortikin
Copy link
Owner

for this message:
#120 (comment)
for this dialog under commit
#272
i open issue for coloring
#274

@zeffii
Copy link
Collaborator

zeffii commented Oct 11, 2014

prefs are great :)

@zeffii zeffii closed this as completed Oct 11, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants