入力した文字列を別の場所に表示する

文字を入力し、ボタンを押すと入力内容が下に表示される。


この基本的すぎる操作を行うためのコードは以下の通り。

import System.Drawing
import System.Windows.Forms

from System.Drawing import *
from System.Windows.Forms import *

class MainForm(Form):
 def __init__(self):
  self.InitializeComponent()
 
 def InitializeComponent(self):
  self._textInput = System.Windows.Forms.TextBox()
  self._buttonSend = System.Windows.Forms.Button()
  self._labelOutput = System.Windows.Forms.Label()
  self.SuspendLayout()
  #
  # textInput
  #
  self._textInput.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
  self._textInput.Location = System.Drawing.Point(28, 31)
  self._textInput.Name = "textInput"
  self._textInput.Size = System.Drawing.Size(221, 19)
  self._textInput.TabIndex = 0
  #
  # buttonSend
  #
  self._buttonSend.Location = System.Drawing.Point(167, 79)
  self._buttonSend.Name = "buttonSend"
  self._buttonSend.Size = System.Drawing.Size(81, 25)
  self._buttonSend.TabIndex = 1
  self._buttonSend.Text = "Send"
  self._buttonSend.UseVisualStyleBackColor = True
  self._buttonSend.Click += self.SendData
  #
  # labelOutput
  #
  self._labelOutput.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
  self._labelOutput.Location = System.Drawing.Point(32, 139)
  self._labelOutput.Name = "labelOutput"
  self._labelOutput.Size = System.Drawing.Size(217, 22)
  self._labelOutput.TabIndex = 2
  #
  # MainForm
  #
  self.ClientSize = System.Drawing.Size(284, 194)
  self.Controls.Add(self._labelOutput)
  self.Controls.Add(self._buttonSend)
  self.Controls.Add(self._textInput)
  self.Name = "MainForm"
  self.Text = "test"
  self.ResumeLayout(False)
  self.PerformLayout()
  
 def SendData(self, sender, e):
  self._labelOutput.Text = self._textInput.Text