simple_input_example
Differences
This shows you the differences between two versions of the page.
— | simple_input_example [2022/09/03 23:25] (current) – created - external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | < | ||
+ | import clr | ||
+ | clr.AddReference (' | ||
+ | clr.AddReference(' | ||
+ | |||
+ | from System.Drawing import Point | ||
+ | from System.Windows.Forms import TextBox, Keys, KeyPressEventHandler | ||
+ | |||
+ | from System.Windows import Forms | ||
+ | |||
+ | class MyMainForm(Forms.Form): | ||
+ | def __init__(self): | ||
+ | self.Width = 300 | ||
+ | self.Height = 200 | ||
+ | self.Text = 'Main Form' | ||
+ | my_button = Forms.Button(Text=' | ||
+ | my_button.Click += self.MyOnClick | ||
+ | my_button.Location = Point(25, 95) | ||
+ | self.Controls.Add(my_button) | ||
+ | | ||
+ | self.textbox = TextBox() | ||
+ | self.textbox.Text = " | ||
+ | self.textbox.Location = Point(25, 75) | ||
+ | self.textbox.Width = 150 | ||
+ | # | ||
+ | self.textbox.KeyPress += KeyPressEventHandler(self.OnEnter) | ||
+ | self.Controls.Add(self.textbox) | ||
+ | | ||
+ | def MyOnClick(self, | ||
+ | self.Finished() | ||
+ | | ||
+ | def OnEnter(self, | ||
+ | key = args.KeyChar | ||
+ | if key == Keys.Enter: | ||
+ | self.Finished() | ||
+ | | ||
+ | def Finished(self): | ||
+ | Misc.SendMessage(" | ||
+ | self.Close() | ||
+ | |||
+ | app = MyMainForm() | ||
+ | Forms.Application.Run(app) | ||
+ | </ | ||
simple_input_example.txt · Last modified: 2022/09/03 23:25 by 127.0.0.1