ボタンが押されたらテキストボックスに入ってる内容に従って何か処理する・・・のサンプルコード
import clr
clr.AddReference("System.Windows.Forms")
from System.Windows import Forms
class SimpleInputForm(Forms.Form):
def __init__(self):
self.Height = 120
self.Width = 400
self.Text = 'IronPython Windows.Forms sample'
self.Controls.Add(Forms.Label(Left=20, Top=10, Text="Input your name."))
self.MessageText = Forms.TextBox(Left=20, Top=35, Width=350)
self.Controls.Add(self.MessageText)
self.MessageButton = Forms.Button(Text="&Message", Left=100, Top=60)
self.MessageButton.Click += self.OnClickHello
self.Controls.Add(self.MessageButton)
self.QuitButton = Forms.Button(Text="&Quit", Left=230, Top=60)
self.QuitButton.Click += self.OnClickClose
self.Controls.Add(self.QuitButton)
def OnClickHello(self, sender, args):
if self.MessageText.Text:
message = "Hello, " + self.MessageText.Text + "!"
else:
message = "Hello, world!"
Forms.MessageBox.Show(message)
def OnClickClose(self, sender, args):
self.Close()
if __name__ == '__main__':
app = SimpleInputForm()
Forms.Application.Run(app)
この記事へのコメント
Auststeend
Auststeend
Stepgit
StevSmisse
MatCymn
Kelreeste
MatCymn
MatCymn
StepPsype
Obsesse