我们从Python开源项目中,提取了以下19个代码示例,用于说明如何使用wx.Slider()。
def initGain(self): gainSizer = wx.BoxSizer(orient=wx.VERTICAL) gainControlBox = widgets.ControlBox(self, label='Gain', orient=wx.HORIZONTAL) self.gainText = wx.StaticText(self, label='%0.2f' % self.pg.gain) gainTextSizer = wx.BoxSizer(orient=wx.VERTICAL) gainTextSizer.Add(self.gainText, proportion=1, flag=wx.EXPAND) self.gainSlider = wx.Slider(self, style=wx.SL_HORIZONTAL, value=int(self.pg.gain*100.0), minValue=1, maxValue=100) self.Bind(wx.EVT_SLIDER, self.setGain, self.gainSlider) gainControlBox.Add(gainTextSizer, proportion=0, flag=wx.ALL | wx.EXPAND, border=10) gainControlBox.Add(self.gainSlider, proportion=1, flag=wx.ALL | wx.EXPAND, border=10) gainSizer.Add(gainControlBox, flag=wx.LEFT | wx.BOTTOM | wx.RIGHT | wx.EXPAND, border=10) self.sizer.Add(gainSizer, proportion=0, flag=wx.EXPAND)
def initControls(self): # slider for controlling the length of the spans in Welch's method # since sliders are int, we use divide by 4 to get float value spanControlBox = widgets.ControlBox(self, label='Span', orient=wx.HORIZONTAL) self.spanText = wx.StaticText(self, label='%4.2f(s)' % self.pg.welchConfig.span) spanTextSizer = wx.BoxSizer(orient=wx.VERTICAL) spanTextSizer.Add(self.spanText, proportion=1, flag=wx.LEFT | wx.RIGHT | wx.EXPAND, border=8) self.spanSlider = wx.Slider(self, style=wx.SL_HORIZONTAL, value=int(self.pg.welchConfig.span*4), minValue=1, maxValue=12) spanControlBox.Add(spanTextSizer, proportion=0, flag=wx.TOP, border=10) spanControlBox.Add(self.spanSlider, proportion=1, flag=wx.ALL | wx.EXPAND, border=10) self.Bind(wx.EVT_SLIDER, self.setSpan, self.spanSlider) self.sizer.Add(spanControlBox, proportion=0, flag=wx.LEFT | wx.BOTTOM | wx.RIGHT | wx.EXPAND, border=10)
def __init__(self,parent,slidername,**kwargs): wx.Panel.__init__(self,parent,**kwargs) sliderlabel = wx.StaticText(self,-1,label=slidername+':',size=(50,-1)) self.slidertext = wx.TextCtrl(self,-1,style=wx.TE_PROCESS_ENTER, size=(50,-1)) self.slider = JumpSlider(self) #self.slider = wx.Slider(self) spintext = wx.StaticText(self,-1,label=u"\u00B1",size=(10,-1)) self.spin = wx.SpinCtrl(self,value='0',initial=0,size=(50,-1)) hbox = wx.BoxSizer(wx.HORIZONTAL) hbox.Add(sliderlabel,0,wx.ALIGN_CENTER_VERTICAL | wx.LEFT, 10) hbox.Add(self.slidertext,0,wx.ALIGN_CENTER_VERTICAL | wx.LEFT, 10) hbox.Add(self.slider,1,wx.EXPAND,0) hbox.Add(spintext,0,wx.ALIGN_CENTER_VERTICAL | wx.LEFT, 10) hbox.Add(self.spin,0,wx.ALIGN_CENTER_VERTICAL | wx.RIGHT, 10) vbox = wx.BoxSizer(wx.VERTICAL) vbox.Add(hbox,1,wx.EXPAND,0) self.SetSizer(vbox) self.SetValue(0)
def add_slide(self, rang, title, key, unit): sizer = wx.BoxSizer( wx.HORIZONTAL ) lab_title = wx.StaticText( self, wx.ID_ANY, title, wx.DefaultPosition, wx.DefaultSize, wx.ALIGN_CENTRE ) lab_title.Wrap( -1 ) sizer.Add( lab_title, 0, wx.ALIGN_CENTER|wx.ALL, 5 ) iswin = platform.system() == 'Windows' lab = wx.SL_VALUE_LABEL if iswin else wx.SL_LABELS ctrl = wx.Slider( self, wx.ID_ANY, 50, rang[0], rang[1], wx.DefaultPosition, wx.Size( -1,-1 ), wx.SL_HORIZONTAL|lab ) self.ctrl_dic[key] = ctrl ctrl.Bind(wx.EVT_SCROLL, lambda x : self.para_changed(key)) sizer.Add( ctrl, 2, wx.ALL, 5 ) lab_unit = wx.StaticText( self, wx.ID_ANY, unit, wx.DefaultPosition, wx.DefaultSize, wx.ALIGN_CENTRE ) lab_unit.Wrap( -1 ) sizer.Add( lab_unit, 0, wx.ALIGN_CENTER|wx.ALL, 5 ) self.tus.append((lab_title, lab_unit)) self.lst.Add( sizer, 0, wx.EXPAND, 5 )
def create_slider(**kwargs): panel = kwargs.get('panel') value = kwargs.get('value') key = kwargs.get('key') bind = kwargs.get('bind') gui = kwargs.get('gui') item_sizer = wx.BoxSizer(wx.HORIZONTAL) item_name = MODULE_KEY.join(key) style = wx.SL_VALUE_LABEL | wx.SL_AUTOTICKS item_box = wx.Slider(panel, id=id_renew(item_name, update=True), minValue=gui['min'], maxValue=gui['max'], value=int(value), style=style) freq = (gui['max'] - gui['min'])/5 item_box.SetTickFreq(freq) item_box.SetLineSize(4) item_box.Bind(wx.EVT_SCROLL, bind) item_text = wx.StaticText(panel, label=translate_key(item_name)) item_sizer.Add(item_text, 0, wx.ALIGN_CENTER) item_sizer.Add(item_box, 1, wx.EXPAND) return {'item': item_sizer, 'text_size': item_text.GetSize()[0], 'text_ctrl': item_text}
def receive_messages(self, event): while True: result = self.client.receive() if not result: break for name in result: if not 'value' in result[name]: print 'no value', result raise 'no value' value = round3(result[name]['value']) strvalue = str(value) if len(strvalue) > 50: strvalue = strvalue[:47] + '...' self.values[name].SetLabel(strvalue) if name in self.controls: try: if str(type(self.controls[name])) == "<class 'wx._controls.Choice'>": if not self.controls[name].SetStringSelection(value): print 'warning, invalid choice value specified' elif str(type(self.controls[name])) == "<class 'wx._controls.Slider'>": r = self.sliderrange[name] self.controls[name].SetValue(float(value - r[0])/(r[1]-r[0])*1000) else: self.controls[name].SetValue(value) except: self.controls[name].SetValue(str(value)) size = self.GetSize() self.Fit() self.SetSize(size)
def __init__(self, parent, table, pos=(150, 680), size=(1000, 200)): wx.Panel.__init__(self, parent, pos=pos, size=size) self.parent = parent self.table = table self.size = size sizer = wx.BoxSizer(wx.HORIZONTAL) self.sndView = GuiSndViewPlayHead(self.parent, size=self.size) self.sndView.setTable(self.table) sizer.Add(self.sndView, 0, wx.EXPAND) # def createSndTable(self): # print self.parent.GetSize() # sizer = wx.BoxSizer(wx.HORIZONTAL) # jr 1 juin 2017 # self.sndview = GuiSndViewPlayHead(self.parent, size=(1000, 400)) # self.sndview.setTable(self.table) # sizer.Add(self.sndview, 0, wx.LEFT | wx.EXPAND, 155) # JR 1 juin 2017 # return sizer # def createTimeSlider(self): # sizer = wx.BoxSizer(wx.VERTICAL) # self.timeSlider = PyoGuiControlSlider(self.parent, 0, self.table.getDur(False), 0, orient=wx.HORIZONTAL) # self.timeSlider.Bind(EVT_PYO_GUI_CONTROL_SLIDER, self.moveTimeSlider) # # self.timeSlider = wx.Slider(self.parent, -1, value=0, minValue=0, maxValue=self.table.getDur(False), # # style=wx.SL_HORIZONTAL|wx.SL_LABELS) ## self.timeSlider.Bind(wx.EVT_SLIDER, self.moveTimeSlider) # sizer.Add(self.timeSlider, 0, wx.LEFT | wx.EXPAND, 155) # return sizer # def moveTimeSlider(self,e): # print self.timeSlider.value # # def setRange(self,min,max): # self.timeSlider.setRange(min,max)
def initControls(self): nFreqControlBox = widgets.ControlBox(self, label='Num Freqs', orient=wx.HORIZONTAL) self.nFreqText = wx.StaticText(self, label='%3d' % self.pg.waveletConfig.nFreq) nFreqTextSizer = wx.BoxSizer(orient=wx.VERTICAL) nFreqTextSizer.Add(self.nFreqText, proportion=1, flag=wx.LEFT | wx.RIGHT | wx.EXPAND, border=8) self.nFreqSlider = wx.Slider(self, style=wx.SL_HORIZONTAL, value=self.pg.waveletConfig.nFreq/5, minValue=1, maxValue=100) nFreqControlBox.Add(nFreqTextSizer, proportion=0, flag=wx.TOP, border=10) nFreqControlBox.Add(self.nFreqSlider, proportion=1, flag=wx.ALL | wx.EXPAND, border=10) self.Bind(wx.EVT_SLIDER, self.setNFreq, self.nFreqSlider) self.sizer.Add(nFreqControlBox, proportion=0, flag=wx.LEFT | wx.BOTTOM | wx.RIGHT | wx.EXPAND, border=10) spanControlBox = widgets.ControlBox(self, label='Span', orient=wx.HORIZONTAL) self.spanText = wx.StaticText(self, label='%3d' % self.pg.waveletConfig.span) spanTextSizer = wx.BoxSizer(orient=wx.VERTICAL) spanTextSizer.Add(self.spanText, proportion=1, flag=wx.LEFT | wx.RIGHT | wx.EXPAND, border=8) self.spanSlider = wx.Slider(self, style=wx.SL_HORIZONTAL, value=self.pg.waveletConfig.span, minValue=1, maxValue=50) spanControlBox.Add(spanTextSizer, proportion=0, flag=wx.TOP, border=10) spanControlBox.Add(self.spanSlider, proportion=1, flag=wx.ALL | wx.EXPAND, border=10) self.Bind(wx.EVT_SLIDER, self.setSpan, self.spanSlider) self.sizer.Add(spanControlBox, proportion=0, flag=wx.LEFT | wx.BOTTOM | wx.RIGHT | wx.EXPAND, border=10)
def initControls(self): orderControlBox = widgets.ControlBox(self, label='Model Order', orient=wx.HORIZONTAL) self.orderText = wx.StaticText(self, label='%3d' % self.pg.autoregConfig.order) orderTextSizer = wx.BoxSizer(orient=wx.VERTICAL) orderTextSizer.Add(self.orderText, proportion=1, flag=wx.LEFT | wx.RIGHT | wx.EXPAND, border=8) self.orderSlider = wx.Slider(self, style=wx.SL_HORIZONTAL, value=self.pg.autoregConfig.order, minValue=1, maxValue=100) orderControlBox.Add(orderTextSizer, proportion=0, flag=wx.TOP, border=10) orderControlBox.Add(self.orderSlider, proportion=1, flag=wx.ALL | wx.EXPAND, border=10) self.Bind(wx.EVT_SLIDER, self.setOrder, self.orderSlider) self.sizer.Add(orderControlBox, proportion=0, flag=wx.LEFT | wx.BOTTOM | wx.RIGHT | wx.EXPAND, border=10) nFreqControlBox = widgets.ControlBox(self, label='Num Freqs', orient=wx.HORIZONTAL) self.nFreqText = wx.StaticText(self, label='%3d' % self.pg.autoregConfig.nFreq) nFreqTextSizer = wx.BoxSizer(orient=wx.VERTICAL) nFreqTextSizer.Add(self.nFreqText, proportion=1, flag=wx.LEFT | wx.RIGHT | wx.EXPAND, border=8) self.nFreqSlider = wx.Slider(self, style=wx.SL_HORIZONTAL, value=self.pg.autoregConfig.nFreq/5, minValue=1, maxValue=100) nFreqControlBox.Add(nFreqTextSizer, proportion=0, flag=wx.TOP, border=10) nFreqControlBox.Add(self.nFreqSlider, proportion=1, flag=wx.ALL | wx.EXPAND, border=10) self.Bind(wx.EVT_SLIDER, self.setNFreq, self.nFreqSlider) self.sizer.Add(nFreqControlBox, proportion=0, flag=wx.LEFT | wx.BOTTOM | wx.RIGHT | wx.EXPAND, border=10)
def initGainLoss(self): gainLossSizer = wx.BoxSizer(orient=wx.VERTICAL) gainControlBox = widgets.ControlBox(self, label='Gain', orient=wx.HORIZONTAL) self.gainText = wx.StaticText(self, label='%0.2f' % self.pg.gain) gainTextSizer = wx.BoxSizer(orient=wx.VERTICAL) gainTextSizer.Add(self.gainText, proportion=1, flag=wx.EXPAND) self.gainSlider = wx.Slider(self, style=wx.SL_HORIZONTAL, value=int(self.pg.gain*100.0), minValue=1, maxValue=100) self.Bind(wx.EVT_SLIDER, self.setGain, self.gainSlider) gainControlBox.Add(gainTextSizer, proportion=0, flag=wx.ALL | wx.EXPAND, border=10) gainControlBox.Add(self.gainSlider, proportion=1, flag=wx.ALL | wx.EXPAND, border=10) gainLossSizer.Add(gainControlBox, flag=wx.LEFT | wx.BOTTOM | wx.RIGHT | wx.EXPAND, border=10) lossControlBox = widgets.ControlBox(self, label='Loss', orient=wx.HORIZONTAL) self.lossText = wx.StaticText(self, label='%0.2f' % self.pg.loss) lossTextSizer = wx.BoxSizer(orient=wx.VERTICAL) lossTextSizer.Add(self.lossText, proportion=1, flag=wx.EXPAND) self.lossSlider = wx.Slider(self, style=wx.SL_HORIZONTAL, value=int(self.pg.loss*100.0), minValue=1, maxValue=100) self.Bind(wx.EVT_SLIDER, self.setLoss, self.lossSlider) lossControlBox.Add(lossTextSizer, proportion=0, flag=wx.ALL | wx.EXPAND, border=10) lossControlBox.Add(self.lossSlider, proportion=1, flag=wx.ALL | wx.EXPAND, border=10) gainLossSizer.Add(lossControlBox, flag=wx.LEFT | wx.BOTTOM | wx.RIGHT | wx.EXPAND, border=10) self.sizer.Add(gainLossSizer, proportion=0, flag=wx.EXPAND)
def initSigControls(self): """Initialize signal controls. """ sigSizer = wx.BoxSizer(orient=wx.VERTICAL) distControlBox = widgets.ControlBox(self, label='Distribution', orient=wx.VERTICAL) self.distComboBox = wx.ComboBox(self, choices=list(distributions.keys()), value='uniform', style=wx.CB_SORT | wx.CB_READONLY) self.distComboBox.Bind(wx.EVT_COMBOBOX, self.setDist, self.distComboBox) distControlBox.Add(self.distComboBox, proportion=0, flag=wx.ALL, border=10) self.walkCheckBox = wx.CheckBox(self, label='Walk') self.walkCheckBox.Bind(wx.EVT_CHECKBOX, self.setWalk, self.walkCheckBox) distControlBox.Add(self.walkCheckBox, proportion=0, flag=wx.LEFT | wx.BOTTOM | wx.RIGHT, border=10) sigSizer.Add(distControlBox, proportion=0, flag=wx.ALL, border=10) scaleControlBox = widgets.ControlBox(self, label='Scale', orient=wx.HORIZONTAL) self.scaleText = wx.StaticText(self, label='%4.1f' % 1.0) scaleTextSizer = wx.BoxSizer(orient=wx.VERTICAL) scaleTextSizer.Add(self.scaleText, proportion=1, flag=wx.EXPAND) self.scaleSlider = wx.Slider(self, style=wx.SL_HORIZONTAL, value=10, minValue=1, maxValue=300) self.Bind(wx.EVT_SLIDER, self.setScale, self.scaleSlider) scaleControlBox.Add(scaleTextSizer, proportion=0, flag=wx.ALL, border=10) scaleControlBox.Add(self.scaleSlider, proportion=1, flag=wx.ALL | wx.EXPAND, border=10) sigSizer.Add(scaleControlBox, proportion=0, flag=wx.EXPAND | wx.LEFT | wx.BOTTOM | wx.RIGHT, border=10) self.sizer.Add(sigSizer)
def __init__(self, parent): super(WaveformPanel, self).__init__(parent=parent) self.parent = parent start_text = wx.StaticText(self, label="Start position (seconds)") self.start_position = wx.SpinCtrlDouble(self) stop_text = wx.StaticText(self, label="Stop position (seconds)") self.stop_position = wx.SpinCtrlDouble(self) volume_text = wx.StaticText(self, label="Playback volume") volume_slider = wx.Slider(parent=self, value=25, style=wx.SL_HORIZONTAL | wx.SL_VALUE_LABEL) ok_button = wx.Button(parent=self, id=wx.ID_OK, label="Trim") cancel_button = wx.Button(parent=self, id=wx.ID_CANCEL) top_sizer = wx.BoxSizer(wx.VERTICAL) button_sizer = wx.BoxSizer(wx.HORIZONTAL) top_sizer.Add(start_text, 0, wx.ALL ^ wx.BOTTOM, 5) top_sizer.Add(self.start_position, 0, wx.ALL, 5) top_sizer.Add(stop_text, 0, wx.ALL ^ wx.BOTTOM, 5) top_sizer.Add(self.stop_position, 0, wx.ALL, 5) top_sizer.Add(volume_text, 0, wx.ALL ^ wx.BOTTOM, 5) top_sizer.Add(volume_slider, 0, wx.ALL | wx.EXPAND, 5) top_sizer.Add(button_sizer, 0, wx.ALL | wx.EXPAND, 5) button_sizer.Add(ok_button, 0, wx.ALL, 5) button_sizer.Add(cancel_button, 0, wx.ALL, 5) self.Bind(wx.EVT_SPINCTRLDOUBLE, source=self.start_position, handler=self.on_change) self.Bind(wx.EVT_SPINCTRLDOUBLE, source=self.stop_position, handler=self.on_change) self.Bind(wx.EVT_SLIDER, source=volume_slider, handler=self.on_volume) self.SetSizerAndFit(top_sizer)
def __init__(self, parent, gap=12, *args, **kwargs): wx.Slider.__init__(self, parent, *args, **kwargs) self.gap = gap self.parent = self.GetParent() self.Bind(wx.EVT_LEFT_DOWN, self.OnClick)
def __init__(self, *args, **kwargs): wx.Slider.__init__(self, *args, **kwargs) self.SetPageSize(1) self.calculate_rect() self.Bind(wx.EVT_SLIDER, self.on_event)
def __init__(self, parent, start_time, end_time): wx.Dialog.__init__(self, parent, -1) sizer = wx.BoxSizer(wx.VERTICAL) self.SetTitle("Time Window") self.start_label = wx.StaticText(self, -1, label="...", style=wx.BOLD) self.end_label = wx.StaticText(self, -1, label="...", style=wx.BOLD) self.window_label = wx.StaticText(self, -1, "\t to \t") # self.start_label.SetFont(wx.Font(11, wx.DEFAULT, wx.BOLD, wx.NORMAL)) # self.window_label.SetFont(wx.Font(11, wx.DEFAULT, wx.ITALIC, wx.NORMAL)) # self.end_label.SetFont(wx.Font(11, wx.DEFAULT, wx.BOLD, wx.NORMAL)) self.start_label.SetFont(wx.Font(11, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_SLANT, wx.FONTWEIGHT_NORMAL)) self.window_label.SetFont(wx.Font(11, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_ITALIC, wx.FONTWEIGHT_NORMAL)) self.end_label.SetFont(wx.Font(11, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_SLANT, wx.FONTWEIGHT_NORMAL)) labelSizer = wx.BoxSizer(wx.HORIZONTAL) labelSizer.Add(self.start_label, 0, wx.ALL | wx.EXPAND, 3) labelSizer.Add(self.window_label, wx.ALL, 1) labelSizer.Add(self.end_label, 0, wx.ALL | wx.EXPAND, 3) self.btns = self.CreateSeparatedButtonSizer(wx.OK | wx.CANCEL) start_sizer = wx.BoxSizer(wx.HORIZONTAL) start_sizer.Add(wx.StaticText(self, -1, "Start: "), 0, wx.ALL, 1) self.start_slider = wx.Slider( self, -1, 0, 0, 100, wx.DefaultPosition, (250, -1), wx.SL_HORIZONTAL) start_sizer.Add(self.start_slider, 0, wx.ALL | wx.EXPAND, 5) self.Bind(wx.EVT_SLIDER, self.start_slider_update, self.start_slider) end_sizer = wx.BoxSizer(wx.HORIZONTAL) end_sizer.Add(wx.StaticText(self, -1, "End: "), 0, wx.ALL, 1) self.end_slider = wx.Slider( self, -1, 100, 0, 100, wx.DefaultPosition, (250, -1), wx.SL_HORIZONTAL) end_sizer.Add(self.end_slider, 0, wx.ALL | wx.EXPAND, 5) self.Bind(wx.EVT_SLIDER, self.end_slider_udpate, self.end_slider) self.start_time = start_time self.cur_end = end_time self.cur_start = self.start_time self.unit_seconds = (end_time - start_time).total_seconds() / 100.0 self.updateUI() sizer.Add(labelSizer, 0, wx.ALL | wx.EXPAND, 5) sizer.Add(start_sizer, 0, wx.ALL | wx.EXPAND, 5) sizer.Add(end_sizer, 0, wx.ALL | wx.EXPAND, 5) sizer.Add(self.btns, 0, wx.ALL | wx.EXPAND, 5) self.SetSizer(sizer) self.Fit()
def initSigControls(self): """Initialize signal controls. """ sigSizer = wx.BoxSizer(orient=wx.VERTICAL) waveformControlBox = widgets.ControlBox(self, label='Waveform', orient=wx.VERTICAL) self.waveformComboBox = wx.ComboBox(self, id=wx.ID_ANY, choices=list(waveforms.keys()), value='sinusoid', style=wx.CB_SORT | wx.CB_READONLY) self.waveformComboBox.Bind(wx.EVT_COMBOBOX, self.setWaveform) waveformControlBox.Add(self.waveformComboBox, proportion=0, flag=wx.ALL, border=10) sigSizer.Add(waveformControlBox, proportion=0, flag=wx.ALL | wx.EXPAND, border=10) freqControlBox = widgets.ControlBox(self, label='Base Frequency', orient=wx.HORIZONTAL) self.freqText = wx.StaticText(self, label='%4.1f(Hz)' % 1.0) freqTextSizer = wx.BoxSizer(orient=wx.VERTICAL) freqTextSizer.Add(self.freqText, proportion=1, flag=wx.EXPAND) self.freqSlider = wx.Slider(self, style=wx.SL_HORIZONTAL, value=10, minValue=1, maxValue=300) self.Bind(wx.EVT_SLIDER, self.setFreq, self.freqSlider) freqControlBox.Add(freqTextSizer, proportion=0, flag=wx.ALL, border=10) freqControlBox.Add(self.freqSlider, proportion=1, flag=wx.ALL | wx.EXPAND, border=10) sigSizer.Add(freqControlBox, proportion=0, flag=wx.LEFT | wx.BOTTOM | wx.RIGHT | wx.EXPAND, border=10) mixControlBox = widgets.ControlBox(self, label='Channel Mixer', orient=wx.HORIZONTAL) self.mixNoneButton = wx.RadioButton(self, label='None', style=wx.RB_GROUP) #mixControlBox.Add(self.mixNoneButton, proportion=0, flag=wx.TOP | wx.LEFT | wx.BOTTOM, border=10) mixControlBox.Add(self.mixNoneButton, proportion=0, flag=wx.ALL, border=10) self.mixNoneButton.SetValue(True) self.Bind(wx.EVT_RADIOBUTTON, self.setMixNone, self.mixNoneButton) #self.mixEqualButton = wx.RadioButton(self, label='Equal') #mixControlBox.Add(self.mixEqualButton, proportion=0, flag=wx.ALL, border=10) #self.Bind(wx.EVT_RADIOBUTTON, self.setMixEqual, self.mixEqualButton) self.mixRandomButton = wx.RadioButton(self, label='Random') #mixControlBox.Add(self.mixRandomButton, proportion=0, flag=wx.BOTTOM | wx.RIGHT | wx.TOP, border=10) mixControlBox.Add(self.mixRandomButton, proportion=0, flag=wx.ALL, border=10) self.Bind(wx.EVT_RADIOBUTTON, self.setMixRandom, self.mixRandomButton) sigSizer.Add(mixControlBox, proportion=0, flag=wx.LEFT | wx.BOTTOM | wx.RIGHT | wx.EXPAND, border=10) self.sizer.Add(sigSizer)
def initSigControls(self): """Initialize signal controls. """ sigSizer = wx.BoxSizer(orient=wx.VERTICAL) scaleControlBox = widgets.ControlBox(self, label='Noise Scale', orient=wx.HORIZONTAL) self.scaleText = wx.StaticText(self, label='%4.1f' % self.src.scale.value) scaleTextSizer = wx.BoxSizer(orient=wx.VERTICAL) scaleTextSizer.Add(self.scaleText, proportion=1, flag=wx.EXPAND) self.scaleSlider = wx.Slider(self, style=wx.SL_HORIZONTAL, value=self.src.scale.value*10.0, minValue=1, maxValue=300) self.Bind(wx.EVT_SLIDER, self.setScale, self.scaleSlider) scaleControlBox.Add(scaleTextSizer, proportion=0, flag=wx.ALL, border=10) scaleControlBox.Add(self.scaleSlider, proportion=1, flag=wx.ALL | wx.EXPAND, border=10) sigSizer.Add(scaleControlBox, proportion=0, flag=wx.ALL | wx.EXPAND, border=10) erpSpeedControlBox = widgets.ControlBox(self, label='ERP Speed', orient=wx.HORIZONTAL) self.erpSpeedText = wx.StaticText(self, label='%4.1f' % self.src.erpSpeed.value) erpSpeedTextSizer = wx.BoxSizer(orient=wx.VERTICAL) erpSpeedTextSizer.Add(self.erpSpeedText, proportion=1, flag=wx.EXPAND) self.erpSpeedSlider = wx.Slider(self, style=wx.SL_HORIZONTAL, value=self.src.erpSpeed.value*10.0, minValue=1, maxValue=300) self.Bind(wx.EVT_SLIDER, self.setERPSpeed, self.erpSpeedSlider) erpSpeedControlBox.Add(erpSpeedTextSizer, proportion=0, flag=wx.ALL, border=10) erpSpeedControlBox.Add(self.erpSpeedSlider, proportion=1, flag=wx.ALL | wx.EXPAND, border=10) sigSizer.Add(erpSpeedControlBox, proportion=0, flag=wx.EXPAND | wx.LEFT | wx.BOTTOM | wx.RIGHT, border=10) triggerControlBox = widgets.ControlBox(self, label='Trigger', orient=wx.HORIZONTAL) self.triggerValueTextCtrl = wx.TextCtrl(self, value=str(self.src.trigger.value))#, style=wx.TE_PROCESS_ENTER) self.Bind(wx.EVT_TEXT, self.setTrigger, self.triggerValueTextCtrl) self.triggerButton = wx.Button(self, label='Manual') self.Bind(wx.EVT_BUTTON, self.manualTrigger, self.triggerButton) triggerControlBox.Add(self.triggerValueTextCtrl, proportion=1, flag=wx.ALL | wx.EXPAND, border=10) triggerControlBox.Add(self.triggerButton, proportion=1, flag=wx.TOP | wx.RIGHT | wx.BOTTOM | wx.EXPAND, border=10) sigSizer.Add(triggerControlBox, proportion=0, flag=wx.LEFT | wx.BOTTOM | wx.RIGHT | wx.EXPAND, border=10) self.sizer.Add(sigSizer)
def initSliders(self): sliderSizer = wx.BoxSizer(wx.HORIZONTAL) lowFreqControlBox = widgets.ControlBox(self, label='lowFreq', orient=wx.VERTICAL) self.lowFreqText = wx.StaticText(self, label='%6.2f(Hz)' % self.flt.lowFreq) lowFreqTextSizer = wx.BoxSizer(orient=wx.VERTICAL) lowFreqTextSizer.Add(self.lowFreqText, proportion=0, flag=wx.ALIGN_CENTER_HORIZONTAL) self.lowFreqSlider = wx.Slider(self, style=wx.SL_VERTICAL | wx.SL_INVERSE, minValue=0, maxValue=int(self.flt.nyquist*4), value=int(self.flt.lowFreq*4)) self.Bind(wx.EVT_SLIDER, self.setLowFreq, self.lowFreqSlider) lowFreqControlBox.Add(lowFreqTextSizer, proportion=0, flag=wx.TOP | wx.BOTTOM | wx.EXPAND, border=8) lowFreqControlBox.Add(self.lowFreqSlider, proportion=1, flag=wx.LEFT | wx.RIGHT | wx.EXPAND, border=25) sliderSizer.Add(lowFreqControlBox, proportion=1, flag=wx.ALL | wx.EXPAND, border=10) highFreqControlBox = widgets.ControlBox(self, label='highFreq', orient=wx.VERTICAL) self.highFreqText = wx.StaticText(self, label='%6.2f(Hz)' % self.flt.highFreq) highFreqTextSizer = wx.BoxSizer(orient=wx.VERTICAL) highFreqTextSizer.Add(self.highFreqText, proportion=0, flag=wx.ALIGN_CENTER_HORIZONTAL) self.highFreqSlider = wx.Slider(self, style=wx.SL_VERTICAL | wx.SL_INVERSE, minValue=0, maxValue=int(self.flt.nyquist*4), value=int(self.flt.highFreq*4)) self.Bind(wx.EVT_SLIDER, self.setHighFreq, self.highFreqSlider) highFreqControlBox.Add(highFreqTextSizer, proportion=0, flag=wx.TOP | wx.BOTTOM | wx.EXPAND, border=8) highFreqControlBox.Add(self.highFreqSlider, proportion=1, flag=wx.LEFT | wx.RIGHT | wx.EXPAND, border=25) sliderSizer.Add(highFreqControlBox, proportion=1, flag=wx.ALL | wx.EXPAND, border=10) orderControlBox = widgets.ControlBox(self, label='Order', orient=wx.VERTICAL) self.orderText = wx.StaticText(self, label='%2d' % self.flt.order) orderTextSizer = wx.BoxSizer(orient=wx.VERTICAL) orderTextSizer.Add(self.orderText, proportion=0, flag=wx.ALIGN_CENTER_HORIZONTAL) self.orderSlider = wx.Slider(self, style=wx.SL_VERTICAL | wx.SL_INVERSE, minValue=1, maxValue=10, value=self.flt.order) self.Bind(wx.EVT_SLIDER, self.setOrder, self.orderSlider) orderControlBox.Add(orderTextSizer, proportion=0, flag=wx.TOP | wx.BOTTOM | wx.EXPAND, border=8) orderControlBox.Add(self.orderSlider, proportion=1, flag=wx.LEFT | wx.RIGHT | wx.EXPAND, border=25) sliderSizer.Add(orderControlBox, proportion=1, flag=wx.ALL | wx.EXPAND, border=10) self.bottomSizer.Add(sliderSizer, proportion=1, flag=wx.EXPAND)
def initSliders(self): sliderSizer = wx.BoxSizer(wx.HORIZONTAL) lowFreqControlBox = widgets.ControlBox(self, label='lowFreq', orient=wx.VERTICAL) self.lowFreqText = wx.StaticText(self, label='%6.2f(Hz)' % self.flt.lowFreq) lowFreqTextSizer = wx.BoxSizer(orient=wx.VERTICAL) lowFreqTextSizer.Add(self.lowFreqText, proportion=0, flag=wx.ALIGN_CENTER_HORIZONTAL) self.lowFreqSlider = wx.Slider(self, style=wx.SL_VERTICAL | wx.SL_INVERSE, minValue=0, maxValue=int(self.flt.nyquist*4), value=int(self.flt.lowFreq*4)) self.Bind(wx.EVT_SLIDER, self.setLowFreq, self.lowFreqSlider) lowFreqControlBox.Add(lowFreqTextSizer, proportion=0, flag=wx.TOP | wx.BOTTOM | wx.EXPAND, border=8) lowFreqControlBox.Add(self.lowFreqSlider, proportion=1, flag=wx.LEFT | wx.RIGHT | wx.EXPAND, border=25) sliderSizer.Add(lowFreqControlBox, proportion=1, flag=wx.ALL | wx.EXPAND, border=10) highFreqControlBox = widgets.ControlBox(self, label='highFreq', orient=wx.VERTICAL) self.highFreqText = wx.StaticText(self, label='%6.2f(Hz)' % self.flt.highFreq) highFreqTextSizer = wx.BoxSizer(orient=wx.VERTICAL) highFreqTextSizer.Add(self.highFreqText, proportion=0, flag=wx.ALIGN_CENTER_HORIZONTAL) self.highFreqSlider = wx.Slider(self, style=wx.SL_VERTICAL | wx.SL_INVERSE, minValue=0, maxValue=int(self.flt.nyquist*4), value=int(self.flt.highFreq*4)) self.Bind(wx.EVT_SLIDER, self.setHighFreq, self.highFreqSlider) highFreqControlBox.Add(highFreqTextSizer, proportion=0, flag=wx.TOP | wx.BOTTOM | wx.EXPAND, border=8) highFreqControlBox.Add(self.highFreqSlider, proportion=1, flag=wx.LEFT | wx.RIGHT | wx.EXPAND, border=25) sliderSizer.Add(highFreqControlBox, proportion=1, flag=wx.ALL | wx.EXPAND, border=10) orderControlBox = widgets.ControlBox(self, label='Order', orient=wx.VERTICAL) self.orderText = wx.StaticText(self, label='%2d' % self.flt.order) orderTextSizer = wx.BoxSizer(orient=wx.VERTICAL) orderTextSizer.Add(self.orderText, proportion=0, flag=wx.ALIGN_CENTER_HORIZONTAL) self.orderSlider = wx.Slider(self, style=wx.SL_VERTICAL | wx.SL_INVERSE, minValue=2, maxValue=50, value=self.flt.order // 2) self.Bind(wx.EVT_SLIDER, self.setOrder, self.orderSlider) orderControlBox.Add(orderTextSizer, proportion=0, flag=wx.TOP | wx.BOTTOM | wx.EXPAND, border=8) orderControlBox.Add(self.orderSlider, proportion=1, flag=wx.LEFT | wx.RIGHT | wx.EXPAND, border=25) sliderSizer.Add(orderControlBox, proportion=1, flag=wx.ALL | wx.EXPAND, border=10) self.bottomSizer.Add(sliderSizer, proportion=1, flag=wx.EXPAND)