Re: gypsthon patch

From: Martin Sevior (msevior@physics.unimelb.edu.au)
Date: Fri Dec 06 2002 - 05:30:40 EST

  • Next message: Martin Sevior: "My movements."

    On Fri, 6 Dec 2002, Mauro Colorio wrote:

    > > HI Maurio,
    >
    > Mauro, I'm MAURO!!:)
    >

    Whoops! Sorry Mauro. It appears that someone has committed your code as
    requested.
             
    >
    > > I haven't tried your code yet but I see no reason it won't work. This
    > > is great! I've always wanted to script abiword with python.
    > >
    > > But I have a question:
    > >
    > > How does one run python scripts now? What is the procedure for running
    > > python scripts.
    > >
    >
    > in the code or in abiword?
    > well in abiword you just install the plugin this add a menu into Tools
    > menu, and selecting that menu item it will prompt you a file select dialog,
    > when you select the script abiword runs it in an embedded python
    > interpreter.
    >

    Ah OK. Select Tools -> Python script, execute it.

    Very cool.

    Thanks!

    Martin

    > for the code exentially is describen in the Gypsython.cpp code
    >
    >
    >
    > Py_Initialize(); //initialize the python interpreter
    >
    > initgypsython(); // initialized the faked abiword module for python
    >
    >
    > // Well this can prevent to do a import gypsython in the script...but
    > it's so ugly!!
    > sprintf(loadmodulestring,
    > "import sys\n"
    > "import os\n"
    > "import string\n"
    > "import gypsython\n" // I need my own namespace:)
    > "(filepath, filename) = os.path.split('%s')\n" // if someone knows a
    > better way to do this..
    > "sys.path.append(filepath)\n__import__(filename)",m_sModulePath);
    > PyRun_SimpleString(loadmodulestring);
    >
    > loads and runs the script selected
    >
    >
    > Py_Finalize();
    >
    >
    >
    > finalize the python interpreter
    >
    > that's all:)
    >
    > ciao
    > Mauro
    >
    >



    This archive was generated by hypermail 2.1.4 : Fri Dec 06 2002 - 05:32:12 EST