我们从Python开源项目中,提取了以下50个代码示例,用于说明如何使用wx.HORIZONTAL。
def initNTrial(self): trialSizer = wx.BoxSizer(orient=wx.HORIZONTAL) trainTrialControlBox = widgets.ControlBox(self, label='Train Trials', orient=wx.VERTICAL) self.trainTrialSpinCtrl = wx.SpinCtrl(self, #style=wx.SP_WRAP, value=str(self.pg.nTrainTrial), min=2, max=100) self.Bind(wx.EVT_SPINCTRL, self.setNTrainTrial, self.trainTrialSpinCtrl) self.offlineControls += [self.trainTrialSpinCtrl] trainTrialControlBox.Add(self.trainTrialSpinCtrl, proportion=1, flag=wx.ALL | wx.EXPAND, border=10) trialSizer.Add(trainTrialControlBox, proportion=1, flag=wx.LEFT | wx.BOTTOM | wx.RIGHT | wx.EXPAND, border=10) testTrialControlBox = widgets.ControlBox(self, label='Test Trials', orient=wx.VERTICAL) self.testTrialSpinCtrl = wx.SpinCtrl(self, #style=wx.SP_WRAP, value=str(self.pg.nTestTrial), min=1, max=100) self.Bind(wx.EVT_SPINCTRL, self.setNTestTrial, self.testTrialSpinCtrl) self.offlineControls += [self.testTrialSpinCtrl] testTrialControlBox.Add(self.testTrialSpinCtrl, proportion=1, flag=wx.ALL | wx.EXPAND, border=10) trialSizer.Add(testTrialControlBox, proportion=1, flag=wx.BOTTOM | wx.RIGHT | wx.EXPAND, border=10) self.sizer.Add(trialSizer, proportion=0, flag=wx.EXPAND)
def initMediaPath(self): mediaPathControlBox = widgets.ControlBox(self, label='Media Path', orient=wx.HORIZONTAL) self.mediaPathTextCtrl = wx.TextCtrl(parent=self, style=wx.TE_PROCESS_ENTER) self.mediaPathTextCtrl.SetValue(self.pg.defaultMusicDir) mediaPathControlBox.Add(self.mediaPathTextCtrl, proportion=1, flag=wx.ALL | wx.EXPAND, border=10) self.Bind(wx.EVT_TEXT_ENTER, self.setMediaPath, self.mediaPathTextCtrl) self.offlineControls += [self.mediaPathTextCtrl] self.mediaBrowseButton = wx.Button(self, label='Browse') mediaPathControlBox.Add(self.mediaBrowseButton, proportion=0, flag=wx.TOP | wx.RIGHT | wx.BOTTOM, border=10) self.Bind(wx.EVT_BUTTON, self.mediaBrowse, self.mediaBrowseButton) self.offlineControls += [self.mediaBrowseButton] self.sizer.Add(mediaPathControlBox, proportion=0, flag=wx.ALL | wx.EXPAND, border=10)
def initNTrial(self): trialSizer = wx.BoxSizer(orient=wx.HORIZONTAL) trainTrialControlBox = widgets.ControlBox(self, label='Train Trials', orient=wx.VERTICAL) self.trainTrialSpinCtrl = wx.SpinCtrl(self, #style=wx.SP_WRAP, value=str(self.pg.nTrainTrial), min=10, max=100) self.Bind(wx.EVT_SPINCTRL, self.setNTrainTrial, self.trainTrialSpinCtrl) self.offlineControls += [self.trainTrialSpinCtrl] trainTrialControlBox.Add(self.trainTrialSpinCtrl, proportion=1, flag=wx.ALL | wx.EXPAND, border=10) trialSizer.Add(trainTrialControlBox, proportion=1, flag=wx.LEFT | wx.BOTTOM | wx.RIGHT | wx.EXPAND, border=10) testTrialControlBox = widgets.ControlBox(self, label='Test Trials', orient=wx.VERTICAL) self.testTrialSpinCtrl = wx.SpinCtrl(self, #style=wx.SP_WRAP, value=str(self.pg.nTestTrial), min=1, max=100) self.Bind(wx.EVT_SPINCTRL, self.setNTestTrial, self.testTrialSpinCtrl) self.offlineControls += [self.testTrialSpinCtrl] testTrialControlBox.Add(self.testTrialSpinCtrl, proportion=1, flag=wx.ALL | wx.EXPAND, border=10) trialSizer.Add(testTrialControlBox, proportion=1, flag=wx.BOTTOM | wx.RIGHT | wx.EXPAND, border=10) self.sizer.Add(trialSizer, 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 initNTrial(self): trialSizer = wx.BoxSizer(orient=wx.HORIZONTAL) trainTrialControlBox = widgets.ControlBox(self, label='Train Trials', orient=wx.VERTICAL) self.trainTrialSpinCtrl = wx.SpinCtrl(self, #style=wx.SP_WRAP, value=str(self.pg.nTrainTrial), min=5, max=100) self.Bind(wx.EVT_SPINCTRL, self.setNTrainTrial, self.trainTrialSpinCtrl) self.offlineControls += [self.trainTrialSpinCtrl] trainTrialControlBox.Add(self.trainTrialSpinCtrl, proportion=1, flag=wx.ALL | wx.EXPAND, border=10) trialSizer.Add(trainTrialControlBox, proportion=1, flag=wx.LEFT | wx.BOTTOM | wx.RIGHT | wx.EXPAND, border=10) testTrialControlBox = widgets.ControlBox(self, label='Test Trials', orient=wx.VERTICAL) self.testTrialSpinCtrl = wx.SpinCtrl(self, #style=wx.SP_WRAP, value=str(self.pg.nTestTrial), min=1, max=100) self.Bind(wx.EVT_SPINCTRL, self.setNTestTrial, self.testTrialSpinCtrl) self.offlineControls += [self.testTrialSpinCtrl] testTrialControlBox.Add(self.testTrialSpinCtrl, proportion=1, flag=wx.ALL | wx.EXPAND, border=10) trialSizer.Add(testTrialControlBox, proportion=1, flag=wx.BOTTOM | wx.RIGHT | wx.EXPAND, border=10) self.sizer.Add(trialSizer, proportion=0, flag=wx.EXPAND)
def initLayout(self): """Initialize the page layout. """ scrolledSizer = wx.BoxSizer(orient=wx.HORIZONTAL) scrolledSizer.Add(self.sourceSizer, proportion=0)#, flag=wx.EXPAND) scrolledSizer.Add(self.chanSizer, proportion=0, flag=wx.EXPAND) scrolledSizer.Add(self.messageSizer, proportion=1, flag=wx.EXPAND) self.scrolledPanel.SetSizer(scrolledSizer) # main sizer sizer = wx.BoxSizer(orient=wx.HORIZONTAL) sizer.Add(self.scrolledPanel, proportion=1, flag=wx.EXPAND) self.SetSizer(sizer) self.scrolledPanel.Layout() self.scrolledPanel.FitInside() self.scrolledPanel.SetupScrolling() # hide after layout (prevents gtk warnings) for sp in self.srcPanels.values(): sp.deselect()
def initOptions(self): optionsSizer = wx.BoxSizer(wx.HORIZONTAL) kernTypeControlBox = widgets.ControlBox(self, label='Kernel Type', orient=wx.HORIZONTAL) self.kernTypeComboBox = wx.ComboBox(self, choices=self.flt.kernMap.keys(), value=self.flt.kernType, style=wx.CB_DROPDOWN) self.Bind(wx.EVT_COMBOBOX, self.setKernType, self.kernTypeComboBox) kernTypeControlBox.Add(self.kernTypeComboBox, proportion=1, flag=wx.ALL, border=8) optionsSizer.Add(kernTypeControlBox, proportion=1, flag=wx.ALL | wx.ALIGN_CENTER, border=8) widthControlBox = widgets.ControlBox(self, label='Width', orient=wx.HORIZONTAL) self.widthSpinCtrl = wx.SpinCtrl(self, value=str(self.flt.width), min=2, max=100) self.Bind(wx.EVT_SPINCTRL, self.setWidth, self.widthSpinCtrl) widthControlBox.Add(self.widthSpinCtrl, proportion=1, flag=wx.ALL, border=8) optionsSizer.Add(widthControlBox, proportion=0, flag=wx.TOP | wx.RIGHT | wx.BOTTOM | wx.EXPAND, border=8) self.sizer.Add(optionsSizer, proportion=0)#, flag=wx.EXPAND)
def initOptions(self): STransConfigPanel.initOptions(self) optionsSizer = wx.BoxSizer(wx.HORIZONTAL) kurtosisControlBox = widgets.ControlBox(self, label='Kurtosis', orient=wx.VERTICAL) self.kurtosisComboBox = wx.ComboBox(self, choices=('Adapt', 'Sub', 'Super'), value=self.flt.kurtosis, style=wx.CB_DROPDOWN) self.Bind(wx.EVT_COMBOBOX, self.setKurtosis, self.kurtosisComboBox) kurtosisControlBox.Add(self.kurtosisComboBox, proportion=1, flag=wx.ALL, border=8) optionsSizer.Add(kurtosisControlBox, proportion=1, flag=wx.LEFT | wx.RIGHT, border=8) maxIterControlBox = widgets.ControlBox(self, label='Max Iter.', orient=wx.HORIZONTAL) self.maxIterSpinCtrl = wx.SpinCtrl(self, value=str(self.flt.maxIter), min=50, max=3500) self.Bind(wx.EVT_SPINCTRL, self.setMaxIter, self.maxIterSpinCtrl) maxIterControlBox.Add(self.maxIterSpinCtrl, proportion=1, flag=wx.ALL | wx.ALIGN_CENTER_VERTICAL, border=8) optionsSizer.Add(maxIterControlBox, proportion=0, flag=wx.RIGHT | wx.EXPAND, border=8) #lrControlBox = widgets.ControlBox(self, label='Learning Rate.', orient=wx.HORIZONTAL) self.sizer.Add(optionsSizer, proportion=0)
def OnScroll(self, evt): if not self._adjustingSB: self._sb_ignore = True sbpos = evt.GetPosition() if evt.GetOrientation() == wx.VERTICAL: fullrange, pagesize = self.sb_vert.GetRange( ), self.sb_vert.GetPageSize() sbpos = fullrange - pagesize - sbpos dist = sbpos * self._sb_xunit - \ (self._getXCurrentRange()[0] - self._sb_xfullrange) self.ScrollUp(dist) if evt.GetOrientation() == wx.HORIZONTAL: dist = sbpos * self._sb_xunit - \ (self._getXCurrentRange()[0] - self._sb_xfullrange[0]) self.ScrollRight(dist) # Private Methods **************************************************
def OnScrollWindow(self, event): if self.Editor.HasCapture() and self.StartMousePos is not None: return if wx.Platform == '__WXMSW__': wx.CallAfter(self.RefreshVisibleElements) self.Editor.Freeze() wx.CallAfter(self.Editor.Thaw) elif event.GetOrientation() == wx.HORIZONTAL: self.RefreshVisibleElements(xp=event.GetPosition()) else: self.RefreshVisibleElements(yp=event.GetPosition()) # Handle scroll in debug to fully redraw area and ensuring # instance path is fully draw without flickering if self.Debug and wx.Platform != '__WXMSW__': x, y = self.GetViewStart() if event.GetOrientation() == wx.HORIZONTAL: self.Scroll(event.GetPosition(), y) else: self.Scroll(x, event.GetPosition()) else: event.Skip()
def buildToolsBar(parent, datas): box = wx.BoxSizer( wx.HORIZONTAL ) #toolsbar = wx.ToolBar( parent, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.TB_HORIZONTAL ) toolsbar = wx.Panel( parent, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.TAB_TRAVERSAL ) toolsbar.SetSizer( box ) add_tools(toolsbar, datas[1][0][1], None) gifpath = os.path.join(root_dir, "tools/drop.gif") btn = wx.BitmapButton(toolsbar, wx.ID_ANY, make_bitmap(wx.Bitmap(gifpath)), wx.DefaultPosition, (32, 32), wx.BU_AUTODRAW|wx.RAISED_BORDER) box.Add(btn) btn.Bind(wx.EVT_LEFT_DOWN, lambda x:menu_drop(parent, toolsbar, datas, btn, x)) add_tools(toolsbar, datas[1][1][1]) return toolsbar
def add_num(self, rang, accu, 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 ) ctrl = NumCtrl(self, rang, accu) self.ctrl_dic[key] = ctrl ctrl.Bind(wx.EVT_KEY_UP, 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 add_color(self, 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 ) ctrl = ColorCtrl(self) self.ctrl_dic[key] = ctrl ctrl.Bind(wx.EVT_KEY_UP, 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 add_txt(self, 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 ) ctrl = wx.TextCtrl( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, 0 ) self.ctrl_dic[key] = ctrl ctrl.Bind( wx.EVT_KEY_UP, 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, id, titlemsg ): wx.Dialog.__init__( self, parent, id, title=titlemsg ) MechList = [] for m in parent.ScoreServer.MechList.List: MechList.append( str(m.ID) + ": " + str(m.Name) ) self.MechText = wx.StaticText( self, -1, "Mech Selection:" ) self.MechChoice = wx.ListBox( self, -1, style=wx.LB_EXTENDED, choices=MechList ) self.CancelButton = wx.Button( self, wx.ID_CANCEL, "Cancel" ) self.OKButton = wx.Button( self, wx.ID_OK, "OK" ) TopSizer = wx.BoxSizer( wx.VERTICAL ) BtnSizer = wx.BoxSizer( wx.HORIZONTAL ) BtnSizer.Add( self.CancelButton, 0, wx.ALL, 5 ) BtnSizer.Add( self.OKButton, 0, wx.ALL, 5 ) TopSizer.Add( self.MechText, 0, wx.ALL, 5 ) TopSizer.Add( self.MechChoice, 0, wx.ALL, 5 ) TopSizer.Add( BtnSizer, 0, wx.ALL|wx.CENTER, 5 ) self.SetSizer( TopSizer ) TopSizer.Fit( self )
def create_page_buttons(self, sizer, panel): button_sizer = wx.BoxSizer(wx.HORIZONTAL) button_sizer.Add( self.create_button( panel=panel, key=['settings', 'ok_button'], bind=self.button_clicked, multiple=True)['item'], 0, wx.ALIGN_RIGHT) button_sizer.Add( self.create_button( panel=panel, key=['settings', 'apply_button'], bind=self.button_clicked, enabled=False, multiple=True)['item'], 0, wx.ALIGN_RIGHT) button_sizer.Add( self.create_button( panel=panel, key=['settings', 'cancel_button'], bind=self.button_clicked, multiple=True)['item'], 0, wx.ALIGN_RIGHT) sizer.Add(button_sizer, 0, wx.ALIGN_RIGHT | wx.ALL, 4)
def create_colour_picker(**kwargs): panel = kwargs.get('panel') value = kwargs.get('value') key = kwargs.get('key') bind = kwargs.get('bind') item_sizer = wx.BoxSizer(wx.HORIZONTAL) item_name = MODULE_KEY.join(key) colour_picker = CustomColourPickerCtrl() item_box = colour_picker.create(panel, value=value, event=bind, key=key) 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 create_dropdown(**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) choices = gui.get('choices', []) item_name = MODULE_KEY.join(key) item_text = wx.StaticText(panel, label=translate_key(item_name)) item_box = KeyChoice(panel, id=id_renew(item_name, update=True), keys=choices, choices=choices) item_box.Bind(wx.EVT_CHOICE, bind) item_box.SetSelection(choices.index(value)) item_sizer.Add(item_text, 0, wx.ALIGN_CENTER) item_sizer.Add(item_box) return {'item': item_sizer, 'text_size': item_text.GetSize()[0], 'text_ctrl': item_text}
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 __init__(self, parent): with iz.Dialog(init=self, title=u"Logon", orient=wx.VERTICAL, style=wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER): with iz.GridBagSizer(orient=wx.HORIZONTAL, proportion=1) as gb: # Defaults for StaticText and TextCtrl are normally border=0,proportion=0,flag=0. Change them temporarily # to avoid repeating the same options for each and every control: with iz.StaticText.Default(border=10), iz.TextCtrl.Default(border=10, proportion=1, flag=wx.EXPAND): # Now the sizer parameters can be omitted in the control definitions, since the defaults are # now appropriate. iz.StaticText(u"Username") self._name = iz.TextCtrl().wx iz.StaticText(u"Password", x=0) self._pass = iz.TextCtrl(style=wx.TE_PASSWORD).wx gb.AddGrowableCol(1) with iz.StdDialogButtonSizer(): okbut = iz.Button(u"OK", id=wx.ID_OK).wx iz.Button(u"Cancel", id=wx.ID_CANCEL) insp = iz.Button(u"Help", id=wx.ID_HELP,border=10, EVT_BUTTON=InspectionTool().Show).wx okbut.SetDefault() self.Fit()
def create_postorder(self): prev_x = prev_y = prev_xspan = prev_yspan = 0 for c in self.zchildren: x,y = c.x,c.y if x is None and y is None: x,y = prev_x,prev_y if self.orient == wx.HORIZONTAL: x += prev_xspan elif self.orient == wx.VERTICAL: y += prev_yspan else: raise TypeError('%s position unspecified' % (c,)) elif x is None: x = prev_x if y < prev_y + prev_yspan: x += 1 elif y is None: y = prev_y if x < prev_x + prev_xspan: y += 1 if c.border > 0 and (c.flag & wx.ALL)==0: c.flag |= wx.ALL c.sizer_item = self.w.Add(c.sized, (y,x), (c.yspan,c.xspan), c.flag, c.border) prev_x, prev_y, prev_xspan, prev_yspan = x,y,c.xspan,c.yspan
def __init__(self, *args, **kwargs): if 'size' not in kwargs: kwargs['size'] = (360, 240) super(NewRockTableDialog, self).__init__(*args, **kwargs) # ico = wx.Icon(r'./icons/plus32x32.ico', wx.BITMAP_TYPE_ICO) # self.SetIcon(ico) fgs = wx.BoxSizer(wx.HORIZONTAL) main_label = wx.StaticText(self, label="Fill up the cell below to create a new rock table.") name_label = wx.StaticText(self, label="Name Rock Table: ") # unit_label = wx.StaticText(self, label="Unidade: ") self.name_ctrl = wx.TextCtrl(self) # self.unit_ctrl = wx.TextCtrl(self) fgs.Add(name_label, 0, wx.EXPAND) fgs.Add(self.name_ctrl, 1, wx.EXPAND) # fgs.AddGrowableRow(0) sizer = wx.BoxSizer(wx.VERTICAL) button_sizer = self.CreateButtonSizer(wx.OK | wx.CANCEL) sizer.Add(main_label, 1, wx.GROW | wx.EXPAND) sizer.Add(fgs, 0, wx.EXPAND) sizer.Add(button_sizer, 0, wx.EXPAND) self.SetSizer(sizer) self.name_ctrl.SetFocus()
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 _on_right_click(self, event): """ Copies a cell into clipboard on right click. Unfortunately, determining the clicked column is not straightforward. This appraoch is inspired by the TextEditMixin in: /usr/lib/python2.7/dist-packages/wx-2.8-gtk2-unicode/wx/lib/mixins/listctrl.py More references: - http://wxpython-users.1045709.n5.nabble.com/Getting-row-col-of-selected-cell-in-ListCtrl-td2360831.html - https://groups.google.com/forum/#!topic/wxpython-users/7BNl9TA5Y5U - https://groups.google.com/forum/#!topic/wxpython-users/wyayJIARG8c """ if self.HitTest(event.GetPosition()) != wx.NOT_FOUND: x, y = event.GetPosition() row, flags = self.HitTest((x, y)) col_locs = [0] loc = 0 for n in range(self.GetColumnCount()): loc = loc + self.GetColumnWidth(n) col_locs.append(loc) scroll_pos = self.GetScrollPos(wx.HORIZONTAL) # this is crucial step to get the scroll pixel units unit_x, unit_y = self.GetMainWindow().GetScrollPixelsPerUnit() col = bisect(col_locs, x + scroll_pos * unit_x) - 1 value = self.df.iloc[row, col] # print(row, col, scroll_pos, value) clipdata = wx.TextDataObject() clipdata.SetText(str(value)) wx.TheClipboard.Open() wx.TheClipboard.SetData(clipdata) wx.TheClipboard.Close()
def __init__(self, parent, columns, df_list_ctrl, change_callback): wx.Panel.__init__(self, parent) columns_with_neutral_selection = [''] + list(columns) self.columns = columns self.df_list_ctrl = df_list_ctrl self.change_callback = change_callback self.num_filters = 10 self.main_sizer = wx.BoxSizer(wx.VERTICAL) self.combo_boxes = [] self.text_controls = [] for i in range(self.num_filters): combo_box = wx.ComboBox(self, choices=columns_with_neutral_selection, style=wx.CB_READONLY) text_ctrl = wx.TextCtrl(self, wx.ID_ANY, '') self.Bind(wx.EVT_COMBOBOX, self.on_combo_box_select) self.Bind(wx.EVT_TEXT, self.on_text_change) row_sizer = wx.BoxSizer(wx.HORIZONTAL) row_sizer.Add(combo_box, 0, wx.ALL, 5) row_sizer.Add(text_ctrl, 1, wx.ALL | wx.EXPAND | wx.ALIGN_RIGHT, 5) self.combo_boxes.append(combo_box) self.text_controls.append(text_ctrl) self.main_sizer.Add(row_sizer, 0, wx.EXPAND) self.SetSizer(self.main_sizer)
def __init__(self, parent, columns, df_list_ctrl): wx.Panel.__init__(self, parent) columns_with_neutral_selection = [''] + list(columns) self.columns = columns self.df_list_ctrl = df_list_ctrl self.figure = Figure(facecolor="white", figsize=(1, 1)) self.axes = self.figure.add_subplot(111) self.canvas = FigureCanvas(self, -1, self.figure) chart_toolbar = NavigationToolbar2Wx(self.canvas) self.combo_box1 = wx.ComboBox(self, choices=columns_with_neutral_selection, style=wx.CB_READONLY) self.Bind(wx.EVT_COMBOBOX, self.on_combo_box_select) row_sizer = wx.BoxSizer(wx.HORIZONTAL) row_sizer.Add(self.combo_box1, 0, wx.ALL | wx.ALIGN_CENTER, 5) row_sizer.Add(chart_toolbar, 0, wx.ALL, 5) sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add(self.canvas, 1, flag=wx.EXPAND, border=5) sizer.Add(row_sizer) self.SetSizer(sizer)
def __init__(self, parent, columns, df_list_ctrl): wx.Panel.__init__(self, parent) columns_with_neutral_selection = [''] + list(columns) self.columns = columns self.df_list_ctrl = df_list_ctrl self.figure = Figure(facecolor="white", figsize=(1, 1)) self.axes = self.figure.add_subplot(111) self.canvas = FigureCanvas(self, -1, self.figure) chart_toolbar = NavigationToolbar2Wx(self.canvas) self.combo_box1 = wx.ComboBox(self, choices=columns_with_neutral_selection, style=wx.CB_READONLY) self.combo_box2 = wx.ComboBox(self, choices=columns_with_neutral_selection, style=wx.CB_READONLY) self.Bind(wx.EVT_COMBOBOX, self.on_combo_box_select) row_sizer = wx.BoxSizer(wx.HORIZONTAL) row_sizer.Add(self.combo_box1, 0, wx.ALL | wx.ALIGN_CENTER, 5) row_sizer.Add(self.combo_box2, 0, wx.ALL | wx.ALIGN_CENTER, 5) row_sizer.Add(chart_toolbar, 0, wx.ALL, 5) sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add(self.canvas, 1, flag=wx.EXPAND, border=5) sizer.Add(row_sizer) self.SetSizer(sizer)
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 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 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 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 initCopy(self): copySizer = wx.BoxSizer(orient=wx.HORIZONTAL) copyControlBox = widgets.ControlBox(self, label='Copy Text', orient=wx.VERTICAL) self.copyTextCtrl = wx.TextCtrl(self) self.Bind(wx.EVT_TEXT, self.setCopyText, self.copyTextCtrl) self.offlineControls += [self.copyTextCtrl] copyControlBox.Add(self.copyTextCtrl, proportion=1, flag=wx.ALL | wx.EXPAND, border=10) copySizer.Add(copyControlBox, proportion=1, flag =wx.ALL | wx.EXPAND, border=10) self.sizer.Add(copySizer, proportion=0, flag=wx.EXPAND)
def initNTrial(self): trialSizer = wx.BoxSizer(orient=wx.HORIZONTAL) trialControlBox = widgets.ControlBox(self, label='Num Trials', orient=wx.VERTICAL) self.trialSpinCtrl = wx.SpinCtrl(self, #style=wx.SP_WRAP, value=str(self.pg.nTrials), min=1, max=100) self.Bind(wx.EVT_SPINCTRL, self.setNTrial, self.trialSpinCtrl) self.offlineControls += [self.trialSpinCtrl] trialControlBox.Add(self.trialSpinCtrl, proportion=1, flag=wx.ALL | wx.EXPAND, border=10) trialSizer.Add(trialControlBox, proportion=1, flag=wx.LEFT | wx.BOTTOM | wx.EXPAND, border=10) pauseControlBox = widgets.ControlBox(self, label='Pause Secs', orient=wx.VERTICAL) self.pauseFloatSpin = agwfs.FloatSpin(self, min_val=0.5, max_val=5.0, increment=0.5, value=self.pg.pause) self.pauseFloatSpin.SetFormat("%f") self.pauseFloatSpin.SetDigits(3) self.Bind(agwfs.EVT_FLOATSPIN, self.setPause, self.pauseFloatSpin) self.offlineControls += [self.pauseFloatSpin] pauseControlBox.Add(self.pauseFloatSpin, proportion=0, flag=wx.ALL | wx.EXPAND, border=12) trialSizer.Add(pauseControlBox, proportion=1, flag=wx.LEFT | wx.BOTTOM | wx.RIGHT | wx.EXPAND, border=10) self.sizer.Add(trialSizer, proportion=0, flag=wx.EXPAND)
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.LEFT | wx.BOTTOM | 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/40.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.LEFT | wx.BOTTOM | wx.RIGHT | wx.EXPAND, border=10) self.sizer.Add(intervalSizer, proportion=0, flag=wx.EXPAND)
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.LEFT | wx.BOTTOM | 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.LEFT | wx.BOTTOM | wx.RIGHT | wx.EXPAND, border=10) self.sizer.Add(windowSizer, proportion=0, flag=wx.EXPAND)
def initGridLayout(self): gridLayoutControlBox = widgets.ControlBox(self, label='Layout', orient=wx.VERTICAL) topSizer = wx.BoxSizer(orient=wx.HORIZONTAL) bottomSizer = wx.BoxSizer(orient=wx.HORIZONTAL) self.gridLayoutLowButton = wx.Button(self, label='Low') self.gridLayoutUppButton = wx.Button(self, label='Upp') self.gridLayoutNumButton = wx.Button(self, label='Num') self.gridLayoutEtcButton = wx.Button(self, label='Etc') self.gridLayoutSymButton = wx.Button(self, label='Sym') topSizer.Add(self.gridLayoutLowButton, proportion=0, flag=wx.TOP | wx.LEFT | wx.BOTTOM, border=10) self.Bind(wx.EVT_BUTTON, self.setGridLayoutLow, self.gridLayoutLowButton) topSizer.Add(self.gridLayoutUppButton, proportion=0, flag=wx.TOP | wx.BOTTOM, border=10) self.Bind(wx.EVT_BUTTON, self.setGridLayoutUpp, self.gridLayoutUppButton) topSizer.Add(self.gridLayoutNumButton, proportion=0, flag=wx.BOTTOM | wx.RIGHT | wx.TOP, border=10) self.Bind(wx.EVT_BUTTON, self.setGridLayoutNum, self.gridLayoutNumButton) bottomSizer.Add(self.gridLayoutEtcButton, proportion=0, flag=wx.LEFT | wx.BOTTOM, border=10) self.Bind(wx.EVT_BUTTON, self.setGridLayoutEtc, self.gridLayoutEtcButton) bottomSizer.Add(self.gridLayoutSymButton, proportion=0, flag=wx.RIGHT | wx.BOTTOM , border=10) self.Bind(wx.EVT_BUTTON, self.setGridLayoutSym, self.gridLayoutSymButton) gridLayoutControlBox.Add(topSizer, proportion=0, flag=wx.EXPAND) gridLayoutControlBox.Add(bottomSizer, proportion=0, flag=wx.EXPAND) self.sizer.Add(gridLayoutControlBox, 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 initFeatures(self): featureSizer = wx.BoxSizer(orient=wx.HORIZONTAL) spanControlBox = widgets.ControlBox(self, label='Welch Span', orient=wx.VERTICAL) self.spanFloatSpin = agwfs.FloatSpin(self, min_val=0.1, max_val=3.0, increment=0.05, value=self.pg.welchConfig.span) self.spanFloatSpin.SetFormat('%f') self.spanFloatSpin.SetDigits(3) self.Bind(agwfs.EVT_FLOATSPIN, self.setSpan, self.spanFloatSpin) self.cp.offlineControls += [self.spanFloatSpin] spanControlBox.Add(self.spanFloatSpin, proportion=1, flag=wx.ALL | wx.EXPAND, border=10) featureSizer.Add(spanControlBox, proportion=1, flag=wx.LEFT | wx.BOTTOM | wx.RIGHT | wx.EXPAND, border=10) # radio buttons for turning log transform on and off logTransControlBox = widgets.ControlBox(self, label='Log Trans', orient=wx.HORIZONTAL) logTransOnRbtn = wx.RadioButton(self, label='On', style=wx.RB_GROUP) self.Bind(wx.EVT_RADIOBUTTON, self.setLogTransOn, logTransOnRbtn) logTransControlBox.Add(logTransOnRbtn, proportion=0, flag=wx.ALL, border=10) self.cp.offlineControls += [logTransOnRbtn] logTransOffRbtn = wx.RadioButton(self, label='Off') self.Bind(wx.EVT_RADIOBUTTON, self.setLogTransOff, logTransOffRbtn) logTransControlBox.Add(logTransOffRbtn, proportion=0, flag=wx.ALL, border=10) self.cp.offlineControls += [logTransOffRbtn] if self.pg.welchConfig.logTrans: logTransOnRbtn.SetValue(True) else: logTransOffRbtn.SetValue(True) featureSizer.Add(logTransControlBox, proportion=1, flag=wx.BOTTOM | wx.RIGHT | wx.EXPAND, border=10) self.sizer.Add(featureSizer, proportion=0, flag=wx.EXPAND)
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 initRobot(self): # robot kind robotKindControlBox = widgets.ControlBox(self, label='Robot Kind', orient=wx.VERTICAL) self.robotKindComboBox = wx.ComboBox(self, value='ER1', style=wx.CB_READONLY, choices=('ER1', 'Baxter')) self.Bind(wx.EVT_COMBOBOX, self.setRobotKind, self.robotKindComboBox) self.offlineControls += [self.robotKindComboBox] robotKindControlBox.Add(self.robotKindComboBox, proportion=0, flag=wx.ALL | wx.EXPAND, border=10) self.sizer.Add(robotKindControlBox, proportion=0, flag=wx.ALL | wx.EXPAND, border=10) robotHostControlBox = widgets.ControlBox(self, label='Robot Hostname', orient=wx.HORIZONTAL) # robot host self.robotHostTextCtrl = wx.TextCtrl(parent=self, value='IP or host name') #self.robotHostTextCtrl.SetHint('IP or host name') # in next version of wxpython? XXX - idfah robotHostControlBox.Add(self.robotHostTextCtrl, proportion=1, flag=wx.ALL | wx.EXPAND, border=10) # robot connect button self.robotConnectButton = wx.Button(self, label='Connect') robotHostControlBox.Add(self.robotConnectButton, proportion=0, flag=wx.BOTTOM | wx.RIGHT | wx.TOP, border=10) self.Bind(wx.EVT_BUTTON, self.setRobotHost, self.robotConnectButton) self.sizer.Add(robotHostControlBox, proportion=0, flag=wx.LEFT | wx.BOTTOM | wx.RIGHT | wx.EXPAND, border=10)
def initLayout(self): sizer = wx.BoxSizer(orient=wx.HORIZONTAL) sizer.Add(self.selectorSizer, proportion=0, flag=wx.EXPAND) sizer.Add(self.configSizer, proportion=1, flag=wx.EXPAND) self.SetSizer(sizer) self.Layout()
def initTrialSecs(self): secsSizer = wx.BoxSizer(orient=wx.HORIZONTAL) trialSecsControlBox = widgets.ControlBox(self, label='Trial Secs', orient=wx.VERTICAL) self.trialSecsFloatSpin = agwfs.FloatSpin(self, min_val=0.25, max_val=50.0, increment=1/4.0, value=self.pg.trialSecs) self.trialSecsFloatSpin.SetFormat("%f") self.trialSecsFloatSpin.SetDigits(3) self.Bind(agwfs.EVT_FLOATSPIN, self.setTrialSecs, self.trialSecsFloatSpin) self.offlineControls += [self.trialSecsFloatSpin] trialSecsControlBox.Add(self.trialSecsFloatSpin, proportion=1, flag=wx.ALL | wx.EXPAND, border=10) secsSizer.Add(trialSecsControlBox, proportion=1, flag=wx.LEFT | wx.BOTTOM | wx.RIGHT | wx.EXPAND, border=10) itiSecsControlBox = widgets.ControlBox(self, label='Inter-Trial Secs', orient=wx.VERTICAL) self.itiFloatSpin = agwfs.FloatSpin(self, min_val=0.25, max_val=10.0, increment=1/4.0, value=self.pg.iti) self.itiFloatSpin.SetFormat("%f") self.itiFloatSpin.SetDigits(3) self.Bind(agwfs.EVT_FLOATSPIN, self.setITI, self.itiFloatSpin) self.offlineControls += [self.itiFloatSpin] itiSecsControlBox.Add(self.itiFloatSpin, proportion=1, flag=wx.ALL | wx.EXPAND, border=10) secsSizer.Add(itiSecsControlBox, 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='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)