如何制作熨斗 python 下拉菜单

how to make an iron python drop down menu

我编写了这个程序,但我想将 bacon 更改为下拉列表而不是文本框。但我不知道 Iron python 中的下拉菜单是什么样的。我乐于接受建议。

  import clr
  clr.AddReference('System.Drawing')
  clr.AddReference('System.Windows.Forms')

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

  class SimpleTextBoxForm(Form):
    def __init__(self):
        self.Text = "Production Plan Pull"

        self.Width = 300
        self.Height = 250

        self.label = Label()
        self.label.Text = "bacon"
        self.label.Location = Point(25, 25)
        self.label.Height = 25
        self.label.Width = 75

        self.textbox = TextBox()
        self.textbox.Text = "Please Insert The bacon"
        self.textbox.Location = Point(100, 25)
        self.textbox.Width = 150

        self.label2 = Label()
        self.label2.Text = "soup"
        self.label2.Location = Point(25, 50)
        self.label2.Height = 25
        self.label2.Width = 75

        self.textbox2 = TextBox()
        self.textbox2.Text = "Please Insert The Soup"
        self.textbox2.Location = Point(100, 50)
        self.textbox2.Width = 150

        self.label3 = Label()
        self.label3.Text = "dork"
        self.label3.Location = Point(25, 75)
        self.label3.Height = 25
        self.label3.Width = 75

        self.textbox3 = TextBox()
        self.textbox3.Text = "Please Insert The dork"
        self.textbox3.Location = Point(100, 75)
        self.textbox3.Width = 150

        self.button1 = Button()
        self.button1.Text = 'Submit'
        self.button1.Location = Point(50, 125)
        self.button1.Click += self.update

        self.button2 = Button()
        self.button2.Text = 'Reset'
        self.button2.Location = Point(150, 125)
        self.button2.Click += self.reset




        self.AcceptButton = self.button1
        self.CancelButton = self.button2
        self.Controls.Add(self.label)
        self.Controls.Add(self.textbox)
        self.Controls.Add(self.label2)
        self.Controls.Add(self.textbox2)
        self.Controls.Add(self.label3)
        self.Controls.Add(self.textbox3)
        self.Controls.Add(self.button1)
        self.Controls.Add(self.button2)

    def update(self, sender, event):
        self.label.Text = self.textbox.Text

    def reset(self, sender, event):
        self.label.Text = "Nothing So Far"
        self.textbox.Text = "The Default Text"

  form = SimpleTextBoxForm()
  Application.Run(form)

IronPython 是您正在使用的编程语言,文本框或下拉菜单是您正在使用的 UI 库的产品。他们根本不一样。

您正在使用 Windows Forms for your UI. Get acquainted with the available controls 或自己构建一个。

您要查找的是ComboBox。更改您的 "bacon" 控件以使用它。