def Configure(self, zone='Active Zone', step1=0.5, step2=2.0, wait=2.0): panel = eg.ConfigPanel() zones = get_available_zones(self.plugin, True, self.plugin.AVAILABLE_ZONES) wx.StaticText(panel, label="Zone: ", pos=(10, 10)) choice_zone = wx.Choice(panel, -1, (10, 30), choices=zones) if zone in zones: choice_zone.SetStringSelection(zone) wx.StaticText(panel, label="Decrease Amount (Step 1): ", pos=(10, 60)) fs_step1 = FS.FloatSpin(panel, -1, pos=(170, 57), min_val=0.5, max_val=10, increment=0.5, value=float(step1), agwStyle=FS.FS_LEFT) wx.StaticText(panel, label="dB", pos=(270, 60)) fs_step1.SetFormat("%f") fs_step1.SetDigits(1) wx.StaticText(panel, label="Time between Step 1 to Step 2: ", pos=(10, 100)) fs_wait = FS.FloatSpin(panel, -1, pos=(170, 97), min_val=0.5, max_val=999, increment=0.1, value=float(wait), agwStyle=FS.FS_LEFT) wx.StaticText(panel, label="Seconds", pos=(270, 100)) fs_wait.SetFormat("%f") fs_wait.SetDigits(1) wx.StaticText(panel, label="Decrease Amount (Step 2): ", pos=(10, 140)) fs_step2 = FS.FloatSpin(panel, -1, pos=(170, 137), min_val=0.5, max_val=10, increment=0.5, value=float(step2), agwStyle=FS.FS_LEFT) wx.StaticText(panel, label="dB", pos=(270, 140)) fs_step2.SetFormat("%f") fs_step2.SetDigits(1) while panel.Affirmed(): panel.SetResult(zones[choice_zone.GetCurrentSelection()], fs_step1.GetValue(), fs_step2.GetValue(), fs_wait.GetValue())
def initSegWindow(self): windowSizer = wx.BoxSizer(orient=wx.HORIZONTAL) windowStartControlBox = widgets.ControlBox(self, label='Window Start', orient=wx.VERTICAL) self.windowStartFloatSpin = agwfs.FloatSpin(self, min_val=0.0, max_val=0.25, increment=1/40.0, value=self.pg.windowStart) self.windowStartFloatSpin.SetFormat("%f") self.windowStartFloatSpin.SetDigits(3) self.Bind(agwfs.EVT_FLOATSPIN, self.setWindowStart, self.windowStartFloatSpin) self.offlineControls += [self.windowStartFloatSpin] windowStartControlBox.Add(self.windowStartFloatSpin, proportion=1, flag=wx.ALL | wx.EXPAND, border=10) windowSizer.Add(windowStartControlBox, proportion=1, flag=wx.RIGHT | wx.BOTTOM | wx.LEFT | wx.EXPAND, border=10) windowEndControlBox = widgets.ControlBox(self, label='Window End', orient=wx.VERTICAL) self.windowEndFloatSpin = agwfs.FloatSpin(self, min_val=0.3, max_val=1.5, increment=1/20.0, value=self.pg.windowEnd) self.windowEndFloatSpin.SetFormat("%f") self.windowEndFloatSpin.SetDigits(3) self.Bind(agwfs.EVT_FLOATSPIN, self.setWindowEnd, self.windowEndFloatSpin) self.offlineControls += [self.windowEndFloatSpin] windowEndControlBox.Add(self.windowEndFloatSpin, proportion=1, flag=wx.ALL | wx.EXPAND, border=10) windowSizer.Add(windowEndControlBox, proportion=1, flag=wx.RIGHT | wx.BOTTOM | wx.EXPAND, border=10) self.sizer.Add(windowSizer, proportion=0, flag=wx.EXPAND)
def add_goniometer_controls(self, goniometer): from wx.lib.agw import floatspin self.distance_ctrl = floatspin.FloatSpin(parent=self, increment=1, digits=2) self.distance_ctrl.SetValue(self.settings.detector_distance) self.distance_ctrl.Bind(wx.EVT_SET_FOCUS, lambda evt: None) if wx.VERSION >= (2,9): # XXX FloatSpin bug in 2.9.2/wxOSX_Cocoa self.distance_ctrl.SetBackgroundColour(self.GetBackgroundColour()) box = wx.BoxSizer(wx.HORIZONTAL) self.panel_sizer.Add(box) label = wx.StaticText(self,-1,"Detector distance") box.Add(self.distance_ctrl, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5) box.Add(label, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5) self.Bind(floatspin.EVT_FLOATSPIN, self.OnChangeSettings, self.distance_ctrl) self.rotation_angle_ctrls = [] if isinstance(goniometer, MultiAxisGoniometer): names = goniometer.get_names() axes = goniometer.get_axes() angles = goniometer.get_angles() for name, axis, angle in zip(names, axes, angles): ctrl = floatspin.FloatSpin(parent=self, increment=1, digits=3) ctrl.SetValue(angle) ctrl.Bind(wx.EVT_SET_FOCUS, lambda evt: None) if wx.VERSION >= (2,9): # XXX FloatSpin bug in 2.9.2/wxOSX_Cocoa ctrl.SetBackgroundColour(self.GetBackgroundColour()) box = wx.BoxSizer(wx.HORIZONTAL) self.panel_sizer.Add(box) label = wx.StaticText(self,-1,"%s angle" %name) box.Add(ctrl, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5) box.Add(label, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5) self.Bind(floatspin.EVT_FLOATSPIN, self.OnChangeSettings, ctrl) self.rotation_angle_ctrls.append(ctrl)
def initIntervals(self): intervalSizer = wx.BoxSizer(orient=wx.HORIZONTAL) siControlBox = widgets.ControlBox(self, label='Stim Secs', orient=wx.VERTICAL) self.siFloatSpin = agwfs.FloatSpin(self, min_val=0.025, max_val=0.5, increment=1/40.0, value=self.pg.si) self.siFloatSpin.SetFormat("%f") self.siFloatSpin.SetDigits(3) self.Bind(agwfs.EVT_FLOATSPIN, self.setSI, self.siFloatSpin) self.offlineControls += [self.siFloatSpin] siControlBox.Add(self.siFloatSpin, proportion=1, flag=wx.ALL | wx.EXPAND, border=10) intervalSizer.Add(siControlBox, proportion=1, flag=wx.RIGHT | wx.BOTTOM | wx.LEFT | wx.EXPAND, border=10) isiControlBox = widgets.ControlBox(self, label='Inter-Stim Secs', orient=wx.VERTICAL) self.isiFloatSpin = agwfs.FloatSpin(self, min_val=0.05, max_val=1.0, increment=1/20.0, value=self.pg.isi) self.isiFloatSpin.SetFormat("%f") self.isiFloatSpin.SetDigits(3) self.Bind(agwfs.EVT_FLOATSPIN, self.setISI, self.isiFloatSpin) self.offlineControls += [self.isiFloatSpin] isiControlBox.Add(self.isiFloatSpin, proportion=1, flag=wx.ALL | wx.EXPAND, border=10) intervalSizer.Add(isiControlBox, proportion=1, flag=wx.RIGHT | wx.BOTTOM | wx.EXPAND, border=10) self.sizer.Add(intervalSizer, proportion=0, flag=wx.EXPAND)
def _build_widgets(self): sb = wx.StaticBox(self, -1, _('Options')) self.angle = floatspin.FloatSpin(self, -1, value=0.7, min_val=0.0, max_val=1.0, increment=0.1, digits=1) self.max_distance = floatspin.FloatSpin(self, -1, value=3.0, min_val=0.0, max_val=100.0, increment=0.1, digits=2) self.min_weight = floatspin.FloatSpin(self, -1, value=0.2, min_val=0.0, max_val=1.0, increment=0.1, digits=1) self.steps = wx.SpinCtrl(self, -1, value='10', min=1, max=100) layout_sizer = wx.FlexGridSizer(rows=4, cols=2, hgap=5, vgap=5) layout_sizer.Add(wx.StaticText(self, -1, _(u'Angle:')), 0, wx.EXPAND) layout_sizer.Add(self.angle, 0, wx.EXPAND) layout_sizer.Add(wx.StaticText(self, -1, _(u'Max. distance:')), 0, wx.EXPAND) layout_sizer.Add(self.max_distance, 0, wx.EXPAND) layout_sizer.Add(wx.StaticText(self, -1, _(u'Min. weight:')), 0, wx.EXPAND) layout_sizer.Add(self.min_weight, 0, wx.EXPAND) layout_sizer.Add(wx.StaticText(self, -1, _(u'N. steps:')), 0, wx.EXPAND) layout_sizer.Add(self.steps, 0, wx.EXPAND) self.main_sizer = wx.StaticBoxSizer(sb, wx.VERTICAL) self.main_sizer.Add(layout_sizer, 0, wx.EXPAND | wx.ALL, 5) self.SetSizer(self.main_sizer)
def __init__(self, parent, ID, pval, ival, dval, serial_obj): wx.Panel.__init__(self, parent, ID) self.ser = serial_obj self.p = pval self.i = ival self.d = dval box = wx.StaticBox(self, -1, 'PID Tunings') sizer = wx.StaticBoxSizer(box, wx.VERTICAL) self.p_text = FS.FloatSpin(self, -1, size=(70, -1), value=str(pval), style=wx.TE_PROCESS_ENTER, min_val=-100, max_val=100, increment=0.1, digits=2, name='Kp') self.i_text = FS.FloatSpin(self, -1, size=(70, -1), value=str(ival), style=wx.TE_PROCESS_ENTER, min_val=-100, max_val=100, increment=0.1, digits=2, name='Ki') self.d_text = FS.FloatSpin(self, -1, size=(70, -1), value=str(dval), style=wx.TE_PROCESS_ENTER, min_val=-100, max_val=100, increment=0.1, digits=2, name='Kd') #self.Bind(wx.EVT_UPDATE_UI, self.on_update_manual_text, self.manual_text) self.Bind(wx.EVT_TEXT_ENTER, self.on_p_text_enter, self.p_text) self.Bind(wx.EVT_SPINCTRL, self.on_p_text_enter, self.p_text) self.Bind(wx.EVT_TEXT_ENTER, self.on_i_text_enter, self.i_text) self.Bind(wx.EVT_SPINCTRL, self.on_i_text_enter, self.i_text) self.Bind(wx.EVT_TEXT_ENTER, self.on_d_text_enter, self.d_text) self.Bind(wx.EVT_SPINCTRL, self.on_d_text_enter, self.d_text) manual_box = wx.BoxSizer(wx.HORIZONTAL) manual_box.Add(self.p_text, flag=wx.ALIGN_CENTER_VERTICAL) manual_box.Add(self.i_text, flag=wx.ALIGN_CENTER_VERTICAL) manual_box.Add(self.d_text, flag=wx.ALIGN_CENTER_VERTICAL) sizer.Add(manual_box, 0, wx.ALL, 10) self.SetSizer(sizer) sizer.Fit(self)
def __init__(self, parent, x, y): ''' ''' wx.Dialog.__init__(self, parent, size=wx.Size(140,120)) wx.StaticText(self, -1, "x", wx.Point(10,10)) wx.StaticText(self, -1, "y", wx.Point(10,35)) self.x = FS.FloatSpin(self, -1, pos= wx.Point(25,10), min_val=-100, max_val=100, increment=0.01, value=x, agwStyle=FS.FS_LEFT) self.y = FS.FloatSpin(self, -1, pos= wx.Point(25,35), min_val=-100, max_val=100, increment=0.01, value=y, agwStyle=FS.FS_LEFT) wx.Button(self, wx.ID_OK, "Ok", wx.Point(10,60), wx.Size(110,23))
def __init__(self, parent, id, title, type, modul, configparser): self.parent = parent self.visible = modul.visibl self.desc = modul.descript self.addr = modul.addr self.title = title self.type = type self.modul = modul self.configparser = configparser wx.Dialog.__init__(self, parent, id, title, size=(320, 200)) panel = wx.Panel(self, -1) self.lb_addr = wx.StaticText(panel, -1, "Address:", (20, 20)) self.sp_h0 = agw.FloatSpin(panel, -1, pos=(100, 15), size=(60, -1), min_val=0, max_val=999, agwStyle=agw.FS_RIGHT, increment=1, digits=0) self.sp_h1 = agw.FloatSpin(panel, -1, pos=(170, 15), size=(60, -1), min_val=0, max_val=999, agwStyle=agw.FS_RIGHT, increment=1, digits=0) self.sp_h2 = agw.FloatSpin(panel, -1, pos=(240, 15), size=(60, -1), min_val=0, max_val=999, agwStyle=agw.FS_RIGHT, increment=1, digits=0) self.lb_desc = wx.StaticText(panel, -1, "Description:", (20, 70)) self.tx_desc = wx.TextCtrl(panel, -1, pos=(100, 70), size=(200, 20)) self.bt_ok = wx.Button(panel, wx.ID_OK, "", pos=(100, 130)) self.bt_cancel = wx.Button(panel, wx.ID_CANCEL, "", pos=(190, 130)) self.cb_visibl = wx.CheckBox(panel, -1, "Visible:", pos=(20, 130)) self.__set_properties() self.__attach_events() self.Centre()
def InitUI(self): panel = wx.Panel(self) wx.StaticText( panel, label="Enter a new detector angle and " "distance.\nAngles are measured in degrees " "anti-\nclockwise from the positive z axis, and " "\ndistances in milimetres from the sample.", pos=(20, 20), ) wx.StaticText(panel, label="New angle: ", pos=(20, 100)) wx.StaticText(panel, label="New distance: ", pos=(20, 150)) # angles widget self.angles = fs.FloatSpin( panel, -1, pos=(150, 95), min_val=-90.0, max_val=90.0, increment=0.5, value=round(DET_ANGLE, 1), agwStyle=fs.FS_LEFT, ) self.angles.SetFormat("%f") self.angles.SetDigits(1) # distance widget self.dist = fs.FloatSpin( panel, -1, pos=(150, 145), min_val=20.0, max_val=500.0, increment=1.0, value=round(d, 1), agwStyle=fs.FS_LEFT, ) self.dist.SetFormat("%f") self.dist.SetDigits(1) # detector texture toggle self.detcheck = wx.CheckBox(panel, -1, "Enable detector texture", (40, 200)) self.detcheck.SetValue((not blanksetting)) # obtn = wx.Button(panel, label='&Ok', pos=(30, 230)) rbtn = wx.Button(panel, label="&Adjust", pos=(70, 230)) rbtn.SetFocus() cbtn = wx.Button(panel, wx.ID_CLOSE, label="&Close", pos=(185, 230)) # obtn.Bind(wx.EVT_BUTTON, self.OnOk) rbtn.Bind(wx.EVT_BUTTON, self.OnAdjust) cbtn.Bind(wx.EVT_BUTTON, self.OnClose)
def initFreqs(self): lowHighFreqSizer = wx.BoxSizer(orient=wx.HORIZONTAL) lowFreqControlBox = widgets.ControlBox(self, label='Low Freq', orient=wx.VERTICAL) self.lowFreqFloatSpin = agwfs.FloatSpin( self, min_val=0.25, max_val=100.0, increment=1 / 4.0, value=self.pg.welchConfig.lowFreq) self.lowFreqFloatSpin.SetFormat('%f') self.lowFreqFloatSpin.SetDigits(4) self.Bind(agwfs.EVT_FLOATSPIN, self.setLowFreq, self.lowFreqFloatSpin) self.cp.offlineControls += [self.lowFreqFloatSpin] lowFreqControlBox.Add(self.lowFreqFloatSpin, proportion=1, flag=wx.ALL | wx.EXPAND, border=10) lowHighFreqSizer.Add(lowFreqControlBox, proportion=1, flag=wx.LEFT | wx.BOTTOM | wx.RIGHT | wx.EXPAND, border=10) highFreqControlBox = widgets.ControlBox(self, label='High Freq', orient=wx.VERTICAL) self.highFreqFloatSpin = agwfs.FloatSpin( self, min_val=0.25, max_val=100.0, increment=1 / 4.0, value=self.pg.welchConfig.highFreq) self.highFreqFloatSpin.SetFormat('%f') self.highFreqFloatSpin.SetDigits(4) self.Bind(agwfs.EVT_FLOATSPIN, self.setHighFreq, self.highFreqFloatSpin) self.cp.offlineControls += [self.highFreqFloatSpin] highFreqControlBox.Add(self.highFreqFloatSpin, proportion=1, flag=wx.ALL | wx.EXPAND, border=10) lowHighFreqSizer.Add(highFreqControlBox, proportion=1, flag=wx.BOTTOM | wx.RIGHT | wx.EXPAND, border=10) self.sizer.Add(lowHighFreqSizer, proportion=0, flag=wx.EXPAND)
def initTrialSecs(self): secsSizer = wx.BoxSizer(orient=wx.HORIZONTAL) trainTrialSecsControlBox = widgets.ControlBox(self, label='Train Trial Secs', orient=wx.VERTICAL) self.trainTrialSecsFloatSpin = agwfs.FloatSpin( self, min_val=2.00, max_val=60.0, increment=1 / 4.0, value=self.pg.trainTrialSecs) self.trainTrialSecsFloatSpin.SetFormat('%f') self.trainTrialSecsFloatSpin.SetDigits(3) self.Bind(agwfs.EVT_FLOATSPIN, self.setTrialSecs, self.trainTrialSecsFloatSpin) self.offlineControls += [self.trainTrialSecsFloatSpin] trainTrialSecsControlBox.Add(self.trainTrialSecsFloatSpin, proportion=1, flag=wx.ALL | wx.EXPAND, border=10) secsSizer.Add(trainTrialSecsControlBox, proportion=1, flag=wx.LEFT | wx.BOTTOM | wx.RIGHT | wx.EXPAND, border=10) pauseSecsControlBox = widgets.ControlBox(self, label='Pause Secs', orient=wx.VERTICAL) self.pauseSecsFloatSpin = agwfs.FloatSpin(self, min_val=0.25, max_val=10.0, increment=1 / 4.0, value=self.pg.pauseSecs) self.pauseSecsFloatSpin.SetFormat('%f') self.pauseSecsFloatSpin.SetDigits(3) self.Bind(agwfs.EVT_FLOATSPIN, self.setPauseSecs, self.pauseSecsFloatSpin) self.offlineControls += [self.pauseSecsFloatSpin] pauseSecsControlBox.Add(self.pauseSecsFloatSpin, proportion=1, flag=wx.ALL | wx.EXPAND, border=10) secsSizer.Add(pauseSecsControlBox, proportion=1, flag=wx.BOTTOM | wx.RIGHT | wx.EXPAND, border=10) self.sizer.Add(secsSizer, proportion=0, flag=wx.EXPAND)
def initTiming(self): timingSizer = wx.BoxSizer(orient=wx.HORIZONTAL) widthControlBox = widgets.ControlBox(self, label='Width Secs', orient=wx.VERTICAL) self.widthFloatSpin = agwfs.FloatSpin(self, min_val=0.2, max_val=5.0, increment=0.05, value=self.pg.width) self.widthFloatSpin.SetFormat('%f') self.widthFloatSpin.SetDigits(3) self.Bind(agwfs.EVT_FLOATSPIN, self.setWidth, self.widthFloatSpin) self.offlineControls += [self.widthFloatSpin] widthControlBox.Add(self.widthFloatSpin, proportion=1, flag=wx.ALL | wx.EXPAND, border=10) timingSizer.Add(widthControlBox, proportion=1, flag=wx.LEFT | wx.BOTTOM | wx.RIGHT | wx.EXPAND, border=10) decisionSecsControlBox = widgets.ControlBox(self, label='Decision Secs', orient=wx.VERTICAL) self.decisionSecsFloatSpin = agwfs.FloatSpin( self, min_val=0.025, max_val=5.0, increment=0.025, value=self.pg.decisionSecs) self.decisionSecsFloatSpin.SetFormat('%f') self.decisionSecsFloatSpin.SetDigits(4) self.Bind(agwfs.EVT_FLOATSPIN, self.setDecisionSecs, self.decisionSecsFloatSpin) self.offlineControls += [self.decisionSecsFloatSpin] decisionSecsControlBox.Add(self.decisionSecsFloatSpin, proportion=1, flag=wx.ALL | wx.EXPAND, border=10) timingSizer.Add(decisionSecsControlBox, proportion=1, flag=wx.BOTTOM | wx.RIGHT | wx.EXPAND, border=10) self.sizer.Add(timingSizer, proportion=0, flag=wx.EXPAND)
def initTiming(self): timingSizer = wx.BoxSizer(orient=wx.HORIZONTAL) widthControlBox = widgets.ControlBox(self, label='Train Width', orient=wx.VERTICAL) self.widthFloatSpin = agwfs.FloatSpin(self, min_val=0.5, max_val=60.0, increment=0.25, value=self.pg.width) self.widthFloatSpin.SetFormat('%f') self.widthFloatSpin.SetDigits(3) self.Bind(agwfs.EVT_FLOATSPIN, self.setWidth, self.widthFloatSpin) self.offlineControls += [self.widthFloatSpin] widthControlBox.Add(self.widthFloatSpin, proportion=1, flag=wx.ALL | wx.EXPAND, border=10) timingSizer.Add(widthControlBox, proportion=1, flag=wx.ALL | wx.EXPAND, border=10) retrainDelayControlBox = widgets.ControlBox(self, label='Retrain Delay', orient=wx.VERTICAL) self.retrainDelayFloatSpin = agwfs.FloatSpin( self, min_val=2.0, max_val=60.0, increment=0.25, value=self.pg.retrainDelay) self.retrainDelayFloatSpin.SetFormat('%f') self.retrainDelayFloatSpin.SetDigits(4) self.Bind(agwfs.EVT_FLOATSPIN, self.setRetrainDelay, self.retrainDelayFloatSpin) self.offlineControls += [self.retrainDelayFloatSpin] retrainDelayControlBox.Add(self.retrainDelayFloatSpin, proportion=1, flag=wx.ALL | wx.EXPAND, border=10) timingSizer.Add(retrainDelayControlBox, proportion=1, flag=wx.BOTTOM | wx.RIGHT | wx.TOP | wx.EXPAND, border=10) self.sizer.Add(timingSizer, proportion=0, flag=wx.EXPAND)
def __init__(self, parent, *args): """Initialize""" FilterGui.__init__(self, parent, *args) self.trace = wx.TextCtrl(self, wx.ID_ANY) self._add_field("Trace to Filter", self.trace, small=True) self.thresh = FS.FloatSpin(self, wx.ID_ANY, min_val=0, max_val=100, increment=0.1, value=0, agwStyle=FS.FS_RIGHT) self.thresh.SetDigits(1) self._add_field("Cutoff (%)", self.thresh, small=True) self.keep_below = wx.CheckBox(self, wx.ID_ANY) self._add_field("Keep samples below threshold?", self.keep_below, small=True) self.SetSizer(self.sizer) self.sizer.SetSizeHints(self) # Initialize events self.thresh.Bind(FS.EVT_FLOATSPIN, self.onchange_thresh) self.trace.Bind(wx.EVT_TEXT, self.onchange_trace) self.keep_below.Bind(wx.EVT_CHECKBOX, self.oncheck_kb) self.draw()
def test_lib_agw_floatspinMethods(self): floatspin = FS.FloatSpin(self.frame, min_val=0, max_val=1, increment=0.01, value=0.1, agwStyle=FS.FS_LEFT) floatspin.SetFormat('%f') floatspin.SetDigits(2) # Some methods tests... self.assertTrue(floatspin.GetFormat() == '%f') self.assertEqual(floatspin.GetDigits(), 2) # Should not be possible to set 100... floatspin.SetValue(100.0) self.assertTrue(floatspin.GetValue() == 0.1) floatspin.SetValue(0.2) floatspin.SetToDefaultValue() self.assertTrue(floatspin.GetValue() == 0.1) self.assertTrue(floatspin.IsFinite(floatspin.GetValue())) self.assertTrue(not floatspin.InRange(50)) self.assertTrue(floatspin.HasRange()) self.assertEqual(floatspin.GetMin(), 0) self.assertEqual(floatspin.GetMax(), 1) self.assertEqual(floatspin.GetIncrement(), FS.FixedPoint(str(0.01), 20))
def Configure(self, freq="87.5", band="FM"): panel = eg.ConfigPanel() self.freq = freq self.bands = ['AM', 'FM'] wx.StaticText(panel, label="Band: ", pos=(10, 10)) self.choice_band = wx.Choice(panel, -1, (10, 30), choices=self.bands) if band in self.bands: self.choice_band.SetStringSelection(band) self.choice_band.Bind(wx.EVT_CHOICE, self.BandChanged) wx.StaticText(panel, label="Frequency: ", pos=(10, 60)) self.floatspin = FS.FloatSpin(panel, -1, pos=(10, 80), min_val=87.5, max_val=107.9, increment=0.2, value=float(freq), agwStyle=FS.FS_LEFT) self.floatspin.SetFormat("%f") self.floatspin.SetDigits(1) #self.objects = [ 'Power', 'Sleep', 'Volume Level', 'Mute', 'Input Selection', 'Scene', 'Straight', 'Enhancer', 'Sound Program'] #wx.StaticText(panel, label="Object: ", pos=(10, 60)) #self.choice_object = wx.Choice(panel, -1, (10, 80), choices=self.objects) self.BandChanged() #if object in self.objects: # self.choice_object.SetStringSelection(object) while panel.Affirmed(): panel.SetResult(self.floatspin.GetValue(), self.bands[self.choice_band.GetCurrentSelection()])
def create_widgets(self): img = wx.Image(self.max_size, self.max_size) self.image_ctrl = wx.StaticBitmap(self, bitmap=wx.Bitmap(img)) self.main_sizer.Add(self.image_ctrl, 0, wx.ALL, 5) browse_btn = wx.Button(self, label="Browse") browse_btn.Bind(wx.EVT_BUTTON, self.on_browse) self.photo_txt = wx.TextCtrl(self, size=(200, -1)) self.add_row_of_widgets([browse_btn, self.photo_txt]) effects_label = wx.StaticText(self, label="Enhancements") selections = ["Brightness", "Color", "Contrast", "Sharpness", "Normal"] self.effects_combo = wx.ComboBox(self, choices=selections, value=selections[-1]) self.effects_combo.Bind(wx.EVT_COMBOBOX, self.on_effect) self.enhancement_factor = FS.FloatSpin(self, wx.ID_ANY, min_val=0, max_val=5, increment=0.1, agwStyle=FS.FS_RIGHT) self.enhancement_factor.SetDigits(digits=1) self.enhancement_factor.SetValue(2.0) self.add_row_of_widgets( [effects_label, self.effects_combo, self.enhancement_factor]) save_btn = wx.Button(self, label="Save") save_btn.Bind(wx.EVT_BUTTON, self.on_save) self.main_sizer.Add(save_btn, 0, wx.ALL | wx.CENTER, 5)
def DoCreateResource(self): try: min_val = float(self.GetText('min_val')) except: min_val = None try: max_val = float(self.GetText('max_val')) except: max_val = None try: increment = float(self.GetText('increment')) except: increment = 1.0 w = floatspin.FloatSpin(parent=self.GetParentAsWindow(), id=self.GetID(), pos=self.GetPosition(), size=self.GetSize(), style=self.GetStyle(), min_val=min_val, max_val=max_val, increment=increment, name=self.GetName()) try: w.SetValue(float(self.GetText('value'))) except: w.SetValue(0.0) try: w.SetDigits(int(self.GetText('digits'))) except: pass self.SetupWindow(w) return w
def __init__(self, parent, id, title): wx.Frame.__init__( self, parent, id, title, wx.DefaultPosition, (300, 150)) self.panel = wx.Panel(self, -1) vbox = wx.BoxSizer(wx.VERTICAL) hbox = wx.BoxSizer(wx.HORIZONTAL) self.floatspin = FS.FloatSpin( self.panel, -1, pos=(50, 50), min_val=0, max_val=10, increment=0.1, value=5, agwStyle=FS.FS_CENTRE) self.floatspin.SetFormat("%f") self.floatspin.SetDigits(2) btn1 = wx.Button(self.panel, 8, 'Adjust') btn2 = wx.Button(self.panel, 9, 'Close') self.Bind(wx.EVT_CLOSE, self.OnClose) btn1.Bind(wx.EVT_BUTTON, self.on_adjust) btn2.Bind(wx.EVT_BUTTON, self.OnClose) vbox.Add(self.floatspin, 1, wx.ALIGN_CENTRE | wx.ALL, 10) hbox.Add(btn1, 1, wx.RIGHT, 10) hbox.Add(btn2, 1) vbox.Add(hbox, 0, wx.ALIGN_CENTRE | wx.ALL, 10) self.panel.SetSizer(vbox) self.initialize_daq()
def create_parameter_control(self, parent): panel = StaticBox(parent, label="Algorithm parameters") epsilon_label = wx.StaticText(panel, label="ε", style=wx.ALIGN_RIGHT) self.epsilon = fs.FloatSpin(panel, agwStyle=fs.FS_RIGHT, min_val=0.001, max_val=1, value=self.model.epsilon, increment=0.01, digits=3, size=self.spinctrl_size) sensitivity_label = wx.StaticText(panel, label="Δ", style=wx.ALIGN_RIGHT) self.sensitivity = wx.SpinCtrl(panel, style=wx.TE_PROCESS_ENTER | wx.ALIGN_RIGHT, size=self.spinctrl_size, min=0, max=100, initial=self.model.sensitivity) monotonic_label = wx.StaticText(panel, label="Monotonic", style=wx.ALIGN_RIGHT) self.monotonic = wx.CheckBox(panel) self.monotonic.SetValue(self.model.monotonic) offset_label = wx.StaticText(panel, label="offset", style=wx.ALIGN_RIGHT) self.offset = wx.SpinCtrl(panel, style=wx.TE_PROCESS_ENTER | wx.ALIGN_RIGHT, size=self.spinctrl_size, min=0, max=100, initial=self.model.sensitivity) grid = [ [epsilon_label, self.epsilon], [sensitivity_label, self.sensitivity], [monotonic_label, self.monotonic], [offset_label, self.offset], ] sizer = wx.FlexGridSizer(rows=len(grid), cols=len(grid[0]), gap=(5, 5)) for line in grid: for item in line: sizer.Add(item, flag=wx.EXPAND) self.Bind(fs.EVT_FLOATSPIN, self.on_epsilon, self.epsilon) self.Bind(wx.EVT_SPINCTRL, self.on_sensitivity, self.sensitivity) self.Bind(wx.EVT_TEXT_ENTER, on_spin_enter, self.sensitivity) self.Bind(wx.EVT_CHECKBOX, self.on_monotonic, self.monotonic) self.Bind(wx.EVT_SPINCTRL, self.on_offset, self.offset) panel.SetSizer(sizer) return panel
def FloatSpin(parent, value=0, action=None, tooltip=None, size=(100, -1), digits=1, increment=1, **kws): """FloatSpin with action and tooltip""" if value is None: value = 0 fs = fspin.FloatSpin(parent, -1, size=size, value=value, digits=digits, increment=increment, **kws) if action is not None: fs.Bind(fspin.EVT_FLOATSPIN, action) if tooltip is not None: if is_wxPhoenix: fs.SetToolTip(tooltip) else: fs.SetToolTipString(tooltip) return fs
def __init__(self, parent, label='', label_size=(200, -1), label_style='normal', ctrl_size=(60, -1), ctrl_value='3', ctrl_max=999999, ctrl_min=0, ctrl_step=1, ctrl_digits=0): CtrlBase.__init__(self, parent=parent, label_style=label_style) self.value = ctrl_value ctr_box = wx.FlexGridSizer(1, 3, 0, 10) self.txt = wx.StaticText(self, label=label.decode('utf-8'), size=label_size) self.txt.SetFont(self.font) self.ctr = fs.FloatSpin(self, value=ctrl_value, max_val=(ctrl_max), min_val=(ctrl_min), increment=ctrl_step, digits=ctrl_digits, size=ctrl_size) ctr_box.Add(self.txt, flag=wx.ALIGN_CENTER_VERTICAL) ctr_box.Add(self.ctr, flag=wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT | wx.EXPAND) self.SetSizer(ctr_box)
def Configure(self, sources=None): panel = eg.ConfigPanel() if sources == None: sources = get_system_io_vol_trim(self.plugin) y = 10 x_start = 10 x = x_start num_per_row = 3 x_padding = 110 y_padding = 45 self.fss = [] for i in range(len(sources)): print sources[i][0] if i > 0 and i % num_per_row == 0: x = x_start y += y_padding wx.StaticText(panel, label=sources[i][0], pos=(x, y)) fs = FS.FloatSpin(panel, -1, min_val=-6.0, max_val=6.0, increment=0.5, pos=(x, y+15), value=float(sources[i][1]/10), agwStyle=FS.FS_LEFT) fs.SetFormat("%f") fs.SetDigits(1) self.fss.append(fs) x += x_padding while panel.Affirmed(): res = [] for i in range(len(self.fss)): res.append([sources[i][0], int(self.fss[i].GetValue()*10)]) panel.SetResult(res)
def __init__(self, parent, *args): """Initialize""" FilterGui.__init__(self, parent, *args) thresh_sel = wx.BoxSizer(wx.HORIZONTAL) txt = wx.StaticText(self, wx.ID_ANY, "Cutoff (%)") self.thresh = FS.FloatSpin(self, wx.ID_ANY, min_val=0, max_val=100, increment=0.1, value=self.filt.threshold, agwStyle=FS.FS_RIGHT) self.thresh.SetDigits(1) thresh_sel.Add(txt, 1, wx.ALIGN_CENTER) thresh_sel.Add(self.thresh, 0) szr_flags = wx.EXPAND | wx.BOTTOM | wx.LEFT | wx.RIGHT self.sizer.Add(thresh_sel, 1, szr_flags, 5) self.SetSizer(self.sizer) self.sizer.SetSizeHints(self) # Initialize events self.thresh.Bind(FS.EVT_FLOATSPIN, self.onchange_thresh)
def test_lib_agw_floatspinCtor(self): floatspin = FS.FloatSpin(self.frame, min_val=0, max_val=1, increment=0.01, value=0.1, agwStyle=FS.FS_LEFT) floatspin.SetFormat('%f') floatspin.SetDigits(2)
def __init__(self, parent): wx.Panel.__init__(self, parent) #-------------------------------------------------------------------------- box = wx.StaticBox(self, -1, 'Upgrades') bsizer = wx.StaticBoxSizer(box, wx.VERTICAL) example = wx.StaticText( self, label=(u'\n'.join([ u'"Category Upgrade Progression" is the sequence of Category upgrades, lowest to highest.', u'"Factor" is the fraction of previous points than can be carried forward from the current category', u'to the Upgrade category.', u'', u'For example:', u'Category Upgrade Progression: Beginner (Men), Novice (Men), Intermediate (Men), Expert (Men)', u'Factor: 0.5', u'', u'This would specify that if a rider is upgraded from Beginner to Novice (or Novice to Intermediate,', u'or Intermediate to Expert), 0.5 of the total points earned in the previous category carry forward', u'to the new category.', u'', u'Upgrades only apply when the Scoring Criteria is by Points. They have no effect on other scoring systems.', u'', ]))) fgs = wx.FlexGridSizer(rows=0, cols=3, vgap=4, hgap=2) fgs.AddGrowableCol(1, proportion=1) fgs.Add(wx.StaticText(self, label='')) fgs.Add( wx.StaticText(self, label=u'{}:'.format('Category Upgrade Progression'))) fgs.Add(wx.StaticText(self, label=u'{}:'.format('Factor'))) self.upgradePaths, self.upgradeFactors = [], [] for i in xrange(8): self.upgradePaths.append(wx.TextCtrl(self)) self.upgradeFactors.append( FS.FloatSpin(self, min_val=0.0, max_val=1.0, increment=0.01, value=0.5, agwStyle=FS.FS_RIGHT)) self.upgradeFactors[-1].SetFormat('%f') self.upgradeFactors[-1].SetDigits(2) fgs.Add(wx.StaticText(self, label=u'{}.'.format(i + 1)), flag=wx.ALIGN_RIGHT | wx.ALIGN_CENTRE_VERTICAL) fgs.Add(self.upgradePaths[-1], 1, flag=wx.EXPAND) fgs.Add(self.upgradeFactors[-1], 0) bsizer.Add(example, flag=wx.ALL, border=8) bsizer.Add(fgs, 1, flag=wx.EXPAND) sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add(bsizer, 0, flag=wx.EXPAND | wx.ALL, border=4) self.SetSizer(sizer)
def __init__(self, *args, **kwds): # begin wxGlade: controllerFrame.__init__ kwds["style"] = kwds.get("style", 0) | wx.DEFAULT_FRAME_STYLE wx.Frame.__init__(self, *args, **kwds) self.SetSize((500, 500)) self.choice_pid_cote = wx.Choice(self, wx.ID_ANY, choices=["N1", "N2"]) self.choice_pid_cote.Bind(wx.EVT_CHOICE, self.onPidChoice) self.ctrl_target_ticks = wx.SpinCtrl(self, wx.ID_ANY, "0", min=-9999999, max=9999999) self.ctrl_target_cycles = wx.SpinCtrl(self, wx.ID_ANY, "0", min=-9999999, max=9999999) self.ctrl_target_angle = FS.FloatSpin(self, wx.ID_ANY, value=0.0, min_val=-9999999.0, max_val=9999999.0) self.ctrl_target_vitesse = FS.FloatSpin(self, wx.ID_ANY, value=0.0, min_val=-9999999.0, max_val=9999999.0) self.target_send = wx.Button(self, wx.ID_ANY, "SEND") self.target_send.Bind(wx.EVT_BUTTON, self.OnSendClicked) self.scroll_panel = wx.ScrolledWindow(self, wx.ID_ANY, style=wx.TAB_TRAVERSAL) self.button_1 = wx.ToggleButton(self, wx.ID_ANY, u"EMERGENCY BREAK [désactivé]") self.button_1.Bind(wx.EVT_TOGGLEBUTTON, self.onBreak) self.choice_manche_cote = wx.Choice(self, wx.ID_ANY, choices=["Gauche", "Droit"]) self.choice_manche_cote.Bind(wx.EVT_CHOICE, self.onMancheChoice) self.checkbox_manche = wx.CheckBox(self, wx.ID_ANY, "Actif") self.checkbox_manche.Bind(wx.EVT_CHECKBOX, self.OnMancheChecked) self.__set_properties() self.__do_layout()
def InitUI(self): self.widget = dict() panel = wx.Panel(self) wx.StaticText(panel, label="Enter new goniometer parameters.", pos=(20, 20)) labels = [ "Adjust omega: ", "Adjust kappa: ", "x offset: ", "y offset: ", "z offset: ", ] values = [ round(omega, 1), round(kappa, 1), offset_matrix[0], offset_matrix[1], offset_matrix[2], ] minmaxinc = np.array([ [-270.0, 270.0, 0.5], [-190.0, 10.0, 0.5], [-2.5, 2.5, 0.1], [-2.5, 2.5, 0.1], [-2.5, 2.5, 0.1], ]) # Creating 5 FloatSpin widgets and their labels. for i in range(5): wx.StaticText(panel, label=labels[i], pos=(20, (80 + 50 * i))) self.widget[i] = fs.FloatSpin( panel, -1, pos=(200, (75 + 50 * i)), min_val=minmaxinc[i, 0], max_val=minmaxinc[i, 1], increment=minmaxinc[i, 2], value=round(values[i], 1), agwStyle=fs.FS_LEFT, ) self.widget[i].SetFormat("%f") self.widget[i].SetDigits(1) self.shadowcheck = wx.CheckBox(panel, -1, "Enable goniometer shadow", (40, 350)) self.shadowcheck.SetValue(shadowsetting) rbtn = wx.Button(panel, label="&Adjust", pos=(70, 400)) rbtn.SetFocus() cbtn = wx.Button(panel, wx.ID_CLOSE, label="&Close", pos=(185, 400)) rbtn.Bind(wx.EVT_BUTTON, self.OnCompute) cbtn.Bind(wx.EVT_BUTTON, self.OnClose)
def __init__(self, parent): wx.Dialog.__init__(self, parent, title="Add Delay") panel = wx.Panel(self) sizer = wx.BoxSizer(wx.VERTICAL) sbox = wx.StaticBox(panel, label="") sboxSizer = wx.StaticBoxSizer(sbox, wx.HORIZONTAL) grid = wx.GridBagSizer(5, 5) row = 0 self.spinDelay = floatspin.FloatSpin(panel, min_val=0, max_val=10000, digits=5, increment=0.1) self.labelDelay = wx.StaticText(panel, label="seconds") grid.Add(self.spinDelay, pos=(row, 1), span=(2, 2), flag=wx.ALL | wx.ALIGN_BOTTOM, border=5) grid.Add(self.labelDelay, pos=(row, 3), span=(2, 2), flag=wx.ALL | wx.ALIGN_CENTRE, border=5) sboxSizer.Add(grid, 1, wx.ALL | wx.EXPAND, 10) sboxSizer.AddSpacer(10) #----- hsizer = wx.BoxSizer(wx.HORIZONTAL) hsizer.AddStretchSpacer() btnCancel = wx.Button(panel, label="Cancel", id=wx.ID_CANCEL) btnCancel.Bind(wx.EVT_BUTTON, self.OnButton) btnConfirm = wx.Button(panel, label="Confirm", id=wx.ID_OK) btnConfirm.Bind(wx.EVT_BUTTON, self.OnButton) hsizer.Add(btnCancel, 0, wx.ALL | wx.EXPAND, 5) hsizer.Add(btnConfirm, 0, wx.ALL | wx.EXPAND, 5) #add to main sizer sizer.Add(sboxSizer, 0, wx.ALL | wx.EXPAND, 5) sizer.Add(hsizer, 0, wx.ALL | wx.EXPAND, 5) panel.SetSizer(sizer) w, h = sizer.Fit(self) self.Bind(wx.EVT_KEY_UP, self.OnKeyUp) try: icon = wx.Icon("images/delay.png") self.SetIcon(icon) except Exception as e: print(e)
def __init__(self, parent, label='', label_size=(200, -1), label_style='normal', checkbox=False, checkbox_state=False, checkbox_label='', ctrl_size=(60, -1), ctrl_value='3', ctrl_max=999999, ctrl_min=0, ctrl_step=1, ctrl_digits=0): CtrlBase.__init__(self, parent=parent, label_style=label_style) self.value = ctrl_value self.checkbox_state = checkbox_state self.toggle = None cols = 3 if checkbox: assert checkbox_label != '' label = '' cols += 1 self.toggle = wx.CheckBox(self, label=checkbox_label, size=label_size) self.toggle.SetValue(self.checkbox_state) ctr_box = wx.FlexGridSizer(1, cols, 0, 5) self.txt = wx.StaticText(self, label=label.decode('utf-8'), size=label_size) self.txt.SetFont(self.font) self.ctr = fs.FloatSpin(self, value=ctrl_value, max_val=(ctrl_max), min_val=(ctrl_min), increment=ctrl_step, digits=ctrl_digits, size=ctrl_size) if checkbox: ctr_box.Add(self.toggle, flag=wx.ALIGN_CENTER_VERTICAL) self.toggle_boxes(flag_on=self.checkbox_state) self.Bind(wx.EVT_CHECKBOX, self.onToggle, self.toggle) ctr_box.Add(self.txt, flag=wx.ALIGN_CENTER_VERTICAL) ctr_box.Add(self.ctr, flag=wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT | wx.EXPAND) self.SetSizer(ctr_box)