Skip to content

Instantly share code, notes, and snippets.

@pewerner
Created November 6, 2013 11:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pewerner/7334679 to your computer and use it in GitHub Desktop.
Save pewerner/7334679 to your computer and use it in GitHub Desktop.
Simple IronPython WInForm
import clr
clr.AddReference('System.Windows.Forms')
clr.AddReference('System.Drawing')
from System.Windows.Forms import *
from System.Drawing import *
class MyForm(Form):
def __init__(self):
selectInput = Button()
selectInput.Location = Point(350, 50)
selectInput.Size = Size(100, 23);
selectInput.UseVisualStyleBackColor = True
selectInput.Click += self.onClick
selectInput.Text = 'Select Input File'
global inputFile
inputFile = TextBox()
inputFile.Location = Point(50, 50)
inputFile.Size = Size(183, 20);
self.ClientSize = Size(477, 450)
self.Controls.Add(selectInput)
self.Controls.Add(inputFile)
def onClick(self, sender, args):
fileDialog = OpenFileDialog()
fileDialog.InitialDirectory = "C:\\Users"
fileDialog.ShowDialog()
inputFile.Text = fileDialog.FileName
form = MyForm()
Application.Run(form)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment