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
path: root/source
diff options
context:
space:
mode:
authorWillian Padovani Germano <wpgermano@gmail.com>2004-05-23 00:25:22 +0400
committerWillian Padovani Germano <wpgermano@gmail.com>2004-05-23 00:25:22 +0400
commit7f6b88e3896c1b031ce955a7b52be8d0b8401519 (patch)
treee13f9e3e8bc23f410c70fa5a1e1957ff8425a923 /source
parent4551490dd44dbd8eae21826842e7e904bed5c288 (diff)
BPython:
- updated docs with recently added functions - dynamic menu entries now are sorted (alphabetically, of course) - added new menu categories for scripts: Wizards, Modifiers, Generators, Materials, Animation: only added to list of options, didn't mess with any Blender header. They are already available from the "Scripts" menu in the scripts win, but not elsewhere. - added option 'datadir' to Blender.Get(option): so scripts can use .blender/bpydata for reading / writing their data files.
Diffstat (limited to 'source')
-rw-r--r--source/blender/python/BPY_extern.h1
-rw-r--r--source/blender/python/BPY_interface.c34
-rw-r--r--source/blender/python/BPY_menus.c83
-rw-r--r--source/blender/python/BPY_menus.h12
-rw-r--r--source/blender/python/api2_2x/Blender.c10
-rw-r--r--source/blender/python/api2_2x/Draw.c3
-rw-r--r--source/blender/python/api2_2x/Text.c147
-rw-r--r--source/blender/python/api2_2x/Text.h148
-rw-r--r--source/blender/python/api2_2x/doc/Blender.py30
-rw-r--r--source/blender/python/api2_2x/doc/Draw.py64
10 files changed, 330 insertions, 202 deletions
diff --git a/source/blender/python/BPY_extern.h b/source/blender/python/BPY_extern.h
index 55898994262..9829226db81 100644
--- a/source/blender/python/BPY_extern.h
+++ b/source/blender/python/BPY_extern.h
@@ -74,6 +74,7 @@ void BPY_free_finished_script(struct Script *script);
void init_syspath(void);
void syspath_append(char *dir);
+char *bpy_gethome();
#ifdef __cplusplus
} /* extern "C" */
diff --git a/source/blender/python/BPY_interface.c b/source/blender/python/BPY_interface.c
index b549b817587..0a2e0dd7cc5 100644
--- a/source/blender/python/BPY_interface.c
+++ b/source/blender/python/BPY_interface.c
@@ -567,7 +567,7 @@ int BPY_menu_do_python(short menutype, int event)
if (pym->dir) /* script is in U.pythondir */
BLI_make_file_string("/", filestr, U.pythondir, pym->filename);
else { /* script is in ~/.blender/scripts/ */
- BLI_make_file_string("/", dirname, bpymenu_gethome(), "scripts");
+ BLI_make_file_string("/", dirname, bpy_gethome(), "scripts");
BLI_make_file_string("/", filestr, dirname, pym->filename);
}
@@ -1105,3 +1105,35 @@ void init_ourImport(void)
d = PyModule_GetDict(m);
PyDict_SetItemString(d, "__import__", import);
}
+
+/* this makes sure BLI_gethome() returns a path with '.blender' appended
+ * Besides, this function now either returns userhome/.blender (if it exists)
+ * or blenderInstallDir/.blender/ otherwise */
+char *bpy_gethome()
+{
+ static char homedir[FILE_MAXDIR];
+ char bprogdir[FILE_MAXDIR];
+ char *s;
+ int i;
+
+ if (homedir[0] != '\0') return homedir; /* no need to search twice */
+
+ s = BLI_gethome();
+
+ if (strstr(s, ".blender")) PyOS_snprintf(homedir, FILE_MAXDIR, s);
+ else BLI_make_file_string ("/", homedir, s, ".blender/");
+
+ /* if userhome/.blender/ exists, return it */
+ if (BLI_exists(homedir)) return homedir;
+
+ /* otherwise, use argv[0] (bprogname) to get .blender/ in
+ * Blender's installation dir */
+ s = BLI_last_slash(bprogname);
+
+ i = s - bprogname + 1;
+
+ PyOS_snprintf(bprogdir, i, bprogname);
+ BLI_make_file_string ("/", homedir, bprogdir, ".blender/");
+
+ return homedir;
+}
diff --git a/source/blender/python/BPY_menus.c b/source/blender/python/BPY_menus.c
index 628f24b35f2..b1d392f3b7f 100644
--- a/source/blender/python/BPY_menus.c
+++ b/source/blender/python/BPY_menus.c
@@ -73,43 +73,15 @@ static int DEBUG;
*/
BPyMenu *BPyMenuTable[PYMENU_TOTAL];
-/* we can't be sure if BLI_gethome() returned a path
- * with '.blender' appended or not. Besides, this function now
- * either returns userhome/.blender (if it exists) or
- * blenderInstallDir/.blender/ otherwise */
-char *bpymenu_gethome()
-{
- static char homedir[FILE_MAXDIR];
- char bprogdir[FILE_MAXDIR];
- char *s;
- int i;
-
- if (homedir[0] != '\0') return homedir; /* no need to search twice */
-
- s = BLI_gethome();
-
- if (strstr(s, ".blender")) PyOS_snprintf(homedir, FILE_MAXDIR, s);
- else BLI_make_file_string ("/", homedir, s, ".blender/");
-
- /* if userhome/.blender/ exists, return it */
- if (BLI_exists(homedir)) return homedir;
-
- /* otherwise, use argv[0] (bprogname) to get .blender/ in
- * Blender's installation dir */
- s = BLI_last_slash(bprogname);
-
- i = s - bprogname + 1;
-
- PyOS_snprintf(bprogdir, i, bprogname);
- BLI_make_file_string ("/", homedir, bprogdir, ".blender/");
-
- return homedir;
-}
-
static int bpymenu_group_atoi (char *str)
{
if (!strcmp(str, "Import")) return PYMENU_IMPORT;
else if (!strcmp(str, "Export")) return PYMENU_EXPORT;
+ else if (!strcmp(str, "Generators")) return PYMENU_GENERATORS;
+ else if (!strcmp(str, "Modifiers")) return PYMENU_MODIFIERS;
+ else if (!strcmp(str, "Wizards")) return PYMENU_WIZARDS;
+ else if (!strcmp(str, "Animation")) return PYMENU_ANIMATION;
+ else if (!strcmp(str, "Materials")) return PYMENU_MATERIALS;
/* "Misc" or an inexistent group name: use misc */
else return PYMENU_MISC;
}
@@ -123,6 +95,21 @@ char *BPyMenu_group_itoa (short menugroup)
case PYMENU_EXPORT:
return "Export";
break;
+ case PYMENU_GENERATORS:
+ return "Generators";
+ break;
+ case PYMENU_MODIFIERS:
+ return "Modifiers";
+ break;
+ case PYMENU_WIZARDS:
+ return "Wizards";
+ break;
+ case PYMENU_ANIMATION:
+ return "Animation";
+ break;
+ case PYMENU_MATERIALS:
+ return "Materials";
+ break;
case PYMENU_MISC:
return "Misc";
break;
@@ -294,12 +281,26 @@ static BPyMenu *bpymenu_AddEntry (short group, short version, char *name,
menu->next = next; /* non-NULL if menu already existed */
if (nameclash) return menu; /* no need to place it, it's already at the list*/
+ else { /* insert the new entry in its correct position at the table */
+ BPyMenu *prev = NULL;
+ char *s = NULL;
+
+ iter = &BPyMenuTable[group];
+ while (*iter) {
+ s = (*iter)->name;
+ if (s) if (strcmp(menu->name, s) < 0) break; /* sort by names */
+ prev = *iter;
+ iter = &((*iter)->next);
+ }
- iter = &BPyMenuTable[group];
- while (*iter) iter = &((*iter)->next);
+ if (*iter) { /* prepend */
+ menu->next = *iter;
+ if (prev) prev->next = menu;
+ else BPyMenuTable[group] = menu; /* is first entry */
+ }
+ else *iter = menu; /* append */
+ }
- *iter = menu;
-
return menu;
}
@@ -345,7 +346,7 @@ static int bpymenu_CreateFromFile (void)
BPyMenuTable[group] = NULL;
/* let's try to open the file with bpymenu data */
- BLI_make_file_string ("/", line, bpymenu_gethome(), BPYMENU_DATAFILE);
+ BLI_make_file_string ("/", line, bpy_gethome(), BPYMENU_DATAFILE);
fp = fopen(line, "rb");
@@ -432,7 +433,7 @@ static void bpymenu_WriteDataFile(void)
char fname[FILE_MAXDIR+FILE_MAXFILE];
int i;
- BLI_make_file_string("/", fname, bpymenu_gethome(), BPYMENU_DATAFILE);
+ BLI_make_file_string("/", fname, bpy_gethome(), BPYMENU_DATAFILE);
fp = fopen(fname, "w");
if (!fp) {
@@ -680,7 +681,7 @@ int BPyMenu_Init(int usedir)
if (U.pythondir[0] == '\0') upydir = NULL;
- BLI_make_file_string ("/", dirname, bpymenu_gethome(), "scripts");
+ BLI_make_file_string ("/", dirname, bpy_gethome(), "scripts");
res1 = bpymenu_GetStatMTime(dirname, 0, &tdir1);
@@ -722,7 +723,7 @@ int BPyMenu_Init(int usedir)
if (DEBUG) printf("\nRegistering scripts in Blender menus ...\n\n");
if (!usedir) { /* if we're not forced to use the dir */
- BLI_make_file_string("/", fname, bpymenu_gethome(), BPYMENU_DATAFILE);
+ BLI_make_file_string("/", fname, bpy_gethome(), BPYMENU_DATAFILE);
resf = bpymenu_GetStatMTime(fname, 1, &tfile);
if (resf < 0) tfile = 0;
}
diff --git a/source/blender/python/BPY_menus.h b/source/blender/python/BPY_menus.h
index 10e32f66b90..b9826ed4bc2 100644
--- a/source/blender/python/BPY_menus.h
+++ b/source/blender/python/BPY_menus.h
@@ -36,8 +36,8 @@
* adds 'dynamic' menus to Blender, letting scripts register themselves in any
* of a few pre-defined (trivial to upgrade) places in menus. These places or
* slots are called groups here (Import, Export, etc). This is how it works:
- * - scripts at some specific folder (only the user pref U.pythondir, right
- * now) are scanned for registration info.
+ * - scripts at dirs user pref U.pythondir and .blender/scripts/ are scanned
+ * for registration info.
* - this data is also saved to a .Bpymenus file at the user's home dir and
* only re-created when the scripts folder gets modified.
* - on start-up Blender uses this info to fill a table, which is used to
@@ -79,9 +79,14 @@ typedef struct BPyMenu {
* the new group.
*/
typedef enum {
+ PYMENU_WIZARDS, /* complex 'app' scripts */
+ PYMENU_MODIFIERS, /* modifies existing objs */
+ PYMENU_MISC,
+ PYMENU_MATERIALS,
+ PYMENU_GENERATORS, /* creates new objects */
PYMENU_IMPORT,
PYMENU_EXPORT,
- PYMENU_MISC,
+ PYMENU_ANIMATION,
PYMENU_TOTAL
} PYMENUHOOKS;
@@ -96,7 +101,6 @@ void BPyMenu_RemoveAllEntries(void);
void BPyMenu_PrintAllEntries(void);
char *BPyMenu_CreatePupmenuStr(BPyMenu *pym, short group);
char *BPyMenu_group_itoa (short group);
-char *bpymenu_gethome();
struct BPyMenu *BPyMenu_GetEntry (short group, short pos);
#endif /* BPY_MENUS_H */
diff --git a/source/blender/python/api2_2x/Blender.c b/source/blender/python/api2_2x/Blender.c
index b489dd4cf33..839c8010ce4 100644
--- a/source/blender/python/api2_2x/Blender.c
+++ b/source/blender/python/api2_2x/Blender.c
@@ -41,11 +41,13 @@
#include <DNA_object_types.h>
#include <DNA_scene_types.h>
#include <DNA_screen_types.h> /* for SPACE_VIEW3D */
+#include <DNA_space_types.h> /* for SPACE_VIEW3D */
#include <DNA_userdef_types.h>
#include <BKE_ipo.h>
#include "gen_utils.h"
#include "modules.h"
+#include "../BPY_extern.h" /* for bpy_gethome() */
/* From Window.h, used here by Blender_Redraw */
PyObject *M_Window_Redraw(PyObject *self, PyObject *args);
@@ -80,6 +82,7 @@ static char Blender_Get_doc[] =
'staframe' - Returns the start frame of the animation\n\
'endframe' - Returns the end frame of the animation\n\
'filename' - Returns the name of the last file read or written\n\
+ 'datadir' - Returns the dir where scripts can save their data, if available\n\
'version' - Returns the Blender version number";
static char Blender_Redraw_doc[] = "() - Redraw all 3D windows";
@@ -196,6 +199,13 @@ static PyObject *Blender_Get (PyObject *self, PyObject *args)
{
return ( PyString_FromString (G.sce) );
}
+ if (StringEqual (str, "datadir"))
+ {
+ char datadir[FILE_MAXDIR];
+ BLI_make_file_string("/", datadir, bpy_gethome(), "bpydata/");
+ if (BLI_exists(datadir)) return PyString_FromString(datadir);
+ else return EXPP_incr_ret (Py_None);
+ }
/* According to the old file (opy_blender.c), the following if
statement is a quick hack and needs some clean up. */
if (StringEqual (str, "vrmloptions"))
diff --git a/source/blender/python/api2_2x/Draw.c b/source/blender/python/api2_2x/Draw.c
index 4eb2ea09d00..3434b655280 100644
--- a/source/blender/python/api2_2x/Draw.c
+++ b/source/blender/python/api2_2x/Draw.c
@@ -546,8 +546,7 @@ static PyObject *Method_Exit (PyObject *self, PyObject *args)
* and gui button events, so a script can continue executing after the
* interpreter reached its end and returned control to Blender. Everytime
* the SPACE_SCRIPT window with this script is redrawn, the registered
- * callbacks are executed and deleted (a new call to Register re-inserts them
- * or new ones).*/
+ * callbacks are executed. */
static PyObject *Method_Register (PyObject *self, PyObject *args)
{
PyObject *newdrawc = NULL, *neweventc = NULL, *newbuttonc = NULL;
diff --git a/source/blender/python/api2_2x/Text.c b/source/blender/python/api2_2x/Text.c
index 933191eda56..721747c3133 100644
--- a/source/blender/python/api2_2x/Text.c
+++ b/source/blender/python/api2_2x/Text.c
@@ -29,7 +29,152 @@
* ***** END GPL/BL DUAL LICENSE BLOCK *****
*/
-#include "Text.h"
+#include <Python.h>
+#include <stdio.h>
+
+#include <BKE_main.h>
+#include <BKE_global.h>
+#include <BKE_library.h>
+#include <BKE_sca.h>
+#include <BIF_drawtext.h>
+#include <BKE_text.h>
+#include <BLI_blenlib.h>
+#include <DNA_text_types.h>
+
+#include "gen_utils.h"
+#include "modules.h"
+#include "../BPY_extern.h"
+
+#define EXPP_TEXT_MODE_FOLLOW TXT_FOLLOW
+
+/*****************************************************************************/
+/* Python API function prototypes for the Text module. */
+/*****************************************************************************/
+static PyObject *M_Text_New (PyObject *self, PyObject *args,
+ PyObject *keywords);
+static PyObject *M_Text_Get (PyObject *self, PyObject *args);
+static PyObject *M_Text_Load (PyObject *self, PyObject *args);
+static PyObject *M_Text_unlink (PyObject *self, PyObject *args);
+
+/*****************************************************************************/
+/* The following string definitions are used for documentation strings. */
+/* In Python these will be written to the console when doing a */
+/* Blender.Text.__doc__ */
+/*****************************************************************************/
+static char M_Text_doc[] =
+"The Blender Text module\n\n";
+
+static char M_Text_New_doc[] =
+"() - return a new Text object";
+
+static char M_Text_Get_doc[] =
+"(name) - return the Text with name 'name', \
+returns None if not found.\n If 'name' is not specified, \
+it returns a list of all Texts in the\ncurrent scene.";
+
+static char M_Text_Load_doc[] =
+"(filename) - return text from file filename as a Text Object, \
+returns None if not found.\n";
+
+static char M_Text_unlink_doc[] =
+"(text) - remove Text object 'text' from Blender";
+
+/*****************************************************************************/
+/* Python method structure definition for Blender.Text module: */
+/*****************************************************************************/
+struct PyMethodDef M_Text_methods[] = {
+ {"New",(PyCFunction)M_Text_New, METH_VARARGS|METH_KEYWORDS,
+ M_Text_New_doc},
+ {"Get", M_Text_Get, METH_VARARGS, M_Text_Get_doc},
+ {"get", M_Text_Get, METH_VARARGS, M_Text_Get_doc},
+ {"Load", M_Text_Load, METH_VARARGS, M_Text_Load_doc},
+ {"unlink", M_Text_unlink, METH_VARARGS, M_Text_unlink_doc},
+ {NULL, NULL, 0, NULL}
+};
+
+/*****************************************************************************/
+/* Python BPy_Text structure definition: */
+/*****************************************************************************/
+typedef struct {
+ PyObject_HEAD
+ Text *text;
+
+} BPy_Text;
+
+static int Text_IsLinked(BPy_Text *self);
+
+/*****************************************************************************/
+/* Python BPy_Text methods declarations: */
+/*****************************************************************************/
+static PyObject *Text_getName(BPy_Text *self);
+static PyObject *Text_getFilename(BPy_Text *self);
+static PyObject *Text_getNLines(BPy_Text *self);
+static PyObject *Text_setName(BPy_Text *self, PyObject *args);
+static PyObject *Text_clear(BPy_Text *self, PyObject *args);
+static PyObject *Text_write(BPy_Text *self, PyObject *args);
+static PyObject *Text_set(BPy_Text *self, PyObject *args);
+static PyObject *Text_asLines(BPy_Text *self, PyObject *args);
+
+/*****************************************************************************/
+/* Python BPy_Text methods table: */
+/*****************************************************************************/
+static PyMethodDef BPy_Text_methods[] = {
+ /* name, method, flags, doc */
+ {"getName", (PyCFunction)Text_getName, METH_NOARGS,
+ "() - Return Text Object name"},
+ {"getFilename", (PyCFunction)Text_getFilename, METH_VARARGS,
+ "() - Return Text Object filename"},
+ {"getNLines", (PyCFunction)Text_getNLines, METH_VARARGS,
+ "() - Return number of lines in text buffer"},
+ {"setName", (PyCFunction)Text_setName, METH_VARARGS,
+ "(str) - Change Text Object name"},
+ {"clear", (PyCFunction)Text_clear, METH_VARARGS,
+ "() - Clear Text buffer"},
+ {"write", (PyCFunction)Text_write, METH_VARARGS,
+ "(line) - Append string 'str' to Text buffer"},
+ {"set", (PyCFunction)Text_set, METH_VARARGS,
+ "(name, val) - Set attribute 'name' to value 'val'"},
+ {"asLines", (PyCFunction)Text_asLines, METH_VARARGS,
+ "() - Return text buffer as a list of lines"},
+ {0}
+};
+
+/*****************************************************************************/
+/* Python Text_Type callback function prototypes: */
+/*****************************************************************************/
+static void Text_dealloc (BPy_Text *self);
+static int Text_setAttr (BPy_Text *self, char *name, PyObject *v);
+static PyObject *Text_getAttr (BPy_Text *self, char *name);
+static int Text_compare (BPy_Text *a, BPy_Text *b);
+static PyObject *Text_repr (BPy_Text *self);
+
+/*****************************************************************************/
+/* Python Text_Type structure definition: */
+/*****************************************************************************/
+PyTypeObject Text_Type =
+{
+ PyObject_HEAD_INIT(NULL)
+ 0, /* ob_size */
+ "Blender Text", /* tp_name */
+ sizeof (BPy_Text), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ /* methods */
+ (destructor)Text_dealloc, /* tp_dealloc */
+ 0, /* tp_print */
+ (getattrfunc)Text_getAttr, /* tp_getattr */
+ (setattrfunc)Text_setAttr, /* tp_setattr */
+ (cmpfunc)Text_compare, /* tp_compare */
+ (reprfunc)Text_repr, /* tp_repr */
+ 0, /* tp_as_number */
+ 0, /* tp_as_sequence */
+ 0, /* tp_as_mapping */
+ 0, /* tp_as_hash */
+ 0,0,0,0,0,0,
+ 0, /* tp_doc */
+ 0,0,0,0,0,0,
+ BPy_Text_methods, /* tp_methods */
+ 0, /* tp_members */
+};
/*****************************************************************************/
/* Function: M_Text_New */
diff --git a/source/blender/python/api2_2x/Text.h b/source/blender/python/api2_2x/Text.h
index 68819c641dd..27c2de86cf2 100644
--- a/source/blender/python/api2_2x/Text.h
+++ b/source/blender/python/api2_2x/Text.h
@@ -31,152 +31,4 @@
#ifndef EXPP_TEXT_H
#define EXPP_TEXT_H
-
-#include <Python.h>
-#include <stdio.h>
-
-#include <BKE_main.h>
-#include <BKE_global.h>
-#include <BKE_library.h>
-#include <BKE_sca.h>
-#include <BIF_drawtext.h>
-#include <BKE_text.h>
-#include <BLI_blenlib.h>
-#include <DNA_text_types.h>
-
-#include "gen_utils.h"
-#include "modules.h"
-#include "../BPY_extern.h"
-
-#define EXPP_TEXT_MODE_FOLLOW TXT_FOLLOW
-
-/*****************************************************************************/
-/* Python API function prototypes for the Text module. */
-/*****************************************************************************/
-static PyObject *M_Text_New (PyObject *self, PyObject *args,
- PyObject *keywords);
-static PyObject *M_Text_Get (PyObject *self, PyObject *args);
-static PyObject *M_Text_Load (PyObject *self, PyObject *args);
-static PyObject *M_Text_unlink (PyObject *self, PyObject *args);
-
-/*****************************************************************************/
-/* The following string definitions are used for documentation strings. */
-/* In Python these will be written to the console when doing a */
-/* Blender.Text.__doc__ */
-/*****************************************************************************/
-static char M_Text_doc[] =
-"The Blender Text module\n\n";
-
-static char M_Text_New_doc[] =
-"() - return a new Text object";
-
-static char M_Text_Get_doc[] =
-"(name) - return the Text with name 'name', \
-returns None if not found.\n If 'name' is not specified, \
-it returns a list of all Texts in the\ncurrent scene.";
-
-static char M_Text_Load_doc[] =
-"(filename) - return text from file filename as a Text Object, \
-returns None if not found.\n";
-
-static char M_Text_unlink_doc[] =
-"(text) - remove Text object 'text' from Blender";
-
-/*****************************************************************************/
-/* Python method structure definition for Blender.Text module: */
-/*****************************************************************************/
-struct PyMethodDef M_Text_methods[] = {
- {"New",(PyCFunction)M_Text_New, METH_VARARGS|METH_KEYWORDS,
- M_Text_New_doc},
- {"Get", M_Text_Get, METH_VARARGS, M_Text_Get_doc},
- {"get", M_Text_Get, METH_VARARGS, M_Text_Get_doc},
- {"Load", M_Text_Load, METH_VARARGS, M_Text_Load_doc},
- {"unlink", M_Text_unlink, METH_VARARGS, M_Text_unlink_doc},
- {NULL, NULL, 0, NULL}
-};
-
-/*****************************************************************************/
-/* Python BPy_Text structure definition: */
-/*****************************************************************************/
-typedef struct {
- PyObject_HEAD
- Text *text;
-
-} BPy_Text;
-
-/*****************************************************************************/
-/* Python BPy_Text methods declarations: */
-/*****************************************************************************/
-static PyObject *Text_getName(BPy_Text *self);
-static PyObject *Text_getFilename(BPy_Text *self);
-static PyObject *Text_getNLines(BPy_Text *self);
-static PyObject *Text_setName(BPy_Text *self, PyObject *args);
-static PyObject *Text_clear(BPy_Text *self, PyObject *args);
-static PyObject *Text_write(BPy_Text *self, PyObject *args);
-static PyObject *Text_set(BPy_Text *self, PyObject *args);
-static PyObject *Text_asLines(BPy_Text *self, PyObject *args);
-
-/*****************************************************************************/
-/* Python BPy_Text methods table: */
-/*****************************************************************************/
-static PyMethodDef BPy_Text_methods[] = {
- /* name, method, flags, doc */
- {"getName", (PyCFunction)Text_getName, METH_NOARGS,
- "() - Return Text Object name"},
- {"getFilename", (PyCFunction)Text_getFilename, METH_VARARGS,
- "() - Return Text Object filename"},
- {"getNLines", (PyCFunction)Text_getNLines, METH_VARARGS,
- "() - Return number of lines in text buffer"},
- {"setName", (PyCFunction)Text_setName, METH_VARARGS,
- "(str) - Change Text Object name"},
- {"clear", (PyCFunction)Text_clear, METH_VARARGS,
- "() - Clear Text buffer"},
- {"write", (PyCFunction)Text_write, METH_VARARGS,
- "(line) - Append string 'str' to Text buffer"},
- {"set", (PyCFunction)Text_set, METH_VARARGS,
- "(name, val) - Set attribute 'name' to value 'val'"},
- {"asLines", (PyCFunction)Text_asLines, METH_VARARGS,
- "() - Return text buffer as a list of lines"},
- {0}
-};
-
-/*****************************************************************************/
-/* Python Text_Type callback function prototypes: */
-/*****************************************************************************/
-static void Text_dealloc (BPy_Text *self);
-static int Text_setAttr (BPy_Text *self, char *name, PyObject *v);
-static PyObject *Text_getAttr (BPy_Text *self, char *name);
-static int Text_compare (BPy_Text *a, BPy_Text *b);
-static PyObject *Text_repr (BPy_Text *self);
-
-/*****************************************************************************/
-/* Python Text_Type structure definition: */
-/*****************************************************************************/
-PyTypeObject Text_Type =
-{
- PyObject_HEAD_INIT(NULL)
- 0, /* ob_size */
- "Blender Text", /* tp_name */
- sizeof (BPy_Text), /* tp_basicsize */
- 0, /* tp_itemsize */
- /* methods */
- (destructor)Text_dealloc, /* tp_dealloc */
- 0, /* tp_print */
- (getattrfunc)Text_getAttr, /* tp_getattr */
- (setattrfunc)Text_setAttr, /* tp_setattr */
- (cmpfunc)Text_compare, /* tp_compare */
- (reprfunc)Text_repr, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- 0, /* tp_as_hash */
- 0,0,0,0,0,0,
- 0, /* tp_doc */
- 0,0,0,0,0,0,
- BPy_Text_methods, /* tp_methods */
- 0, /* tp_members */
-};
-
-static int Text_IsLinked(BPy_Text *self);
-
#endif /* EXPP_TEXT_H */
diff --git a/source/blender/python/api2_2x/doc/Blender.py b/source/blender/python/api2_2x/doc/Blender.py
index a391c4cf64a..aebbdc3c77a 100644
--- a/source/blender/python/api2_2x/doc/Blender.py
+++ b/source/blender/python/api2_2x/doc/Blender.py
@@ -62,8 +62,8 @@ The Blender Python API Reference
open-source language.
@author: The Blender Python Team
-@requires: Blender 2.33 or newer.
-@version: 2.33a
+@requires: Blender 2.33+ or newer.
+@version: 2.33a-cvs
@see: U{www.blender.org<http://www.blender.org>}
@see: U{projects.blender.org<http://projects.blender.org>}
@see: U{www.python.org<http://www.python.org>}
@@ -90,6 +90,9 @@ def Get (request):
- 'staframe': the start frame of the animation
- 'endframe': the end frame of the animation
- 'filename': the name of the last file read or written
+ - 'datadir' : the path to the dir where scripts should store and
+ retrieve their data files, including saved configuration (can
+ be None, if not found).
- 'version' : the Blender version number
@return: The requested data.
"""
@@ -99,8 +102,25 @@ def Redraw ():
Redraw all 3D windows.
"""
-def ReleaseGlobalDict (bool = None):
+def Load (filename = None):
"""
- @depreciated: this function doesn't work anymore and will be removed.
- Look at the L{Registry} submodule for a better alternative.
+ Load a Blender .blend file.
+ @type filename: string
+ @param filename: the pathname to the desired .blend file. If 'filename'
+ isn't given or if it contains the substring '.B.blend', the default
+ .B.blend file is loaded.
+
+ @warn: loading a new .blend file removes the current data in Blender. For
+ safety, this function saves the current data as an autosave file in
+ the temporary dir used by Blender before loading the new file.
+ """
+
+def Quit ():
+ """
+ Exit from Blender immediately.
+ @warn: the use of this function should obviously be avoided, it is available
+ because there are some cases where it can be useful, like in automated
+ tests. For safety, a "quit.blend" file is saved (normal Blender behavior
+ upon exiting) when this function is called, so the data in Blender isn't
+ lost.
"""
diff --git a/source/blender/python/api2_2x/doc/Draw.py b/source/blender/python/api2_2x/doc/Draw.py
index 3c391f93848..0a7b566c273 100644
--- a/source/blender/python/api2_2x/doc/Draw.py
+++ b/source/blender/python/api2_2x/doc/Draw.py
@@ -170,6 +170,70 @@ def PupMenu(name, maxrow = None):
@return: the chosen entry number or -1 if none was chosen.
"""
+def PupIntInput(text, default, min, max):
+ """
+ Create an integer number input pop-up.
+
+ This allows python to use Blender's integer number popup input.
+
+ Example::
+ default = 50
+ min = 0
+ max = 100
+
+ result = Draw.PupIntInput('Set this value between 0 and 100', default, min, max)
+ if result != None:
+ print result
+ else:
+ print 'no user input'
+
+ @type text: string
+ @param text: The text that is displayed in the popup.
+ @type default: int
+ @param default: The value that the popup is set to initialy.
+ @type min: int
+ @param min: The lowest value the popup will allow.
+ @type max: int
+ @param max: The highest value the popup will allow.
+ @rtype: int
+ @return: the number chosen or None if none was chosen.
+ """
+
+def PupFloatInput(text, default, min, max, clickStep, floatLen):
+ """
+ Create a floating point number input pop-up.
+
+ This allows python to use Blender's floating point popup input.
+
+ Example::
+ default = 50
+ min = 0
+ max = 100
+ clickStep = 10
+ floatLen = 3
+
+ result = Draw.PupIntInput('Set this value between 0 and 100', default, min, max, clickStep, floatLen)
+ if result != None:
+ print result
+ else:
+ print 'no user input'
+
+ @type text: string
+ @param text: The text that is displayed in the popup.
+ @type default: float
+ @param default: The value that the popup is set to initialy.
+ @type min: float
+ @param min: The lowest value the popup will allow.
+ @type max: float
+ @param max: The highest value the popup will allow.
+ @type clickStep: int
+ @param clickStep: How much is incremented per user click, 100 will increment 1.0, 10 will increment 0.1 etc.
+ @type floatLen: int
+ @param floatLen: The number of decimal places to display, between 2 and 4.
+ @rtype: float
+ @return: the number chosen or None if none was chosen.
+ """
+
def Menu(name, event, x, y, width, height, default, tooltip = None):
"""
Create a new Menu Button object.