Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2009-11-05 14:17:09 +0300
committerCampbell Barton <ideasman42@gmail.com>2009-11-05 14:17:09 +0300
commit247f72fcc00b438d8d76809eee9c00c5c8561e68 (patch)
tree89032162087708b47b83c0e7b91637e5c3cf394b /source/blender
parentcacd68c3359c74f5f2ab7bae304ffeb59ee6e9da (diff)
- added bpy.context to the python module
- made the console banner printing function into a python operator (includes sys.version) - added 'C' into the consoles default namespace for convenience
Diffstat (limited to 'source/blender')
-rw-r--r--source/blender/editors/space_console/space_console.c18
-rw-r--r--source/blender/python/intern/bpy_interface.c16
2 files changed, 16 insertions, 18 deletions
diff --git a/source/blender/editors/space_console/space_console.c b/source/blender/editors/space_console/space_console.c
index 49bc3adb5b9..6774481430a 100644
--- a/source/blender/editors/space_console/space_console.c
+++ b/source/blender/editors/space_console/space_console.c
@@ -164,21 +164,9 @@ static void console_main_area_draw(const bContext *C, ARegion *ar)
View2DScrollers *scrollers;
//float col[3];
- /* add helper text, why not? */
- if(sc->scrollback.first==NULL) {
- console_scrollback_add_str(C, " * Python Interactive Console *", 0);
- console_scrollback_add_str(C, "Command History: Up/Down Arrow", 0);
- console_scrollback_add_str(C, "Cursor: Left/Right Home/End", 0);
- console_scrollback_add_str(C, "Remove: Backspace/Delete", 0);
- console_scrollback_add_str(C, "Execute: Enter", 0);
- console_scrollback_add_str(C, "Autocomplete: Ctrl+Space", 0);
- console_scrollback_add_str(C, "Ctrl +/- Wheel: Zoom", 0);
- console_scrollback_add_str(C, "Builtin Modules: bpy, bpy.data, bpy.ops, bpy.props, bpy.types, bpy.ui", 0);
-
- /* This is normally set by python but to start with its easier just to set it like this rather then running python with no args */
- strcpy(sc->prompt, ">>> ");
- }
-
+ if(sc->scrollback.first==NULL)
+ WM_operator_name_call((bContext *)C, "CONSOLE_OT_banner", WM_OP_EXEC_DEFAULT, NULL);
+
/* clear and setup matrix */
//UI_GetThemeColor3fv(TH_BACK, col);
//glClearColor(col[0], col[1], col[2], 0.0);
diff --git a/source/blender/python/intern/bpy_interface.c b/source/blender/python/intern/bpy_interface.c
index ef3827d970e..e67df5db096 100644
--- a/source/blender/python/intern/bpy_interface.c
+++ b/source/blender/python/intern/bpy_interface.c
@@ -101,8 +101,6 @@ void bpy_context_set(bContext *C, PyGILState_STATE *gilstate)
if(py_call_level==1) {
- BPY_update_modules(); /* can give really bad results if this isnt here */
-
if(C) { // XXX - should always be true.
BPy_SetContext(C);
bpy_import_main_set(CTX_data_main(C));
@@ -111,6 +109,8 @@ void bpy_context_set(bContext *C, PyGILState_STATE *gilstate)
fprintf(stderr, "ERROR: Python context called with a NULL Context. this should not happen!\n");
}
+ BPY_update_modules(); /* can give really bad results if this isnt here */
+
#ifdef TIME_PY_RUN
if(bpy_timer_count==0) {
/* record time from the beginning */
@@ -171,6 +171,7 @@ void BPY_free_compiled_text( struct Text *text )
/*****************************************************************************
* Description: Creates the bpy module and adds it to sys.modules for importing
*****************************************************************************/
+static BPy_StructRNA *bpy_context_module= NULL; /* for fast access */
static void bpy_init_modules( void )
{
PyObject *mod;
@@ -204,6 +205,15 @@ static void bpy_init_modules( void )
bpy_import_test("bpy_ext"); /* extensions to our existing types */
}
+ /* bpy context */
+ {
+ bpy_context_module= ( BPy_StructRNA * ) PyObject_NEW( BPy_StructRNA, &pyrna_struct_Type );
+ RNA_pointer_create(NULL, &RNA_Context, NULL, &bpy_context_module->ptr);
+
+ PyModule_AddObject(mod, "context", (PyObject *)bpy_context_module);
+ }
+
+
/* stand alone utility modules not related to blender directly */
Geometry_Init();
Mathutils_Init();
@@ -220,7 +230,7 @@ void BPY_update_modules( void )
/* refreshes the main struct */
BPY_update_rna_module();
-
+ bpy_context_module->ptr.data= (void *)BPy_GetContext();
}
/*****************************************************************************