def __init__(self, parent, values): wx.Frame.__init__(self, parent, \ title="Enter Resolution to Resample To", \ size = (350,100)) panel = wx.Panel(self) sizer = wx.BoxSizer(wx.VERTICAL) flexsizer = wx.FlexGridSizer(cols=2, hgap=10, vgap=15) label1 = wx.StaticText(panel, -1, label='Resolution (in mm)') self.box1 = NumCtrl(panel, id=wx.ID_ANY, value=values[0], integerWidth=2, fractionWidth=3, allowNegative=False, allowNone=True) flexsizer.Add(label1) flexsizer.Add(self.box1, 0, wx.ALIGN_RIGHT, 5) button = wx.Button(panel, -1, 'OK', size=(90, 30)) button.Bind(wx.EVT_BUTTON, self.onButtonClick) sizer.Add(flexsizer, 1, wx.EXPAND | wx.ALL, 10) sizer.Add(button, 0, wx.ALIGN_CENTER) panel.SetSizer(sizer) self.Show()
def __init__(self, parent): self.parent = parent wx.PopupWindow.__init__(self, parent, style=wx.CLOSE_BOX) self.rbox = wx.RadioBox(self, label='Shear Axis', pos=(50, 10), choices=['X-axis', 'Y-axis'], majorDimension=1, style=wx.RA_SPECIFY_ROWS) sfLabel = wx.StaticText(self, -1, "Enter Shear Factor: ", pos=(10, 74)) self.sfInput = NumCtrl(self, value=0.0, integerWidth=2, fractionWidth=2, pos=(115, 75), size=(100, -1)) refLabel = wx.StaticText(self, -1, "Enter ref: ", pos=(10, 104)) self.refInput = NumCtrl(self, value=0.0, integerWidth=2, fractionWidth=2, pos=(115, 105), size=(100, -1)) okBtn = wx.Button(self, -1, label='OK', pos=(10, 140), size=(100, 30)) cancelBtn = wx.Button(self, -1, label='Cancel', pos=(120, 140), size=(100, 30)) self.SetSize((230, 180)) okBtn.Bind(wx.EVT_BUTTON, self.onOKClick) cancelBtn.Bind(wx.EVT_BUTTON, self.onCancelClick)
def createControls(self): self.OrderType = wx.RadioBox(self.pnl, label='OrderType', pos=(80, 30), choices=["LMT", "MKT"], majorDimension=1, style=wx.RA_SPECIFY_ROWS) self.Action = wx.RadioBox(self.pnl, label='Action', pos=(60, 30), choices=["BUY", "SELL"], majorDimension=1, style=wx.RA_SPECIFY_ROWS) self.hbox1 = wx.BoxSizer(wx.VERTICAL) l1 = wx.StaticText(self.pnl, -1, "Symbol") self.hbox1.Add(l1, 1, wx.ALIGN_LEFT | wx.ALL, 5) self.Symbol = wx.TextCtrl(self.pnl) self.hbox1.Add(self.Symbol) self.hbox2 = wx.BoxSizer(wx.VERTICAL) l2 = wx.StaticText(self.pnl, -1, "Quantity") self.hbox2.Add(l2, 1, wx.ALIGN_LEFT | wx.ALL, 5) self.Quantity = IntCtrl(self.pnl) self.hbox2.Add(self.Quantity) self.hbox3 = wx.BoxSizer(wx.VERTICAL) l3 = wx.StaticText(self.pnl, -1, "LmtPrice") self.hbox3.Add(l3, 1, wx.ALIGN_LEFT | wx.ALL, 5) self.LmtPrice = NumCtrl(self.pnl, fractionWidth=2, min=0, max=None) self.hbox3.Add(self.LmtPrice)
def __init__(self, parent): self.parent = parent wx.PopupWindow.__init__(self, parent, style=wx.CLOSE_BOX) amplitudeLabel = wx.StaticText(self, -1, "Enter amplitude: ", pos=(10, 14)) self.amplitudeInput = NumCtrl(self, value=0.0, integerWidth=3, fractionWidth=2, pos=(120, 10), size=(100, -1)) phaseLabel = wx.StaticText(self, -1, "Enter phase: ", pos=(10, 44)) self.phaseInput = NumCtrl(self, value=0.0, integerWidth=3, fractionWidth=2, pos=(120, 40), size=(100, -1)) okBtn = wx.Button(self, -1, label='OK', pos=(10, 70), size=(100, 30)) cancelBtn = wx.Button(self, -1, label='Cancel', pos=(120, 70), size=(100, 30)) self.SetSize((230, 110)) okBtn.Bind(wx.EVT_BUTTON, self.onOKClick) cancelBtn.Bind(wx.EVT_BUTTON, self.onCancelClick)
def __init__(self, parent): self.parent = parent wx.PopupWindow.__init__(self, parent, style=wx.CLOSE_BOX) txLabel = wx.StaticText(self, -1, "Enter tx: ", pos=(10, 14)) self.txInput = NumCtrl(self, value=0.0, integerWidth=3, fractionWidth=2, pos=(55, 10), size=(100, -1)) tyLabel = wx.StaticText(self, -1, "Enter ty: ", pos=(10, 44)) self.tyInput = NumCtrl(self, value=0.0, integerWidth=3, fractionWidth=2, pos=(55, 40), size=(100, -1)) okBtn = wx.Button(self, -1, label='OK', pos=(10, 70), size=(100, 20)) cancelBtn = wx.Button(self, -1, label='Cancel', pos=(10, 100), size=(100, 20)) self.SetSize((130, 140)) okBtn.Bind(wx.EVT_BUTTON, self.onOKClick) cancelBtn.Bind(wx.EVT_BUTTON, self.onCancelClick)
def _number_editor(self, settings, name): initial_value = settings[name] editor = NumCtrl(self, value=initial_value, integerWidth=3, allowNone=True) editor.Bind(wx.EVT_TEXT, lambda evt: self._set_value(editor, name)) return editor
def _number_editor(self, settings, name): initial_value = settings[name] editor = NumCtrl(self, value=initial_value, integerWidth=3, allowNone=True) """ editor.SetBackgroundColour(Colour(200, 222, 40)) editor.SetOwnBackgroundColour(Colour(200, 222, 40)) editor.SetForegroundColour(Colour(7, 0, 70)) editor.SetOwnForegroundColour(Colour(7, 0, 70)) """ editor.Bind(wx.EVT_TEXT, lambda evt: self._set_value(editor, name)) return editor
def __init__(self, parent): self.parent = parent wx.PopupWindow.__init__(self, parent, style=wx.CLOSE_BOX ) xLabel = wx.StaticText(self, -1, "X", pos=(120,5)) yLabel = wx.StaticText(self, -1, "Y", pos=(180,5)) centerLabel = wx.StaticText(self, -1, "Enter min: ", pos=(10,24)) self.minxInput = NumCtrl(self, value=0.0, integerWidth=3, fractionWidth=2, pos=(90, 20), size=(100, -1)) self.minyInput = NumCtrl(self, value=0.0, integerWidth=3, fractionWidth=2, pos=(150, 20), size=(100, -1)) radiusLabel = wx.StaticText(self, -1, "Enter max: ", pos=(10,54)) self.maxxInput = NumCtrl(self, value=0.0, integerWidth=3, fractionWidth=2, pos=(90, 50), size=(100, -1)) self.maxyInput = NumCtrl(self, value=0.0, integerWidth=3, fractionWidth=2, pos=(150, 50), size=(100, -1)) self.errorLabel = wx.StaticText(self, -1, "", pos=(90, 80)) okBtn = wx.Button(self, -1, label='OK', pos=(10, 100), size=(100, 30)) cancelBtn = wx.Button(self, -1, label='Cancel', pos=(120, 100), size=(100, 30)) self.SetSize((230, 135)) okBtn.Bind(wx.EVT_BUTTON, self.onOKClick) cancelBtn.Bind(wx.EVT_BUTTON, self.onCancelClick)
def Ctrl(*args, **kwargs): """ Actually a factory function providing a unifying interface for generating masked controls. """ if 'controlType' not in kwargs: controlType = TEXT else: controlType = kwargs['controlType'] del kwargs['controlType'] if controlType == TEXT: return TextCtrl(*args, **kwargs) elif controlType == COMBO: return ComboBox(*args, **kwargs) elif controlType == IPADDR: return IpAddrCtrl(*args, **kwargs) elif controlType == TIME: return TimeCtrl(*args, **kwargs) elif controlType == NUMBER: return NumCtrl(*args, **kwargs) else: raise AttributeError("invalid controlType specified: %s" % repr(controlType))
def __init__(self, parent=None): super(PositionParameters, self).__init__(parent) # Parameters self.parent = parent self.SetSize((232,-1)) self.SetSizeHints(232,-1) mainSizer = wx.BoxSizer(wx.VERTICAL) posBox = wx.StaticBox(self, -1, "Position X, Y") posSizer = wx.StaticBoxSizer(posBox, wx.HORIZONTAL) self.positionX = wx.StaticText(self, label='0', style=wx.TR_SINGLE) posSizer.Add(self.positionX, 3, wx.ALL|wx.ALIGN_CENTER, 5) labelX = wx.StaticText(self, label='mm', style=wx.TR_SINGLE) posSizer.Add(labelX, 1, wx.ALL|wx.ALIGN_CENTER, 5) self.positionY = wx.StaticText(self, label='0', style=wx.TR_SINGLE) posSizer.Add(self.positionY, 3, wx.ALL|wx.ALIGN_CENTER, 5) labelY = wx.StaticText(self, label='mm', style=wx.TR_SINGLE) posSizer.Add(labelY, 1, wx.ALL|wx.ALIGN_CENTER, 5) self.setHome = wx.Button(self, name='setHome', label=u'Set \u2302', size=(50,25)) self.setHome.Bind(wx.EVT_BUTTON, self.set_home) posSizer.Add(self.setHome, 1, wx.ALL|wx.ALIGN_CENTER, 5) mainSizer.Add(posSizer, 0, wx.ALL|wx.ALIGN_CENTER, 5) inBox = wx.StaticBox(self, -1, "Increment X, Y | Speed") inSizer = wx.StaticBoxSizer(inBox, wx.HORIZONTAL) self.setIncrementX = NumCtrl(self, name = 'setIncrementX', value = 9, integerWidth = 2, allowNegative = False, min = 0.1, max = 99, fractionWidth = 1, groupDigits = False, autoSize = False, style = wx.TR_SINGLE|wx.CENTER, size = (34,-1)) inSizer.Add(self.setIncrementX, 2, wx.ALL|wx.ALIGN_CENTER, 2) labelIncX = wx.StaticText(self, label='mm', style=wx.TR_SINGLE) inSizer.Add(labelIncX, 1, wx.RIGHT|wx.ALIGN_CENTER, 2) self.setIncrementY = NumCtrl(self, name = 'setIncrementY', value = 9, integerWidth = 2, allowNegative = False, min = 0.1, max = 99, fractionWidth = 1, groupDigits = False, autoSize = False, style = wx.TR_SINGLE|wx.CENTER, size = (34,-1)) inSizer.Add(self.setIncrementY, 2, wx.ALL|wx.ALIGN_CENTER, 5) labelIncY = wx.StaticText(self, label='mm', style=wx.TR_SINGLE) inSizer.Add(labelIncY, 1, wx.RIGHT|wx.ALIGN_CENTER, 2) self.setSpeed = NumCtrl(self, name = 'setSpeed', value = self.parent.control.get_speed(), integerWidth = 2, allowNegative = False, min = 1, max = 99, fractionWidth = 1, groupDigits = False, autoSize = False, style = wx.TR_SINGLE|wx.CENTER, size = (34,-1)) self.setSpeed.Bind(wx.EVT_TEXT, self.set_speed) inSizer.Add(self.setSpeed, 2, wx.ALL|wx.ALIGN_CENTER, 2) labelSpeed = wx.StaticText(self, label='mm/s', style=wx.TR_SINGLE) inSizer.Add(labelSpeed, 1, wx.RIGHT|wx.ALIGN_CENTER, 2) mainSizer.Add(inSizer, 0, wx.ALL|wx.ALIGN_CENTER, 5) self.SetSizer(mainSizer) mainSizer.Fit(self)
def custom_resolution(self, e): global width global height dlg = wx.Dialog(self, size=(300, 150)) self.instructions = wx.StaticText( dlg, wx.ID_ANY, 'Here you can input a custom resolution. Make sure your camera supports it.' ) self.width = NumCtrl(dlg) self.width.SetAllowNegative(False) self.width.SetAllowNone(False) self.width.SetValue(width) self.placex = wx.StaticText(dlg, wx.ID_ANY, 'x') self.height = NumCtrl(dlg) self.height.SetAllowNegative(False) self.height.SetAllowNone(False) self.height.SetValue(height) self.enter = wx.Button(dlg, wx.ID_OK) self.cancel = wx.Button(dlg, wx.ID_CANCEL) wrap_sizer = wx.BoxSizer(wx.VERTICAL) instructions_sizer = wx.BoxSizer(wx.HORIZONTAL) button_sizer = wx.BoxSizer(wx.HORIZONTAL) button_sizer.Add(self.enter, 0, wx.CENTER | wx.RIGHT, 5) button_sizer.Add(self.cancel, 0, wx.CENTER) instructions_sizer.Add(self.width, 1, wx.CENTER | wx.EXPAND) instructions_sizer.Add(self.placex, 0, wx.CENTER) instructions_sizer.Add(self.height, 1, wx.CENTER | wx.EXPAND) wrap_sizer.Add(self.instructions, 1, wx.CENTER | wx.LEFT | wx.RIGHT | wx.BOTTOM, 10) wrap_sizer.Add(instructions_sizer, 0, wx.CENTER | wx.EXPAND | wx.ALL, 10) wrap_sizer.Add(button_sizer, 0, wx.CENTER | wx.BOTTOM, 10) dlg.SetSizer(wrap_sizer) dlg.Centre() dlg.Show() if dlg.ShowModal() == wx.ID_OK: height = self.height.GetValue() width = self.width.GetValue()
class ResampleNumBoxFrame(wx.Frame): def __init__(self, parent, values): wx.Frame.__init__(self, parent, \ title="Enter Resolution to Resample To", \ size = (350,100)) panel = wx.Panel(self) sizer = wx.BoxSizer(wx.VERTICAL) flexsizer = wx.FlexGridSizer(cols=2, hgap=10, vgap=15) label1 = wx.StaticText(panel, -1, label='Resolution (in mm)') self.box1 = NumCtrl(panel, id=wx.ID_ANY, value=values[0], integerWidth=2, fractionWidth=3, allowNegative=False, allowNone=True) flexsizer.Add(label1) flexsizer.Add(self.box1, 0, wx.ALIGN_RIGHT, 5) button = wx.Button(panel, -1, 'OK', size=(90, 30)) button.Bind(wx.EVT_BUTTON, self.onButtonClick) sizer.Add(flexsizer, 1, wx.EXPAND | wx.ALL, 10) sizer.Add(button, 0, wx.ALIGN_CENTER) panel.SetSizer(sizer) self.Show() def onButtonClick(self, event): parent = self.Parent if type(self.box1.GetValue()) is not float: dlg = wx.MessageDialog(self, "Resolution must be a decimal " \ "value, such as 2.5 or 3.0.", 'Error!', wx.OK | wx.ICON_ERROR) dlg.ShowModal() dlg.Destroy() else: val = self.box1.GetValue() parent.listbox.Append(str(val)) self.Close()
class Tubes(wx.Panel): def __init__(self, parent=None): super(Tubes, self).__init__(parent) # Parameters self.parent = parent tubeBox = wx.StaticBox(self, -1, "Plate settings") mainSizer = wx.StaticBoxSizer(tubeBox, wx.VERTICAL) level1Sizer = wx.BoxSizer(wx.HORIZONTAL) level2Sizer = wx.BoxSizer(wx.HORIZONTAL) labelTube = wx.Button(self, name='labelTube', label='Go to tube #:', style=wx.TR_SINGLE) labelTube.Bind(wx.EVT_BUTTON, self.goto_tube) level1Sizer.Add(labelTube, 1, wx.RIGHT|wx.ALIGN_CENTER, 2) self.tubeNo = NumCtrl(self, name = 'gotoTube', value = 1, integerWidth = 2, allowNegative = False, min = 1, max = 99, fractionWidth = 0, groupDigits = False, autoSize = False, style = wx.TR_SINGLE|wx.CENTER, size = (29,-1)) level1Sizer.Add(self.tubeNo, 1, wx.ALL|wx.ALIGN_CENTER, 2) mainSizer.Add(level1Sizer, 1, wx.ALL|wx.ALIGN_CENTER, 5) label_row = wx.StaticText(self, label='Rows', style=wx.TR_SINGLE) level2Sizer.Add(label_row, 2, wx.ALL|wx.ALIGN_CENTER, 2) self.tube_rows = NumCtrl(self, name = 'rowsTube', value = 12, integerWidth = 2, allowNegative = False, min = 1, max = 99, fractionWidth = 0, groupDigits = False, autoSize = False, style = wx.TR_SINGLE|wx.CENTER, size = (29,-1)) level2Sizer.Add(self.tube_rows, 1, wx.ALL|wx.ALIGN_CENTER, 2) label_row = wx.StaticText(self, label='Columns', style=wx.TR_SINGLE) level2Sizer.Add(label_row, 2, wx.ALL|wx.ALIGN_CENTER, 2) self.tube_cols = NumCtrl(self, name = 'colsTube', value = 8, integerWidth = 2, allowNegative = False, min = 1, max = 99, fractionWidth = 0, groupDigits = False, autoSize = False, style = wx.TR_SINGLE|wx.CENTER, size = (29,-1)) level2Sizer.Add(self.tube_cols, 1, wx.ALL|wx.ALIGN_CENTER, 2) mainSizer.Add(level2Sizer, 1, wx.ALL|wx.ALIGN_CENTER, 5) self.SetSizer(mainSizer) def goto_tube(self, event): rows = self.tube_rows.GetValue() cols = self.tube_cols.GetValue() tube = self.tubeNo.GetValue()-1 if (tube+1 > rows*cols) or (tube < 0): return incX = self.parent.pos_param.setIncrementX.GetValue() incY = self.parent.pos_param.setIncrementY.GetValue() cols_step = int(tube/rows) rows_step = tube - (cols_step * rows) print(cols_step, rows_step) self.parent.control.move_abs(-rows_step*incX, cols_step*incY)
def _init_operations_block(self): static_box = wx.StaticBox(self._panel, label="Operations") box_sizer = wx.StaticBoxSizer(static_box, wx.VERTICAL) temp_sizer = wx.GridBagSizer(3, 2) button = wx.Button(self._panel, label="Generate") button.Bind(wx.EVT_BUTTON, self._on_random_particle_generation_click) temp_sizer.Add(button, pos=(0, 0), flag=wx.ALIGN_CENTER | wx.ALL, border=1) num_ctrl = NumCtrl(self._panel, size=(86, 24), autoSize=False, style=wx.TE_CENTER, value=10, min=1, max=50, integerWidth=2, limitOnFieldChange=True) self._widgets['random_generation'] = num_ctrl temp_sizer.Add(num_ctrl, pos=(0, 1), flag=wx.ALIGN_CENTER | wx.TOP, border=1) button = wx.Button(self._panel, label="Load") button.Bind(wx.EVT_BUTTON, self._on_loading_click) temp_sizer.Add(button, pos=(1, 0), flag=wx.ALIGN_CENTER | wx.ALL, border=1) button = wx.Button(self._panel, label="Clear") temp_sizer.Add(button, pos=(1, 1), flag=wx.ALIGN_CENTER | wx.ALL, border=1) button.Bind(wx.EVT_BUTTON, self._on_clear_click) button = wx.Button(self._panel, label="Start") button.Bind(wx.EVT_BUTTON, self._on_start_click) temp_sizer.Add(button, pos=(2, 0), flag=wx.ALIGN_CENTER | wx.ALL, border=1) button = wx.Button(self._panel, label="Stop") button.Bind(wx.EVT_BUTTON, self._on_stop_click) temp_sizer.Add(button, pos=(2, 1), flag=wx.ALIGN_CENTER | wx.ALL, border=1) box_sizer.Add(temp_sizer, flag=wx.EXPAND | wx.ALL, border=1) self._panel_sizer.Add(box_sizer, pos=(3, 0), span=(1, 4), flag=wx.EXPAND | wx.ALL, border=6)
def __init__(self, parent): self.parent = parent wx.PopupWindow.__init__(self, parent, style=wx.CLOSE_BOX ) self.rbox = wx.RadioBox(self,label = 'About', pos = (2,10), choices = ['X-axis', 'Y-axis', 'Origin', 'Line'], majorDimension = 1, style = wx.RA_SPECIFY_ROWS) slopeLabel = wx.StaticText(self, -1, "Enter slope (m): ", pos=(10,70)) self.slopeInput = NumCtrl(self, value=0.0, integerWidth=3,fractionWidth=2, pos=(120, 70), size=(100, -1)) cLabel = wx.StaticText(self, -1, "Enter y-intercept (c): ", pos=(10,100)) self.cInput = NumCtrl(self, value=0.0, integerWidth=3, fractionWidth=2, pos=(120, 100), size=(100, -1)) okBtn = wx.Button(self, -1, label='OK', pos=(10, 130), size=(100, 30)) cancelBtn = wx.Button(self, -1, label='Cancel', pos=(120, 130), size=(100, 30)) self.SetSize((230, 170)) okBtn.Bind(wx.EVT_BUTTON, self.onOKClick) cancelBtn.Bind(wx.EVT_BUTTON, self.onCancelClick)
def __init__(self, parent, values): wx.Frame.__init__(self, parent, title="Enter Frequency Cutoffs (in Hz)", size=(300, 140)) panel = wx.Panel(self) sizer = wx.BoxSizer(wx.VERTICAL) flexsizer = wx.FlexGridSizer(cols=2, hgap=10, vgap=15) label1 = wx.StaticText(panel, -1, label='Low-frequency cutoff') self.box1 = NumCtrl(panel, id=wx.ID_ANY, value=values[0], integerWidth=2, fractionWidth=3, allowNegative=False, allowNone=True) flexsizer.Add(label1) flexsizer.Add(self.box1, 0, wx.ALIGN_RIGHT, 5) label2 = wx.StaticText(panel, -1, label='High-frequency cutoff') self.box2 = NumCtrl(panel, id=wx.ID_ANY, value=values[1], integerWidth=2, fractionWidth=3, allowNegative=False, allowNone=True) flexsizer.Add(label2, 0, wx.EXPAND, 2) flexsizer.Add(self.box2, 0, wx.ALIGN_RIGHT, 5) button = wx.Button(panel, -1, 'OK', size=(90, 30)) button.Bind(wx.EVT_BUTTON, self.onButtonClick) sizer.Add(flexsizer, 1, wx.EXPAND | wx.ALL, 10) sizer.Add(button, 0, wx.ALIGN_CENTER) panel.SetSizer(sizer) self.Show()
def setMiddlePanel(self, parent): sizer = wx.BoxSizer(wx.HORIZONTAL) label = wx.StaticText(parent, -1, self.elbowDialogGeneralText()["e5"]) value = NumCtrl(parent, self.listOfIds[4], integerWidth=7, fractionWidth=0) sizer.Add(label, 1, flag=wx.ALL | wx.ALIGN_RIGHT, border=2) sizer.Add(value, 2, flag=wx.ALL | wx.ALIGN_LEFT, border=2) parent.SetSizer(sizer) parent.Fit()
def buildBandpassBox(self): bandpass_box = wx.StaticBox(self, label="Bandpass filter") text_start_fq = wx.StaticText(bandpass_box, label="Low cutoff:") self.input_start_fq = NumCtrl(bandpass_box, value=20, integerWidth=5, fractionWidth=0, allowNegative=False, min=20, max=20000) text_end_fq = wx.StaticText(bandpass_box, label="High cutoff:") self.input_end_fq = NumCtrl(bandpass_box, value=20000.0, integerWidth=5, fractionWidth=0, allowNegative=False, min=100, max=25000) button_apply_bandpass = wx.Button(bandpass_box, label="Apply bandpass filter") button_reset_bandpass = wx.Button(bandpass_box, label="Delete bandpass") button_apply_bandpass.Bind(wx.EVT_BUTTON, self.onApplyBandpass) button_reset_bandpass.Bind(wx.EVT_BUTTON, self.onResetBandpass) gridbag_sizer = wx.GridBagSizer(vgap=5, hgap=5) gridbag_sizer.Add(text_start_fq, pos=(0, 0), flag=wx.EXPAND) gridbag_sizer.Add(self.input_start_fq, pos=(0, 2), flag=wx.EXPAND) gridbag_sizer.Add(text_end_fq, pos=(1, 0), flag=wx.EXPAND) gridbag_sizer.Add(self.input_end_fq, pos=(1, 2), flag=wx.EXPAND) gridbag_sizer.Add(button_reset_bandpass, pos=(3, 0), flag=wx.EXPAND) gridbag_sizer.Add(button_apply_bandpass, pos=(3, 2), flag=wx.EXPAND) gridbag_sizer.AddGrowableCol(1) # gridbag_sizer.AddGrowableRow(3) box_sizer = wx.StaticBoxSizer(bandpass_box, wx.VERTICAL) box_sizer.Add(gridbag_sizer, proportion=1, flag=wx.EXPAND) return box_sizer
class TextBoxFrame(wx.Frame): def __init__(self, parent, values): wx.Frame.__init__(self, parent, title="Enter Frequency Cutoffs (in Hz)", size=(300, 140)) panel = wx.Panel(self) sizer = wx.BoxSizer(wx.VERTICAL) flexsizer = wx.FlexGridSizer(cols=2, hgap=10, vgap=15) label1 = wx.StaticText(panel, -1, label='Low-frequency cutoff') self.box1 = NumCtrl(panel, id=wx.ID_ANY, value=values[0], integerWidth=2, fractionWidth=3, allowNegative=False, allowNone=True) flexsizer.Add(label1) flexsizer.Add(self.box1, 0, wx.ALIGN_RIGHT, 5) label2 = wx.StaticText(panel, -1, label='High-frequency cutoff') self.box2 = NumCtrl(panel, id=wx.ID_ANY, value=values[1], integerWidth=2, fractionWidth=3, allowNegative=False, allowNone=True) flexsizer.Add(label2, 0, wx.EXPAND, 2) flexsizer.Add(self.box2, 0, wx.ALIGN_RIGHT, 5) button = wx.Button(panel, -1, 'OK', size=(90, 30)) button.Bind(wx.EVT_BUTTON, self.onButtonClick) sizer.Add(flexsizer, 1, wx.EXPAND | wx.ALL, 10) sizer.Add(button, 0, wx.ALIGN_CENTER) panel.SetSizer(sizer) self.Show() def onButtonClick(self, event): parent = self.Parent if self.box1.GetValue() and self.box2.GetValue(): if self.box1.GetValue() >= self.box2.GetValue(): dlg = wx.MessageDialog( self, 'Lower Bound should be less than Upper Bound', 'Error!', wx.OK | wx.ICON_ERROR) dlg.ShowModal() dlg.Destroy() else: val = [self.box1.GetValue(), self.box2.GetValue()] parent.listbox.Append(str(val)) self.Close()
def __init__(self, parent=None): super(Tubes, self).__init__(parent) # Parameters self.parent = parent tubeBox = wx.StaticBox(self, -1, "Plate settings") mainSizer = wx.StaticBoxSizer(tubeBox, wx.VERTICAL) level1Sizer = wx.BoxSizer(wx.HORIZONTAL) level2Sizer = wx.BoxSizer(wx.HORIZONTAL) labelTube = wx.Button(self, name='labelTube', label='Go to tube #:', style=wx.TR_SINGLE) labelTube.Bind(wx.EVT_BUTTON, self.goto_tube) level1Sizer.Add(labelTube, 1, wx.RIGHT|wx.ALIGN_CENTER, 2) self.tubeNo = NumCtrl(self, name = 'gotoTube', value = 1, integerWidth = 2, allowNegative = False, min = 1, max = 99, fractionWidth = 0, groupDigits = False, autoSize = False, style = wx.TR_SINGLE|wx.CENTER, size = (29,-1)) level1Sizer.Add(self.tubeNo, 1, wx.ALL|wx.ALIGN_CENTER, 2) mainSizer.Add(level1Sizer, 1, wx.ALL|wx.ALIGN_CENTER, 5) label_row = wx.StaticText(self, label='Rows', style=wx.TR_SINGLE) level2Sizer.Add(label_row, 2, wx.ALL|wx.ALIGN_CENTER, 2) self.tube_rows = NumCtrl(self, name = 'rowsTube', value = 12, integerWidth = 2, allowNegative = False, min = 1, max = 99, fractionWidth = 0, groupDigits = False, autoSize = False, style = wx.TR_SINGLE|wx.CENTER, size = (29,-1)) level2Sizer.Add(self.tube_rows, 1, wx.ALL|wx.ALIGN_CENTER, 2) label_row = wx.StaticText(self, label='Columns', style=wx.TR_SINGLE) level2Sizer.Add(label_row, 2, wx.ALL|wx.ALIGN_CENTER, 2) self.tube_cols = NumCtrl(self, name = 'colsTube', value = 8, integerWidth = 2, allowNegative = False, min = 1, max = 99, fractionWidth = 0, groupDigits = False, autoSize = False, style = wx.TR_SINGLE|wx.CENTER, size = (29,-1)) level2Sizer.Add(self.tube_cols, 1, wx.ALL|wx.ALIGN_CENTER, 2) mainSizer.Add(level2Sizer, 1, wx.ALL|wx.ALIGN_CENTER, 5) self.SetSizer(mainSizer)
def InitUI(self): menubar = wx.MenuBar() helpMenu = wx.Menu() aboutItem = helpMenu.Append(wx.ID_ABOUT, 'About', 'Display about information') menubar.Append(helpMenu, '&Help') self.SetMenuBar(menubar) self.Bind(wx.EVT_MENU, self.OnShowAbout, aboutItem) panel = wx.Panel(self, wx.ID_ANY) self.chooseDataButton = wx.Button(panel, label="Choose Data File") self.chooseDataButton.Bind(wx.EVT_BUTTON, self.OnChooseFile) self.dataFileName = wx.StaticText(panel, wx.ID_ANY, label="No Data File Chosen", style=wx.ALIGN_CENTER) self.figure = Figure() self.axes = self.figure.add_subplot(111) self.canvas = FigureCanvas(panel, -1, self.figure) hbox1 = wx.BoxSizer(wx.HORIZONTAL) l1 = wx.StaticText(panel, -1, "Data Start") hbox1.Add(l1, 1, wx.EXPAND | wx.ALIGN_LEFT | wx.ALL,5) self.dataStartText = NumCtrl(panel) self.dataStartText.Disable() hbox1.Add(self.dataStartText,1,wx.EXPAND | wx.ALIGN_LEFT | wx.ALL,5) self.runAnalysisButton = wx.Button(panel, label="Run Analysis") self.runAnalysisButton.Bind(wx.EVT_BUTTON, self.OnRunAnalysis) self.runAnalysisButton.Disable() vbox = wx.BoxSizer(wx.VERTICAL) vbox.Add(self.chooseDataButton) vbox.Add(self.dataFileName) vbox.Add(hbox1) vbox.Add(self.runAnalysisButton) vbox.Add(self.canvas, 1, wx.LEFT | wx.TOP | wx.GROW) panel.SetSizer(vbox) self.SetTitle('Analyzing Slowdown of Spinner') self.SetSize(640,480) self.Centre()
def onEnter(self, event): label = self.txt.GetValue() if label == "Input string": #print("Input string it's working") self.txtstring = wx.TextCtrl(self.panel,id=wx.ID_ANY,pos=(190,110)) self.btn = wx.Button(self.panel,id=wx.ID_ANY,label="Show",pos=(350,110)) self.btn.Bind(wx.EVT_BUTTON,self.onShow) self.static = wx.TextCtrl(self.panel,id=1,pos=(10,200),size=(460,240),style=wx.TE_READONLY) elif label == "Input number": #print("Input number it's working") self.txtnum = NumCtrl(self.panel,id=wx.ID_ANY,pos=(200,110)) self.btn1 = wx.Button(self.panel,id=wx.ID_ANY,label="Show",pos=(350,110)) self.btn1.Bind(wx.EVT_BUTTON,self.onShow1) self.static1 = wx.TextCtrl(self.panel,id=1,pos=(10,200),size=(460,100),style=wx.TE_READONLY) elif label == "Checkbox": #print("Checkbox it's working") self.CB1 = wx.CheckBox(self.panel,id=wx.ID_ANY,label="Example1",pos=(200,110)) self.CB2 = wx.CheckBox(self.panel,id=wx.ID_ANY,label="Exmaple2",pos=(200,130)) self.Bind(wx.EVT_CHECKBOX,self.onShow2) self.static2 = wx.TextCtrl(self.panel,id=1,pos=(10,200),size=(460,100),style=wx.TE_READONLY) elif label == "Dropdown": #print("Dropdown it's working") sampleList1 = ['Sample1','Sample2','Sample3'] self.dod = wx.ComboBox(self.panel, 500, "", (160,110), (170,50), sampleList1, wx.CB_DROPDOWN #| wx.TE_PROCESS_ENTER #| wx.CB_SORT ) self.btn2 = wx.Button(self.panel,id=wx.ID_ANY,label="Show",pos=(350,110)) self.btn2.Bind(wx.EVT_BUTTON,self.onShow3) self.static3 = wx.TextCtrl(self.panel,id=1,pos=(10,200),size=(460,100),style=wx.TE_READONLY) elif label == "Toggle": #print("Toggle it's working") self.Toggle = wx.ToggleButton(self.panel,id=1,label="default",pos=(200,110)) self.Toggle.Bind(wx.EVT_TOGGLEBUTTON,self.onShow4) self.static4 = wx.TextCtrl(self.panel,id=1,pos=(10,200),size=(460,100),style=wx.TE_READONLY)
def setPanelWidgets(self, parent, list): listOfIds = {} mainSizer = wx.BoxSizer(wx.VERTICAL) for values in list: ids = [] if len(values) > 2: for x in range(4): id = wx.NewId() ids.append(id) panel = wx.Panel(parent, ids[0]) sizer = wx.BoxSizer(wx.HORIZONTAL) label = wx.StaticText(panel, ids[1], values[0]) value = NumCtrl(panel, ids[2], integerWidth=values[1][0], fractionWidth=values[1][1]) units = wx.Choice(panel, ids[3], choices=values[2]) units.Bind(wx.EVT_CHOICE, self.onAny) sizer.Add(label, 1, flag=wx.ALL | wx.ALIGN_RIGHT, border=2) sizer.Add(value, 2, flag=wx.ALL | wx.ALIGN_LEFT, border=2) sizer.Add(units, 1, flag=wx.ALL, border=2) listOfIds[values[0]] = { "panel": ids[0], "label": ids[1], "value": ids[2], "units": ids[3] } else: for x in range(3): id = wx.NewId() ids.append(id) panel = wx.Panel(parent, ids[0]) sizer = wx.BoxSizer(wx.HORIZONTAL) label = wx.StaticText(panel, ids[1], values[0]) units = wx.Choice(panel, ids[2], choices=values[1]) units.Bind(wx.EVT_CHOICE, self.onAny) sizer.Add(label, 1, flag=wx.ALL | wx.ALIGN_LEFT, border=2) sizer.Add(units, 1, flag=wx.ALL, border=2) listOfIds[values[0]] = { "panel": ids[0], "label": ids[1], "units": ids[2] } panel.SetSizer(sizer) panel.Fit() mainSizer.Add(panel, 1, wx.EXPAND) parent.SetSizer(mainSizer) parent.Fit() self.widgetsIds = listOfIds
def buildTimeOptions(self): time_box = wx.StaticBox(self, label="Displayed time limits") text_start_time = wx.StaticText(time_box, label="Start:") self.input_start_time = NumCtrl(time_box, value=0.0, integerWidth=3, fractionWidth=2, allowNegative=False, min=0.00) text_end_time = wx.StaticText(time_box, label="End:") self.input_end_time = NumCtrl(time_box, value=1.0, integerWidth=3, fractionWidth=2, allowNegative=False, min=0.01) button_apply_time = wx.Button(time_box, label="Apply time limits") button_reset_time = wx.Button(time_box, label="Reset time limits") button_apply_time.Bind(wx.EVT_BUTTON, self.onApplyTime) button_reset_time.Bind(wx.EVT_BUTTON, self.onResetTime) gridbag_sizer = wx.GridBagSizer(vgap=5, hgap=5) gridbag_sizer.Add(text_start_time, pos=(0, 0), flag=wx.EXPAND) gridbag_sizer.Add(self.input_start_time, pos=(0, 2), flag=wx.EXPAND) gridbag_sizer.Add(text_end_time, pos=(1, 0), flag=wx.EXPAND) gridbag_sizer.Add(self.input_end_time, pos=(1, 2), flag=wx.EXPAND) gridbag_sizer.Add(button_reset_time, pos=(3, 0), flag=wx.EXPAND) gridbag_sizer.Add(button_apply_time, pos=(3, 2), flag=wx.EXPAND) gridbag_sizer.AddGrowableCol(1) # gridbag_sizer.AddGrowableRow(3) box_sizer = wx.StaticBoxSizer(time_box, wx.VERTICAL) box_sizer.Add(gridbag_sizer, proportion=1, flag=wx.EXPAND) return box_sizer
def __prepare_input_fields(self): self.__input_fields = dict() for name, input_type in self.__subjective_input_callback_wrapper.get_subjective_input_structure( ): # add name name_text_field = wx.StaticText(self, -1, name) self.input_grid_sizer.Add(name_text_field) # add input field if input_type == SubjectiveMeasurementType.bool: input_field = wx.CheckBox(self, -1) elif input_type == SubjectiveMeasurementType.percentage: input_field = NumCtrl(self, -1) input_field.SetBounds(min=0, max=100) elif input_type == SubjectiveMeasurementType.number: input_field = NumCtrl(self, -1) self.input_grid_sizer.Add(input_field) self.__input_fields[name] = (input_type, input_field) self.disable_input_fields()
def __init__(self, parent): self.parent = parent wx.PopupWindow.__init__(self, parent, style=wx.CLOSE_BOX) xLabel = wx.StaticText(self, -1, "X", pos=(120, 5)) yLabel = wx.StaticText(self, -1, "Y", pos=(180, 5)) centerLabel = wx.StaticText(self, -1, "Enter center: ", pos=(10, 24)) self.centerxInput = NumCtrl(self, value=0.0, integerWidth=3, fractionWidth=2, pos=(90, 20), size=(100, -1)) self.centeryInput = NumCtrl(self, value=0.0, integerWidth=3, fractionWidth=2, pos=(150, 20), size=(100, -1)) rxLabel = wx.StaticText(self, -1, "Enter rx: ", pos=(10, 54)) self.rxInput = NumCtrl(self, value=0.0, allowNegative=False, integerWidth=3, fractionWidth=2, pos=(90, 50), size=(100, -1)) ryLabel = wx.StaticText(self, -1, "Enter ry: ", pos=(10, 84)) self.ryInput = NumCtrl(self, value=0.0, allowNegative=False, integerWidth=3, fractionWidth=2, pos=(90, 80), size=(100, -1)) okBtn = wx.Button(self, -1, label='OK', pos=(10, 110), size=(100, 30)) cancelBtn = wx.Button(self, -1, label='Cancel', pos=(120, 110), size=(100, 30)) self.SetSize((230, 145)) okBtn.Bind(wx.EVT_BUTTON, self.onOKClick) cancelBtn.Bind(wx.EVT_BUTTON, self.onCancelClick)
def __init__(self, parent, values): wx.Frame.__init__(self, parent, \ title="Enter Center of gravity coordinates", \ size = (450,150)) panel = wx.Panel(self) sizer = wx.BoxSizer(wx.VERTICAL) flexsizer = wx.FlexGridSizer(cols=3, hgap=10, vgap=15) label1 = wx.StaticText(panel, -1, label='x-coordinate') self.box1 = NumCtrl(panel, id=wx.ID_ANY, value=values[0], integerWidth=2, fractionWidth=3, allowNegative=True, allowNone=True) flexsizer.Add(label1) flexsizer.Add(self.box1, 0, wx.ALIGN_RIGHT, 5) label2 = wx.StaticText(panel, -1, label='y-coordinate') self.box2 = NumCtrl(panel, id=wx.ID_ANY, value=values[1], integerWidth=2, fractionWidth=3, allowNegative=True, allowNone=True) flexsizer.Add(label2, 0, wx.EXPAND, 2) flexsizer.Add(self.box2, 0, wx.ALIGN_LEFT, 5) label3 = wx.StaticText(panel, -1, label='z-coordinate') self.box3 = NumCtrl(panel, id=wx.ID_ANY, value=values[2], integerWidth=2, fractionWidth=3, allowNegative=True, allowNone=True) flexsizer.Add(label3, 0, wx.EXPAND, 3) flexsizer.Add(self.box3, 0, wx.ALIGN_LEFT, 5) button = wx.Button(panel, -1, 'OK', size=(90, 30)) button.Bind(wx.EVT_BUTTON, self.onButtonClick) sizer.Add(flexsizer, 1, wx.EXPAND | wx.ALL, 10) sizer.Add(button, 0, wx.ALIGN_CENTER) panel.SetSizer(sizer) self.Show()
class ClipInputPopup(wx.Frame): def __init__(self, parent): self.parent = parent wx.PopupWindow.__init__(self, parent, style=wx.CLOSE_BOX ) xLabel = wx.StaticText(self, -1, "X", pos=(120,5)) yLabel = wx.StaticText(self, -1, "Y", pos=(180,5)) centerLabel = wx.StaticText(self, -1, "Enter min: ", pos=(10,24)) self.minxInput = NumCtrl(self, value=0.0, integerWidth=3, fractionWidth=2, pos=(90, 20), size=(100, -1)) self.minyInput = NumCtrl(self, value=0.0, integerWidth=3, fractionWidth=2, pos=(150, 20), size=(100, -1)) radiusLabel = wx.StaticText(self, -1, "Enter max: ", pos=(10,54)) self.maxxInput = NumCtrl(self, value=0.0, integerWidth=3, fractionWidth=2, pos=(90, 50), size=(100, -1)) self.maxyInput = NumCtrl(self, value=0.0, integerWidth=3, fractionWidth=2, pos=(150, 50), size=(100, -1)) self.errorLabel = wx.StaticText(self, -1, "", pos=(90, 80)) okBtn = wx.Button(self, -1, label='OK', pos=(10, 100), size=(100, 30)) cancelBtn = wx.Button(self, -1, label='Cancel', pos=(120, 100), size=(100, 30)) self.SetSize((230, 135)) okBtn.Bind(wx.EVT_BUTTON, self.onOKClick) cancelBtn.Bind(wx.EVT_BUTTON, self.onCancelClick) def onOKClick(self, event): if self.minxInput.GetValue() < self.maxxInput.GetValue() and self.minyInput.GetValue() < self.maxyInput.GetValue(): self.parent.canvas.min_x = self.minxInput.GetValue() self.parent.canvas.min_y = self.minyInput.GetValue() self.parent.canvas.max_x = self.maxxInput.GetValue() self.parent.canvas.max_y = self.maxyInput.GetValue() self.parent.canvas.draw() self.Show(False) self.parent.buttons[3] = True else: self.errorLabel.SetForegroundColour((255,0,0)) self.errorLabel.SetLabel('Clipping Error') def onCancelClick(self, event): self.Show(False) self.parent.buttons[3] = True
def __init__(self, parent): self.parent = parent wx.PopupWindow.__init__(self, parent, style=wx.CLOSE_BOX) aLabel = wx.StaticText(self, -1, "Enter a: ", pos=(10, 14)) self.aInput = NumCtrl(self, value=0.0, integerWidth=2, fractionWidth=2, pos=(55, 10), size=(100, -1)) bLabel = wx.StaticText(self, -1, "Enter b: ", pos=(10, 44)) self.bInput = NumCtrl(self, value=0.0, integerWidth=2, fractionWidth=2, pos=(55, 40), size=(100, -1)) cLabel = wx.StaticText(self, -1, "Enter c: ", pos=(10, 74)) self.cInput = NumCtrl(self, value=0.0, integerWidth=2, fractionWidth=2, pos=(55, 70), size=(100, -1)) dLabel = wx.StaticText(self, -1, "Enter d: ", pos=(10, 104)) self.dInput = NumCtrl(self, value=0.0, integerWidth=2, fractionWidth=2, pos=(55, 100), size=(100, -1)) okBtn = wx.Button(self, -1, label='OK', pos=(10, 130), size=(100, 20)) cancelBtn = wx.Button(self, -1, label='Cancel', pos=(10, 160), size=(100, 20)) self.SetSize((120, 190)) okBtn.Bind(wx.EVT_BUTTON, self.onOKClick) cancelBtn.Bind(wx.EVT_BUTTON, self.onCancelClick)
def __init__(self, parent, max_icons_size=(25, 25)): self.parent = parent toolbar = parent.CreateToolBar() self.play_menu = toolbar.AddTool(wx.ID_ANY, 'Play', shortHelp='Play', bitmap=scale_image( iconsBase + 'play-button-1.png', max_icons_size=max_icons_size)) self.pause_menu = toolbar.AddTool(wx.ID_ANY, 'Stop', shortHelp='Pause', bitmap=scale_image( iconsBase + 'pause-button.png', max_icons_size=max_icons_size)) toolbar.Realize() self.bpm = NumCtrl(toolbar, value=128, pos=(80, 3), size=(50, 25), min=50, max=250)