Andre Polykanine
2014-09-12 17:56:03 UTC
Hello everyone,
I'm a newbie, so please bear with me :).
In a dialog box I have a combo box and a text field. I would like to
make so that if one particular value in the combo box is selected, the
text field would be disabled (or hidden), and if another value is
selected, the text field would be enabled.
I have:
self.myCombo = wx.ComboBox(parent=self, choices=['value1', 'value2'], style = wx.CB_READONLY)
self.myCombo.Bind(wx.EVT_COMBOBOX, self.onChange)
# ...
def onChange(self, ev):
self.myTextField.Enable(False) if self.myCombo.GetValue()
!= "value1" else self.myTextField.Enable(True)
And this does work like a charm, the text field gets enabled and
disabled.
However, I would like to have the text field enabled or disabled
depending on the initial value of the combo box, meaning the value
gotten from a config file and selected when the dialog box is open.
I've tried the same:
self.myTextField = wx.TextCtrl(parent=self)
self.myTextField.Enable(False) if self.myCombo.GetValue() != "value1"
else self.myTextField.Enable(True)
but this doesn't work. I've tried GetSelection also, but when logging
this, both GetValue and GetSelection return -1.
Any help would be greatly appreciated.
Thanks!
--
With best regards from Ukraine,
Andre
Skype: Francophile
Twitter: http://twitter.com/m_elensule
Facebook: http://facebook.com/menelion
I'm a newbie, so please bear with me :).
In a dialog box I have a combo box and a text field. I would like to
make so that if one particular value in the combo box is selected, the
text field would be disabled (or hidden), and if another value is
selected, the text field would be enabled.
I have:
self.myCombo = wx.ComboBox(parent=self, choices=['value1', 'value2'], style = wx.CB_READONLY)
self.myCombo.Bind(wx.EVT_COMBOBOX, self.onChange)
# ...
def onChange(self, ev):
self.myTextField.Enable(False) if self.myCombo.GetValue()
!= "value1" else self.myTextField.Enable(True)
And this does work like a charm, the text field gets enabled and
disabled.
However, I would like to have the text field enabled or disabled
depending on the initial value of the combo box, meaning the value
gotten from a config file and selected when the dialog box is open.
I've tried the same:
self.myTextField = wx.TextCtrl(parent=self)
self.myTextField.Enable(False) if self.myCombo.GetValue() != "value1"
else self.myTextField.Enable(True)
but this doesn't work. I've tried GetSelection also, but when logging
this, both GetValue and GetSelection return -1.
Any help would be greatly appreciated.
Thanks!
--
With best regards from Ukraine,
Andre
Skype: Francophile
Twitter: http://twitter.com/m_elensule
Facebook: http://facebook.com/menelion
--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to wxpython-users+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to wxpython-users+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.