0
我有一個形式的多個部件,像這樣:wxSlider更新wxTextCtrl反之亦然
self.sl_qZone1 = wx.Slider(self, -1, 50, integer=True, 0, 100, size=(sliderWidthHeight), style=wx.SL_HORIZONTAL)
self.tc_qZone1 = wx.TextCtrl(panel, -1, 50, (0,0), style=wx.TE_CENTER)
我有些事件勢必像這樣一個十幾滑塊/文本控件:
wx.FindWindowByName(mvName['sl0']).Bind(wx.EVT_SLIDER, lambda event: self.sliderUpdate(event, wx.FindWindowByName(mvName['sl0']), wx.FindWindowByName(mvName['tc0']),), wx.FindWindowByName(mvName['sl0']))
wx.FindWindowByName(mvName['tc0']).Bind(wx.EVT_CHAR, lambda event: self.tcVolUpdate(event, wx.FindWindowByName(mvName['sl0']), wx.FindWindowByName(mvName['tc0']),), wx.FindWindowByName(mvName['tc0']))
然後我有這些功能:
def sliderUpdate(self, event, slider, textctrl):
textctrl.SetValue(str(slider.GetValue()))
def tcVolUpdate(self, event, slider, textctrl):
slider.SetValue(int(textctrl.GetValue()))
它工作的很好,當我修改滑塊 - 它更新textctrl與適當的價值。但是,當我嘗試編輯textctrl時,它讓我選擇文本,但不實際編輯它。我試過wx.EVT_TEXT_ENTER
以及沒有運氣。
如何使文本ctrl可更新並讓它更新滑塊的值?