我们从Python开源项目中,提取了以下11个代码示例,用于说明如何使用wx.SL_HORIZONTAL。
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 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 __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, 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) 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)