如何制作铁蟒下拉菜单

时间:2016-03-07 18:51:42

标签: winforms user-interface drop-down-menu ironpython

我已经编写了这个程序但是我想将培根更改为下拉列表而不是文本框。但我不知道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)

1 个答案:

答案 0 :(得分:2)

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

您正在使用Windows Forms作为用户界面。熟悉available controls或自己构建一个。

您正在寻找的是ComboBox。更改您的"bacon"控件以改为使用它。