FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
pythonnet/demo/helloform.py at master · pythonnet/pythonnet · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
pythonnet
/
pythonnet
Public
Notifications
You must be signed in to change notification settings
Fork
780
Star
5.5k
Code
Issues
153
Pull requests
12
Discussions
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Discussions
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
pythonnet
/
demo
/
helloform.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
63 lines (48 loc) · 1.73 KB
Breadcrumbs
pythonnet
/
demo
/
helloform.py
Copy path
File metadata and controls
63 lines (48 loc) · 1.73 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import
clr
clr
.
AddReference
(
"System.Windows.Forms"
)
import
System
.
Windows
.
Forms
as
WinForms
from
System
.
Drawing
import
Size
,
Point
class
HelloApp
(
WinForms
.
Form
):
"""A simple hello world app that demonstrates the essentials of
winforms programming and event-based programming in Python."""
def
__init__
(
self
):
super
().
__init__
()
self
.
Text
=
"Hello World From Python"
self
.
AutoScaleBaseSize
=
Size
(
5
,
13
)
self
.
ClientSize
=
Size
(
392
,
117
)
h
=
WinForms
.
SystemInformation
.
CaptionHeight
self
.
MinimumSize
=
Size
(
392
, (
117
+
h
))
# Create the button
self
.
button
=
WinForms
.
Button
()
self
.
button
.
Location
=
Point
(
160
,
64
)
self
.
button
.
Size
=
Size
(
820
,
20
)
self
.
button
.
TabIndex
=
2
self
.
button
.
Text
=
"Click Me!"
# Register the event handler
self
.
button
.
Click
+=
self
.
button_Click
# Create the text box
self
.
textbox
=
WinForms
.
TextBox
()
self
.
textbox
.
Text
=
"Hello World"
self
.
textbox
.
TabIndex
=
1
self
.
textbox
.
Size
=
Size
(
1260
,
40
)
self
.
textbox
.
Location
=
Point
(
160
,
24
)
# Add the controls to the form
self
.
AcceptButton
=
self
.
button
self
.
Controls
.
Add
(
self
.
button
)
self
.
Controls
.
Add
(
self
.
textbox
)
def
button_Click
(
self
,
sender
,
args
):
"""Button click event handler"""
print
(
"Click"
)
WinForms
.
MessageBox
.
Show
(
"Please do not press this button again."
)
def
run
(
self
):
WinForms
.
Application
.
Run
(
self
)
def
main
():
form
=
HelloApp
()
print
(
"form created"
)
app
=
WinForms
.
Application
print
(
"app referenced"
)
app
.
Run
(
form
)
if
__name__
==
'__main__'
:
main
()
Back
|
FazBrowse Home
|
New Git URL