[Zope-CVS] CVS: PythonNet/demo - helloform.py:1.1

Brian Lloyd brian@zope.com
Mon, 17 Feb 2003 22:44:36 -0500


Update of /cvs-repository/PythonNet/demo
In directory cvs.zope.org:/tmp/cvs-serv5356/demo

Added Files:
	helloform.py 
Log Message:
initial commit

=== Added File PythonNet/demo/helloform.py ===
# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
#
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL).  A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
import gc
gc.disable()

import CLR.System.Windows.Forms as WinForms
from CLR.System.Drawing import Size, Point

class HelloApp:
    def __init__(self):
        self.form = WinForms.Form()
        self.form.Text = "Hello World From Python"
        self.form.AutoScaleBaseSize = Size(5, 13)
        self.form.ClientSize = Size(392, 117);
        h = WinForms.SystemInformation.CaptionHeight
        self.form.MinimumSize = Size(392, (117 + h))

        # Create the button
        self.button = WinForms.Button()
        self.button.Location = Point(256, 64)
        self.button.Size = Size(120, 40)
        self.button.TabIndex = 2
        self.button.Text = "Click Me!"
        
        # Register the event handler
        self.button.Click += self.button_Click
        self.button.Click += self.button_Click2

        # Create the text box
        self.textbox = WinForms.TextBox()
        self.textbox.Text = "Hello Windows Forms World"
        self.textbox.TabIndex = 1
        self.textbox.Size = Size(360, 20)
        self.textbox.Location = Point(16, 24)
        
        # Add the controls to the form
        self.form.AcceptButton = self.button
        self.form.Controls.Add(self.button);
        self.form.Controls.Add(self.textbox);


    def button_Click(self, sender, args):
        """ """
        WinForms.MessageBox.Show("button was clicked")

    def button_Click2(self, sender, args):
        """ """
        print 'I saw the event too!'


def main():
    WinForms.Application.Run(HelloApp().form)

if __name__ == '__main__':
    main()