Date: Wed, 06 Jul 2005 21:22:00 +0000
From: "Freddie Witherden" <[EMAIL PROTECTED]>
Subject: RE: [IronPython] Making A Windows Form App
To: users-ironpython.com@lists.ironpython.com
Message-ID: <[EMAIL PROTECTED]>
Content-Type: text/plain; format=flowed
Namespaces are the biggest problem, LoadAssemblyByName and importing
modules are always a paint for me. The 'editor' or command line tool is
also a bit annoying as you can not copy or paste text from/to it which
makes it harder to work with, but when I had a poke about with MSIL
Disassembler I found: IronPythonConsole.FancyConsole, is this some kind of
more advanced console, as I often make a lot of small programs in
IronPython to test things about and something like a nicer IDE would be
great, it is not like Jython where I can get a book so better
documentation would go a long way.
From: Martin Maly <[EMAIL PROTECTED]>
Reply-To: Discussion of IronPython
<users-ironpython.com@lists.ironpython.com>
To: "Discussion of IronPython"
<users-ironpython.com@lists.ironpython.com>
Subject: RE: [IronPython] Making A Windows Form App
Date: Wed, 6 Jul 2005 13:13:17 -0700
MIME-Version: 1.0
Received: from moutng.kundenserver.de ([212.227.126.183]) by
mc2-f39.hotmail.com with Microsoft SMTPSVC(6.0.3790.211); Wed, 6 Jul 2005
13:13:30 -0700
Received: from [66.33.206.23] (helo=frida.dreamhost.com)by
mxeu13.kundenserver.de with ESMTP (Nemesis),id 0MKsEO-1DqGGy2JMq-0008HJ
for [EMAIL PROTECTED]; Wed, 06 Jul 2005 22:13:32 +0200
Received: from che.dreamhost.com (che.dreamhost.com [66.33.216.23])by
frida.dreamhost.com (Postfix) with ESMTPid 487F516D644; Wed, 6 Jul 2005
13:13:31 -0700 (PDT)
Received: from che.dreamhost.com (localhost [127.0.0.1])by
che.dreamhost.com (Postfix) with ESMTPid 8C59D1BA82; Wed, 6 Jul 2005
13:13:28 -0700 (PDT)
Received: from mail1.exchange.microsoft.com
(mail1.exchange.microsoft.com[131.107.76.156])by che.dreamhost.com
(Postfix) with ESMTP id CD58D1BA81for
<users-ironpython.com@lists.ironpython.com>;Wed, 6 Jul 2005 13:13:23
-0700 (PDT)
Received: from DF-GWY-01.Exchange.Corp.Microsoft.com ([157.54.54.62])
bymail1.exchange.microsoft.com over TLS secured channel withMicrosoft
SMTPSVC(6.0.3790.1830); Wed, 6 Jul 2005 13:11:39 -0700
Received: from df-hub-01.exchange.corp.microsoft.com (157.54.8.109)
byDF-GWY-01.Exchange.Corp.microsoft.com (157.54.54.62) with MicrosoftSMTP
Server id 8.0.324.11; Wed, 6 Jul 2005 20:11:38 +0000
Received: from df-hub-01.exchange.corp.microsoft.com ([157.54.8.109])
bydf-hub-01.exchange.corp.microsoft.com with
MicrosoftSMTPSVC(6.0.3790.1830); Wed, 6 Jul 2005 13:11:38 -0700
Received: from DF-BANDIT-BHD.Exchange.Microsoft.com ([157.54.54.229])
bydf-hub-01.exchange.corp.microsoft.com over TLS secured channel
withMicrosoft SMTPSVC(6.0.3790.1830); Wed, 6 Jul 2005 13:11:37 -0700
X-Message-Info: JGTYoYF78jHWL9MmXrcWU2adrcEMNnu1M4xRlrPMp/U=
Delivered-To: [EMAIL PROTECTED]
Content-Class: urn:content-classes:message
X-MimeOLE: Produced By Microsoft Exchange V6.5.7226.0
X-OriginalArrivalTime: 06 Jul 2005 20:11:37.0569
(UTC)FILETIME=[EA18B510:01C58266]
X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: [IronPython] Making
A Windows Form App
Thread-Index: AcWCZWV8ChLmjDVBQuSUEVbp1jOpZQAARvlA
X-BeenThere: users-ironpython.com@lists.ironpython.com
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: Discussion of IronPython
<users-ironpython.com.lists.ironpython.com>
List-Unsubscribe:
<http://lists.ironpython.com/listinfo.cgi/users-ironpython.com>,<mailto:[EMAIL PROTECTED]>
List-Archive:
<http://listserver.dreamhost.com/pipermail/users-ironpython.com>
List-Post: <mailto:users-ironpython.com@lists.ironpython.com>
List-Help:
<mailto:[EMAIL PROTECTED]>
List-Subscribe:
<http://lists.ironpython.com/listinfo.cgi/users-ironpython.com>,<mailto:[EMAIL PROTECTED]>
Errors-To: [EMAIL PROTECTED]
Return-Path: [EMAIL PROTECTED]
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
------------------------------
Message: 2
Date: Thu, 07 Jul 2005 18:47:39 +0000
From: "Freddie Witherden" <[EMAIL PROTECTED]>
Subject: RE: [IronPython] Making A Windows Form App
To: users-ironpython.com@lists.ironpython.com
Message-ID: <[EMAIL PROTECTED]>
Content-Type: text/plain; format=flowed
.net is a lot like Java, and we can be quite sure that many moons ago the
JPython team (as it was then known) had the same problem with Java
modules, and probably had a long and heated debate about it so I think we
should do it 'the Jython way' as there have never been any problems with
it and lots of people use Jython so it must work.
From: Jim Hugunin <[EMAIL PROTECTED]>
Reply-To: Discussion of IronPython
<users-ironpython.com@lists.ironpython.com>
To: "Discussion of IronPython"
<users-ironpython.com@lists.ironpython.com>
Subject: RE: [IronPython] Making A Windows Form App
Date: Wed, 6 Jul 2005 17:23:55 -0700
MIME-Version: 1.0
Received: from moutng.kundenserver.de ([212.227.126.171]) by
mc4-f18.hotmail.com with Microsoft SMTPSVC(6.0.3790.211); Wed, 6 Jul 2005
17:24:13 -0700
Received: from [66.33.206.23] (helo=frida.dreamhost.com)by
mxeu11.kundenserver.de with ESMTP (Nemesis),id 0MKuA8-1DqKBQ3a3n-0005pt
for [EMAIL PROTECTED]; Thu, 07 Jul 2005 02:24:04 +0200
Received: from che.dreamhost.com (che.dreamhost.com [66.33.216.23])by
frida.dreamhost.com (Postfix) with ESMTPid 880F316D56B; Wed, 6 Jul 2005
17:24:03 -0700 (PDT)
Received: from che.dreamhost.com (localhost [127.0.0.1])by
che.dreamhost.com (Postfix) with ESMTPid 4D3FB1BA82; Wed, 6 Jul 2005
17:23:59 -0700 (PDT)
Received: from mail1.exchange.microsoft.com
(mail1.exchange.microsoft.com[131.107.76.156])by che.dreamhost.com
(Postfix) with ESMTP id F39541BA63for
<users-ironpython.com@lists.ironpython.com>;Wed, 6 Jul 2005 17:23:56
-0700 (PDT)
Received: from DF-GWY-01.Exchange.Corp.Microsoft.com ([157.54.54.62])
bymail1.exchange.microsoft.com over TLS secured channel withMicrosoft
SMTPSVC(6.0.3790.1830); Wed, 6 Jul 2005 17:22:12 -0700
Received: from df-hub-01.exchange.corp.microsoft.com (157.54.8.109)
byDF-GWY-01.Exchange.Corp.microsoft.com (157.54.54.62) with MicrosoftSMTP
Server id 8.0.324.11; Thu, 7 Jul 2005 00:22:12 +0000
Received: from df-hub-01.exchange.corp.microsoft.com ([157.54.8.109])
bydf-hub-01.exchange.corp.microsoft.com with
MicrosoftSMTPSVC(6.0.3790.1830); Wed, 6 Jul 2005 17:22:12 -0700
Received: from DF-BANDIT-BHD.Exchange.Microsoft.com ([157.54.54.229])
bydf-hub-01.exchange.corp.microsoft.com over TLS secured channel
withMicrosoft SMTPSVC(6.0.3790.1830); Wed, 6 Jul 2005 17:22:12 -0700
X-Message-Info: JGTYoYF78jFojgLyvLebIfsbiobYIaFJ60Vutv4BY8A=
Delivered-To: [EMAIL PROTECTED]
Content-Class: urn:content-classes:message
X-MimeOLE: Produced By Microsoft Exchange V6.5.7226.0
X-OriginalArrivalTime: 07 Jul 2005 00:22:12.0177
(UTC)FILETIME=[EB6BD410:01C58289]
X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: [IronPython] Making
A Windows Form App
Thread-Index: AcWCZWV8ChLmjDVBQuSUEVbp1jOpZQAARvlAAADzv3MAB2xg0A==
X-BeenThere: users-ironpython.com@lists.ironpython.com
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: Discussion of IronPython
<users-ironpython.com.lists.ironpython.com>
List-Unsubscribe:
<http://lists.ironpython.com/listinfo.cgi/users-ironpython.com>,<mailto:[EMAIL PROTECTED]>
List-Archive:
<http://listserver.dreamhost.com/pipermail/users-ironpython.com>
List-Post: <mailto:users-ironpython.com@lists.ironpython.com>
List-Help:
<mailto:[EMAIL PROTECTED]>
List-Subscribe:
<http://lists.ironpython.com/listinfo.cgi/users-ironpython.com>,<mailto:[EMAIL PROTECTED]>
Errors-To: [EMAIL PROTECTED]
Return-Path: [EMAIL PROTECTED]
We clearly need a better design than the current sys.LoadAssembly*
methods. For one thing, we shouldn't really be adding these to the
existing sys module but putting new methods like this in a new IronPython
module. As you point out, we should also do a better job of making this
as invisible to the user as possible.
In IronPython-0.6, a much larger number of assemblies were automatically
searched for - including the two shown below. This meant that this
particular program could run without any of this nonsense. The problem
here was that this just delayed the issue of people learning about this
issue and made things even more confusing when they wanted to use an
assembly that wasn't in the known list. I decided that at this stage it
was better to raise this issue front-and-center so that people would be
aware of it and hopefully get quickly familiar with it. The other reason
I wanted to make this more explicit was in the hopes that it would spur
discussion about better ways of solving the problem.
I'm certain that sys.LoadAssembly* is not what will ship with
IronPython-1.0. Here are a few possible options in no particular order.
1. Guess the assembly based on the path, i.e. import System.Drawing will
try to load "System.Drawing". This would be great if it was a naming
convention that was consistently followed, but alas it is a rule that is
so consistently broken I'm doubtful of the benefits.
2. Add a config file to specific a large set of default known assemblies
and have the user extend this with their own. This ties scripts and
config files together in a deeper way than I'd prefer.
3. Extend import, i.e. import System.Drawing from System.Drawing. Of
course, the most obvious ways to do this are a change to the Python
language.
4. Search some well-known directories to come up with a list of known
assemblies and their types and then load assemblies strictly as needed
for imports. This would add many seconds to start-up time unless this
information is cached and caches are their own source of trouble. FYI -
This is closest to what Jython does.
5. I'm sure there are other good ideas out there...
There's a whole separate question as to whether or not any loading by
partial name is too dangerous even as explicit as it is today, see here:
http://blogs.msdn.com/suzcook/archive/2003/05/30/57159.aspx
Thanks - Jim
________________________________________
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of
Keith J. Farmer
Sent: Wednesday, July 06, 2005 1:36 PM
To: Discussion of IronPython
Subject: RE: [IronPython] Making A Windows Form App
Out of curiosity, would it be possible to get IronPython to make a
best-guess attempt at automatically loading an appropriate assembly, if
it discovers that it doesn't know the namespace?
This could alleviate the problems people have with remembering
sys.LoadAssemblyByName.
________________________________________
From: [EMAIL PROTECTED] on behalf of
Martin Maly
Sent: Wed 7/6/2005 1:13 PM
import sys
sys.LoadAssemblyByName("System.Drawing")
sys.LoadAssemblyByName("System.Windows.Forms")
_______________________________________________
users-ironpython.com mailing list
users-ironpython.com@lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
------------------------------
Message: 3
Date: Mon, 11 Jul 2005 15:52:08 -0700
From: Martin Maly <[EMAIL PROTECTED]>
Subject: RE: [IronPython] Documentation
To: "Discussion of IronPython"
<users-ironpython.com@lists.ironpython.com>
Message-ID:
<[EMAIL PROTECTED]>
Content-Type: text/plain; charset="us-ascii"
As of this moment there is no official documentation project under way
except
for the readme that is part of the distribution. The readme gives few
examples
and covers LoadAssemblyByName. Overall, the documentation story as of
now is
not a very good one and we need to improve it.
As for IronPython and WinForms, I have been successful finding all
answers to my
WinForms related problems in MSDN documentation. Granted, the
documentation shows
examples with VB and C#, but the class hierarchy and general information
how to use
WinForms does apply to IronPython very well.
Hope this helps.
Martin
-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of
Freddie Witherden
Sent: Friday, July 01, 2005 7:57 AM
To: users-ironpython.com@lists.ironpython.com
Subject: [IronPython] Documentation
Hi, I would like to know if there is currently any form of documentation
project running for IronPython. As, while I am very fond of it there are
a few things that do need to be documented, eg import sys
sys.LoadAssemblyByName()
As LoadAssemblyByName is not a standard method of the sys object. It
would be nice to have some information on windows forms which are also a
'special' feature of IronPython.
------------------------------
Message: 4
Date: Mon, 11 Jul 2005 15:54:02 -0700
From: Martin Maly <[EMAIL PROTECTED]>
Subject: RE: [IronPython] Making A Windows Form App
To: "Discussion of IronPython"
<users-ironpython.com@lists.ironpython.com>
Message-ID:
<[EMAIL PROTECTED]>
Content-Type: text/plain; charset="us-ascii"
The command line tool that comes with IronPython runs in the standard
Windows console.
You can set up the console to allow copy'n' paste. To do that:
left click on the icon on the upper-left corner of the console window
select "Defaults"
Check "Quick edit mode"
Restart the IronPython.
Then you can use mouse to select area on the console. Right click (or
Enter) will copy to clipboard
and another right click of the mouse will insert the text as a console
input. I find this very useful
when using the IronPython console.
Martin
-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of
Freddie Witherden
Sent: Wednesday, July 06, 2005 2:22 PM
To: users-ironpython.com@lists.ironpython.com
Subject: RE: [IronPython] Making A Windows Form App
Namespaces are the biggest problem, LoadAssemblyByName and importing
modules are always a paint for me. The 'editor' or command line tool is
also a bit annoying as you can not copy or paste text from/to it which
makes it harder to work with, but when I had a poke about with MSIL
Disassembler I found: IronPythonConsole.FancyConsole, is this some kind
of more advanced console, as I often make a lot of small programs in
IronPython to test things about and something like a nicer IDE would be
great, it is not like Jython where I can get a book so better
documentation would go a long way.
------------------------------
Message: 5
Date: Mon, 11 Jul 2005 16:10:03 -0700
From: Martin Maly <[EMAIL PROTECTED]>
Subject: RE: [IronPython] Embedding.
To: "Discussion of IronPython"
<users-ironpython.com@lists.ironpython.com>
Message-ID:
<[EMAIL PROTECTED]>
Content-Type: text/plain; charset="us-ascii"
Sorry for the delay in responding, Alan.
For the simplest scenarios you don't need to initialize PythonEngine.
For example, consider:
class Program {
static void Main(string[] args) {
PythonEngine e = new PythonEngine();
object r = e.Evaluate("2+2"); //r == 4
}
}
For the more complicated cases, initialization is often necessary (for
example to execute scripts that import modules and need sys.path
initialized etc. You can refer to PythonCommandLine.cs to see how the
IronPythonConsole initializes the PythonEngine. Essentially, we set up
things
1) The sys.path variable (via PythonEngine.AddToPath method)
2) further setup of sys module (via PythonEngine.InitializeModules
method)
- this sets up sys.version, sys.prefix, sys.executable and
sys.exec_prefix attributes
3) import site.py (via PythonEngine.ImportSite method)
The interactive initialization is slightly different, but essentially
this is all that is needed to get IronPython engine initialized.
Hope this helps. Let me know if other questions arise.
Martin
Alan Kennedy Wrote:
Greetings all,
I've worked a lot with jython in the past, and have often made use of it
by embedding it in java servers.
I'd like to try the same thing with Ironpython.
Is there any documentation on how to go about this? I'm specifically
interested in writing ironpython "servlets", i.e. servicing web requests
with ironpython code.
Under jython, the interpreter has to be initialised before scripts can be
executed. Is a similar initialisation necessary under ironpython?
Thanks in advance,
Regards,
Alan.
------------------------------
_______________________________________________
users-ironpython.com mailing list
users-ironpython.com@lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
End of users-ironpython.com Digest, Vol 12, Issue 9
***************************************************