[Ironpython-users] Calling Python script from windows form

Slide slide.o.mix at gmail.com
Thu Jan 3 18:58:14 CET 2013


This might help, its an article I wrote with some example code.

http://earl-of-code.com/2012/02/testing-with-ironpython/

Thanks,

slide


On Thu, Jan 3, 2013 at 3:32 AM, Shaikh, Raheel <Raheel.Shaikh at baesystems.com
> wrote:

> **
> I'm an IronPython novice and would like some help.  I have a windows form
> that I have created in Visual Basic 2010 Express, which contains two
> text-boxes ('txtNumber' and 'txtResult') and a button ('btnSquare').  What
> I want to do is be able to call the below Python script ('Square.py') on
> clicking the button on the form;
>
>
> class SquarePython:
>
>     def __init__(self, number):
>
>         self.sq = number*number
>  This script should square the number that is input in to 'txtNumber' and
> then output the result in to 'txtResult'.  I know this is almost too
> simple, but I just need to know the basics.  Here's what I have so far in
> my VB code;
>
> Imports
> Microsoft.Scripting.Hosting
>
> Imports
> IronPython.Hosting
>
> Imports
> IronPython.Runtime.Types
>
> Public
> Class Square
>
>     Private Sub btnSquare_Click(ByVal sender As System.Object, ByVal e AsSystem.
> EventArgs) Handles btnSquare.Click
>
>         Dim runtime As ScriptRuntime = Python.CreateRuntime
>
>         Dim scope As ScriptScope = runtime.ExecuteFile("Square.py")
>
> End Sub
>
> End Class
>
> Thanks in advance.
>
> *Raheel Shaikh*
>
>
> ******************************************************************************
>
> The information contained in this communication may be commercially
> sensitive
>
> and/or legally privileged. If you have received this message in error
> please
>
> notify the sender or a member of the Communications team immediately by
> reply
>
> e-mail and then delete this message from your system. You must not
> disclose
>
> it to any other person or third party who is not on the original
> distribution.
>
>
>
> BAE SYSTEMS MARINE Limited. Registered number is 00229770.
>
> Registered Office: Warwick House, PO Box 87,
>
> Farnborough Aerospace Centre, Farnborough, Hampshire, GU14 6YU
>
>
> ******************************************************************************
>
> _______________________________________________
> Ironpython-users mailing list
> Ironpython-users at python.org
> http://mail.python.org/mailman/listinfo/ironpython-users
>
>


-- 
Website: http://earl-of-code.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ironpython-users/attachments/20130103/3cbfe263/attachment.html>


More information about the Ironpython-users mailing list