IronPython integration

|
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Windows.Forms;
using IronPython.Hosting;
using IronPython.Runtime;

namespace TabbedImages {

    class TabbedImages {

        [STAThread]
        static void Main(string[] rawArgs) {
            List args = new List(rawArgs);
            args.Insert(0, Application.ExecutablePath);

            string dir = Path.GetDirectoryName(Application.ExecutablePath);
            PythonEngine engine = new PythonEngine();
            engine.AddToPath(dir);
            engine.Sys.argv = List.Make(args);

            Dictionary<string, object> d = new Dictionary<string, object>();
            EngineModule engineModule = engine.CreateModule("__main__", d, true);
            engine.DefaultModule = engineModule;

            string path = Path.Combine(dir, "main.py");
            engine.ExecuteFile(path);
        }
    }
}

Leave a comment

Verification (needed to reduce spam):

Pages

OpenID accepted here Learn more about OpenID
Powered by Movable Type 4.32-en

About this Entry

This page contains a single entry by Hugh Brown published on June 26, 2008 5:54 PM.

Lean Software Development was the previous entry in this blog.

US State Quarters Update 3 is the next entry in this blog.

Find recent content on the main index or look in the archives to find all content.