如何根据另一个组合框的选择显示组合框

时间:2012-02-12 18:26:44

标签: combobox wxpython

我正在尝试根据之前组合框中选择的特定项目显示(启用)组合框。我尝试了很多种组合,似乎无法让它表现得很好。它将正常显示(禁用),但我希望它仅在选择某个项目时显示(启用)。我试过.Refresh()和EVT_COMBOBOX,它们不起作用。以下是有问题的代码:

    #Media Quality
    self.formats3 = ['-sameq','-qmax']
    self.format_combo3=wx.ComboBox(self, size=(100, -1),value='Select Quality', choices=self.formats3, style=wx.CB_DROPDOWN, pos=(300,141))
    quality=self.format_combo3.GetValue()


    #-qmax settings
    self.formats4 = ['1','2','3','4','5','6','7','8']
    self.format_combo4=wx.ComboBox(self, size=(30, -1),value='0', choices=self.formats4, style=wx.CB_DROPDOWN, pos=(405,141))
    self.format_combo4.Disable()

    if quality == '-qmax':
        self.format_combo4.Enable()

    else:
        self.format_combo4.Disable()

解决方案:

    #-qmax settings
    self.formats4 = ['1','2','3','4','5','6','7','8']
    self.format_combo4=wx.ComboBox(panel, size=(30, -1),value='0', choices=self.formats4, style=wx.CB_DROPDOWN, pos=(405,111))
    self.format_combo4.Disable()


    #Media Quality
    self.formats5 = ['Select Preset','video to mp3']
    self.format_combo5=wx.ComboBox(panel, size=(100, -1),value='Select Preset', choices=self.formats5, style=wx.CB_DROPDOWN, pos=(300,141))

    #Bit rate
    self.formats6 = ['k/bs','128000', '160000', '180000', '192000']
    self.format_combo6=wx.ComboBox(panel, size=(47, -1),value='k/bs', choices=self.formats6, style=wx.CB_DROPDOWN, pos=(405,141))
    self.format_combo6.Disable()




def OncomboBox(self, e):
    quality=self.format_combo3.GetValue()
    if quality == '-qmax':
        self.format_combo4.Enable()

    else:
        self.format_combo4.Disable()

0 个答案:

没有答案