Hi Freddie,

Below is the working code. I would be interested to hear what you had
most problems with. Common difficulty is the LoadAssemblyByName
function. Feel free to post feedback to this discussion alias. We are
interested to hear what roadblocks developers encounter as they try to
use IronPython.

Martin

import sys
sys.LoadAssemblyByName("System.Drawing")
sys.LoadAssemblyByName("System.Windows.Forms")

import System
from System.Drawing import Point
from System.Windows.Forms import Form, Button, Application

def on_click(*args):
    Application.Exit()

frm = Form(Text = "Hello World")
btn = Button(Text = "Goodbye", Location = Point(50,50))

btn.Click += on_click
frm.Controls.Add(btn)

Application.Run(frm)



 

> Freddie Witherden Wrote:
> 
> Hi, I am trying to convert a very simple C# windows form test 
> that I made into IronPython (to see that it can be done). 
> However I have tried over 20 different ways with no luck. Can 
> anyone help me? There is very very little documentation on 
> IronPython, which I think needs to be addressed. The code
> is:
> using System;
> using System.Drawing;
> using System.Windows.Forms;
> 
> namespace WinForms
> {
>       public class HelloWorld : System.Windows.Forms.Form
>       {
> 
>               private Button btn;
> 
>               public HelloWorld()
>               {
>             Text = "Hello World";
> 
>                       btn = new Button();
>                       btn.Location = new Point(50,50);
>                       btn.Text = "Goodbye";
>                       btn.Click += new System.EventHandler(btn_Click);
> 
>                       Controls.Add(btn);
>               }
> 
>               static void Main()
>               {
>                       Application.Run(new HelloWorld());
>               }
> 
>               private void btn_Click(object sender, EventArgs e)
>               {
>                       Application.Exit();
>               }
>       }
> }
_______________________________________________
users-ironpython.com mailing list
users-ironpython.com@lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com

Reply via email to