[IronPython] Embedding a script

Jeff Collett jcollett at oshtruck.com
Mon Aug 21 21:36:22 CEST 2006

I have a C# app that I am trying to display some values from a Python
A bit shorted here but when I click button1 I want to see the value of
varOne appear in
textBox2. Not sure if this is exactly the way to approach this or not.

public partial class Form1 : Form
        private PythonEngine engine;

        public Form1()
            engine = new PythonEngine();
            engine.Globals["form"] = this;
            engine.Globals["varOne"] = 1;//set varOne for testing


        private void button1_Click(object sender, EventArgs e)

                object testvarOne;
                testvarOne = engine.Globals["varOne"];//get varOne
                engine.Execute(textBox2.Text = 'print testvarOne');



Although this e-mail and any attachments are believed to be free of any virus or other defect which might affect any computer system, it is the responsibility of the recipient to check that it is virus-free and the sender accepts no responsibility or liability for any loss, injury, damage, cost or expense arising in any way from receipt or use thereof by the recipient.

The information contained in this electronic mail message is confidential information and intended only for the use of the individual or entity named above, and may be privileged.  If the reader of this message is not the intended recipient, you are hereby notified that any dissemination, distribution or copying of this communication is strictly prohibited.  If you have received this transmission in error, please  contact the sender immediately, delete this material from your computer and destroy all related paper media.  Please note that the documents transmitted are not intended to be binding until a hard copy has been manually signed by all parties.
Thank you.

More information about the Ironpython-users mailing list