[Bf-committers] keyboard configuration issues

Campbell Barton ideasman42 at gmail.com
Thu Aug 19 16:52:52 CEST 2010


Recently I was looking into a keyboard layout bug and noticed some
problems with the current method that make me uneasy to settle on this
for release.

The first thing is that the keyboard layouts are user specified names
but loaded as modules.
This means you could call your keyboard layout test, bpy, abc, turtle,
select ... and conflict with existing python modules, while this isn't
all that likely it just seems like this is polluting the module
namespace by having user keyboard configurations.
This means you would have sys.modules["bpy"] alongside
sys.modules["someKeyConfig"]

A simple solution to this is to have a package in cfg so
scripts/cfg/blender_keyconfig/__init__.py
scripts/cfg/blender_keyconfig/maya.py, etc
...this way only sys.modules["blender_keyconfig"] is added and the
submodules can be added & removed without worrying about naming
collisions.

But thinking about this I wonder if its a good idea to load all key
configurations on startup at all. Say we have 3-4 configurations, each
are fairly big python scripts and run many functions to build a
keyboard layout with operator properties.

How about use a system similar to our presets, where the files in a
directory are used to fill a menu, and the script runs only when
selected by the user.
A string can be saved for the active layout and this can run automatic
on startup when set.

-- 
- Campbell


More information about the Bf-committers mailing list