diff options
author | Guido van Rossum <guido@python.org> | 1995-02-05 16:54:27 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 1995-02-05 16:54:27 (GMT) |
commit | 9bcb641ad4d4ee6e4ea47cb27584c6cd743904d4 (patch) | |
tree | 7c693c8e465205ca4253f2785d20c87e9d88debc | |
parent | 0818a4c152fdf45c20c87d379fd4060600bd671d (diff) | |
download | cpython-9bcb641ad4d4ee6e4ea47cb27584c6cd743904d4.zip cpython-9bcb641ad4d4ee6e4ea47cb27584c6cd743904d4.tar.gz cpython-9bcb641ad4d4ee6e4ea47cb27584c6cd743904d4.tar.bz2 |
added Resource(), to create new resources from Python
-rw-r--r-- | Mac/Modules/res/Resmodule.c | 28 | ||||
-rw-r--r-- | Mac/Modules/res/ressupport.py | 1 |
2 files changed, 29 insertions, 0 deletions
diff --git a/Mac/Modules/res/Resmodule.c b/Mac/Modules/res/Resmodule.c index 484bca6..a0e487c 100644 --- a/Mac/Modules/res/Resmodule.c +++ b/Mac/Modules/res/Resmodule.c @@ -30,6 +30,8 @@ extern int MenuObj_Convert(PyObject *, MenuHandle *); extern PyObject *CtlObj_New(ControlHandle); extern int CtlObj_Convert(PyObject *, ControlHandle *); +extern PyObject *WinObj_WhichWindow(WindowPtr); + #include <Resources.h> #define resNotFound -192 /* Can't include <Errors.h> because of Python's "errors.h" */ @@ -1161,6 +1163,30 @@ static PyObject *Res_FSpCreateResFile(_self, _args) return _res; } +static PyObject *Res_Resource(_self, _args) + PyObject *_self; + PyObject *_args; +{ + PyObject *_res = NULL; + + char *buf; + int len; + Handle h; + + if (!PyArg_ParseTuple(_args, "s#", &buf, &len)) + return NULL; + h = NewHandle(len); + if ( h == NULL ) { + PyErr_NoMemory(); + return NULL; + } + HLock(h); + memcpy(*h, buf, len); + HUnlock(h); + return (PyObject *)ResObj_New(h); + +} + static PyMethodDef Res_methods[] = { {"InitResources", (PyCFunction)Res_InitResources, 1, "() -> (short _rv)"}, @@ -1228,6 +1254,8 @@ static PyMethodDef Res_methods[] = { "(FSSpec spec, SignedByte permission) -> (short _rv)"}, {"FSpCreateResFile", (PyCFunction)Res_FSpCreateResFile, 1, "(FSSpec spec, OSType creator, OSType fileType, ScriptCode scriptTag) -> None"}, + {"Resource", (PyCFunction)Res_Resource, 1, + "Convert a string to a resource object.\n\nThe created resource object is actually just a handle.\nApply AddResource() to write it to a resource file.\n"}, {NULL, NULL, 0} }; diff --git a/Mac/Modules/res/ressupport.py b/Mac/Modules/res/ressupport.py index 5c0d70f..a44af09 100644 --- a/Mac/Modules/res/ressupport.py +++ b/Mac/Modules/res/ressupport.py @@ -69,6 +69,7 @@ functions = [] resmethods = [] execfile('resgen.py') +execfile('resedit.py') for f in functions: module.add(f) for f in resmethods: resobject.add(f) |