Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 84cee99

Browse files
author
Barton Cline
committed
Add required import clr and some diagnostics
1 parent 534b145 commit 84cee99

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

pythonnet/demo/helloform.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
# FOR A PARTICULAR PURPOSE.
88
# ===========================================================================
99

10+
import clr
11+
SWF = clr.AddReference("System.Windows.Forms")
12+
print SWF.Location
1013
import System.Windows.Forms as WinForms
1114
from System.Drawing import Size, Point
1215

@@ -24,8 +27,8 @@ def __init__(self):
2427

2528
# Create the button
2629
self.button = WinForms.Button()
27-
self.button.Location = Point(256, 64)
28-
self.button.Size = Size(120, 40)
30+
self.button.Location = Point(160, 64)
31+
self.button.Size = Size(820, 20)
2932
self.button.TabIndex = 2
3033
self.button.Text = "Click Me!"
3134

@@ -36,8 +39,8 @@ def __init__(self):
3639
self.textbox = WinForms.TextBox()
3740
self.textbox.Text = "Hello World"
3841
self.textbox.TabIndex = 1
39-
self.textbox.Size = Size(360, 20)
40-
self.textbox.Location = Point(16, 24)
42+
self.textbox.Size = Size(1260, 40)
43+
self.textbox.Location = Point(160, 24)
4144

4245
# Add the controls to the form
4346
self.AcceptButton = self.button
@@ -46,14 +49,19 @@ def __init__(self):
4649

4750
def button_Click(self, sender, args):
4851
"""Button click event handler"""
52+
print "Click"
4953
WinForms.MessageBox.Show("Please do not press this button again.")
5054

5155
def run(self):
5256
WinForms.Application.Run(self)
5357

5458

5559
def main():
56-
HelloApp().run()
60+
form = HelloApp()
61+
print "form created"
62+
app = WinForms.Application
63+
print "app referenced"
64+
app.Run(form)
5765

5866

5967
if __name__ == '__main__':

0 commit comments

Comments
 (0)