Commit Graph

328 Commits

Author SHA1 Message Date
34c78a659b Doc: add bpy.utils.previews
Updated sphinx_doc_gen.py to better handle pure py-classes.
2015-05-12 18:24:32 +10:00
d30f664c04 Expose PreviewImage & custom icons to py API.
This commit mainly:

* Exposes PreviewImage struct in RNA, including ways for user to set images data.
* Adds a new kind of PreviewImage, using a file path and IMB_thumb to get image.
* Adds a new kind of custom icon using PreviewImage, unrelated to ID previews system.
* Adds a python API (utils.previews) to allow python scripts to access those custom previews/icons.

Note that loading image from files' thumbnails is done when needed (deferred loading), not
when defining the custom preview/icon.

WARNING: for release addons who would want to use this, please keep it to a strict minimum, really needed level.
We do not want our UI to explode under hundreds of different flashy icons!

For more info, see also the release notes of Blender 2.75 (http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.75/Addons)
and the example/templates featured with Blender.

Patch by Campbell (ideasman42), Inês (brita) and Bastien (mont29).

Differential Revision: https://developer.blender.org/D1255
2015-05-11 16:37:15 +02:00
929c9de3dc Turn bpy.utils into a package, so that we can easily add submodules to it. 2015-05-02 10:38:51 +02:00
b87eaef1f7 Fix T44137: bpy.path.is_subdir fails
`bpy.path.is_subdir("/abc/def/ghi","/abc/de")` incorrectly returned True
2015-03-26 16:32:16 +11:00
e17c6f79a5 cleanup: py imports 2015-01-28 16:50:51 +11:00
7733bd5efc PyAPI: avoid scanning all addons on startup
Gives small speedup
2015-01-23 16:38:29 +11:00
3e8c0027a3 Cleanup: replace deprecated imp -> importlib 2015-01-23 12:37:58 +11:00
f0f1c7995b PyAPI: disallow assigning members to 'bpy.ops' 2014-12-18 13:52:31 +01:00
b2b1d8e290 Cleanup: remove redundant 'object' parent class 2014-10-28 18:42:06 +01:00
0a48cf08da Correct docstrings 2014-08-26 10:57:21 +10:00
679046743f Fix T41584: bpy.utils.time_from_frame out by a day
Fix from retroj
2014-08-26 09:18:54 +10:00
3a58c4679a Fix addon crash when trying listdir a directory we have no permission to. 2014-07-30 15:35:19 +02:00
f94b87bbb8 New python API for units handling.
Exposes all supported unit systems & types, and to_value()/to_string() functions.

Reviewed and enhanced by CampbellBarton, many thanks!

Differential Revision: https://developer.blender.org/D416
2014-06-17 16:03:40 +02:00
a2489e29f6 Code cleanup: style, unused import 2014-04-28 00:19:15 +10:00
ea610e655c Style cleanup: C & pep8 2014-04-15 13:11:48 +10:00
0c6e74436f Fix T39158: Help > Operator Cheat Sheet causes a python recursive loop.
Core issue exists since ages - the thing you get from bpy.types.YOUR_OT_operator is fuzzy, and may change,
due to the fact that both Operator and OperatorProperties share the same name...
Would be cool to get rid of this issue one day, but for now it's safer to use rna acessor...

This commit is to be backported to 2.70.
2014-03-13 17:37:19 +01:00
18f6bb04fa Fix for custom property editor when property id's contained quotes
Adds bpy.utils.escape_identifier()
2014-02-25 16:19:57 +11:00
dea4bcdf67 PyAPI: bpy.ops was showing 'module' in autocomplete output 2014-02-19 13:41:41 +11:00
2a9e33fba5 Keymap: load/save improvements
- avoid passing redundant operator name to keymap property set function.
- avoid double attr lookups when setting each property.
- handle exceptions on value type mismatch.
- avoid resource warning on failed load.
2014-02-19 10:32:23 +11:00
1ea47c9af9 Code Cleanup: style, spelling and pep8 edits 2013-11-20 03:40:10 +11:00
ecf2eeef23 style cleanup 2013-10-16 04:08:20 +00:00
b20c3f97a4 rename presets not to use '+' character, also some typo fixes. 2013-10-05 14:19:39 +00:00
b6631b8be7 fixes for python api docs.
also move foreach_get/set examples into their own py example files (prefer not to have example code built into blenders binary).
2013-09-18 05:20:43 +00:00
4fbe426151 bpy.path.reduce_dirs() - new utility function to de-duplicate and remove nested paths before doing a recursive search. 2013-08-12 07:44:38 +00:00
2085a42e52 pep8 cleanup 2013-06-27 03:05:19 +00:00
c8f30bc7f0 fix [#35574] Export Key Map issue
problem was the keymap failed to import but didnt give any feedback, now it displays error message.
2013-06-11 15:11:55 +00:00
63d523336f freestyle lineset tag attribute was defined but not used, also some code cleanup. 2013-04-07 01:38:03 +00:00
98752a1f30 py api additions needed for fixing [#34864].
- add rna property 'as_bytes' method so you can get a string property as python bytes (bypass encoding).
- make bpy.path.abspath/relpath compatible with bytes.
- add 'relpath' option to bpy_extras.image_utils.load_image(), so you can load an image relative to a path.
2013-04-05 00:30:32 +00:00
2c348d003e Big i18n tools update, I/II.
Notes:
* Everything is still a bit raw and sometimes hackish.
* Not every feature implemented yet.
* A bunch of cleanup is still needed.
* Doc needs to be updated too!
2013-02-24 08:50:55 +00:00
3b8a0f3d67 use import rather then assignment for loading '_' into scripts. 2013-02-10 09:56:05 +00:00
97d62f0183 style cleanup 2013-01-15 23:15:32 +00:00
9dbe85c17e expose common extensions for image/movie/audio types, since python scripts had to do this internally.
- bpy.path.extensions_image
- bpy.path.extensions_movie
- bpy.path.extensions_audio

eg:

  if os.path.splitext(filename)[1].lower() in bpy.path.extensions_image:
      ... we have an image ...
2013-01-04 03:47:37 +00:00
423994bf39 py api: add restrict state context manager (thats python's context not blenders context),
which restricts bpy.context and bpy.data.

enable this for loading scripts in 'startup' too.
2012-12-20 03:56:22 +00:00
ef665b3d18 dissallow access to the context while addons import and register.
Since the window manager is needed for keymaps this is kept as an exception.

some addons will need updating, but in every case I've seen addons should not be accessing the context while registering.
(bad stuff! - declaring the scene as a global variable - which crashes when the users loads a new file, manipulating the active object or scene... tsk tsk)
2012-12-19 07:27:23 +00:00
7c2e4e28ba bpy.ops module/caller classes incorrectly had __keys__ rather then __slots__.
also added comments about texface drawing when theres no origindex.
2012-12-06 03:09:06 +00:00
7c3db355b1 remove ifdef'd bevel code, current bevel works better then the previous code.
reduce strlen check in texttool_suggest_add()
use 'del list[:]' rather then 'list[:] = []' in python scripts which clear lists.
2012-11-14 09:45:15 +00:00
9fa36b12cc style cleanup: pep8 2012-10-08 08:28:05 +00:00
8a51d235e6 pep8 cleanup 2012-09-26 21:19:51 +00:00
6b1582c012 better handle sizes by default for mask mode, now ignore image width/height 2012-08-25 14:18:54 +00:00
a7ec09aef9 ability to register your own online manual callbacks - useful for 3rd party addon developers, who may want to link to their own URL's. 2012-08-25 14:07:51 +00:00
b0371f053c style cleanup 2012-08-17 18:36:20 +00:00
3270438678 fix for own regression with handling of script paths, however this didnt work quite right before either.
Handle these 2 kinds of script paths
* user script path: ~/.blender/scripts OR $BLENDER_USER_SCRIPTS
* pref script path: always bpy.context.user_preferences.filepaths.script_directory

now both are returned by bpy.utils.script_paths()
2012-07-29 01:02:25 +00:00
e204d67cc7 Fix [#32135] FRAMERATE: Framerate display is truncated in selection box.
Filename extension was striped twice...
2012-07-18 08:51:19 +00:00
558721ab59 More spell checking. 2012-07-04 15:04:38 +00:00
63810ffcef Style edit (mostly), use """ for docstrings (not ''').
Should also fix the broken py ops tips...
2012-07-03 09:02:41 +00:00
bd21001aaf fix for bug where user scripts path set by an environment variable would write presets there but not show up in the menu. 2012-06-29 08:33:13 +00:00
a09feb7386 option so operators can be executed with undo enabled (and redo). 2012-06-27 21:41:17 +00:00
98e6912480 style cleanup 2012-06-19 22:17:19 +00:00
0d6ffd925d remove duplicate import 2012-06-10 00:22:18 +00:00
9ffb1c1dd8 bpy.utils.time_to_frame() and frame_to_time() utility functions. 2012-05-28 16:06:38 +00:00