def setupGrid(self, grid, states, stateTypes): nStates = len(states) grid.SetDefaultColSize(70) grid.CreateGrid(nStates, nStates) for i in range(nStates): grid.SetRowLabelValue(i, states[i]) grid.SetColLabelValue(i, states[i]) grid.SetReadOnly(i, i) grid.SetCellBackgroundColour(i, i, wx.LIGHT_GREY) grid.SetCellTextColour(i, i, wx.LIGHT_GREY) if (stateTypes[i] == fluor.TO_ONLY): for j in range(nStates): grid.SetReadOnly(i, j) grid.SetCellBackgroundColour(i, j, wx.LIGHT_GREY) grid.SetCellTextColour(i, j, wx.LIGHT_GREY) if (stateTypes[i] == fluor.FROM_ONLY): for j in range(nStates): grid.SetReadOnly(j, i) grid.SetCellBackgroundColour(j, i, wx.LIGHT_GREY) grid.SetCellTextColour(j, i, wx.LIGHT_GREY) grid.SetMinSize(grid.BestSize)
def setupSplitterGrid(self): grid = self.gSplitter #grid.SetDefaultColSize(70) grid.CreateGrid(2, 4) grid.SetRowLabelValue(0, 'Spectral chan') grid.SetRowLabelValue(1, 'Z offset [nm]') #hard code some initial values z_offset, spec = self.sim_controller.z_offsets, self.sim_controller.spec_chans for i in range(4): grid.SetColLabelValue(i, 'Chan %d' % i) grid.SetCellValue(0, i, '%d' % spec[i]) grid.SetCellValue(1, i, '%3.2f' % z_offset[i])
def setupSplitterGrid(self): grid = self.gSplitter #grid.SetDefaultColSize(70) grid.CreateGrid(2, 4) grid.SetRowLabelValue(0, 'Spectral chan') grid.SetRowLabelValue(1, 'Z offset [nm]') #hard code some initial values spec = [0, 1, 1, 0] z_offset = [0, -200, 300., 500.] for i in range(4): grid.SetColLabelValue(i, 'Chan %d' % i) grid.SetCellValue(0, i, '%d' % spec[i]) grid.SetCellValue(1, i, '%3.2f' % z_offset[i])
def __init__(self): wx.Frame.__init__(self, None, title="Grid Headers", size=(500, 200)) grid = wx.grid.Grid(self) grid.CreateGrid(5, 5) for row in range(5): grid.SetRowLabelValue(row, self.rowLabels[row]) grid.SetColLabelValue(row, self.colLabels[row]) for col in range(5): grid.SetCellValue( row, col, "(%s,%s)" % (self.rowLabels[row], self.colLabels[col]))
def __init__(self): rowTitles = [u"第1行", u"第2行", u"第3行", u"第4行"] colTitles = [u"第1列", u"第2列", u"第3列", u"第4列"] wx.Frame.__init__(self, None, title=u"表格", size=(450, 160)) grid = wx.grid.Grid(self) # 定义表格控件 grid.CreateGrid(4, 4) for row in range(4): grid.SetRowLabelValue(row, rowTitles[row]) # 设置行标题 grid.SetColLabelValue(row, colTitles[row]) # 设置列标题 for col in range(4): grid.SetCellValue(row, col, str(col)) # 设置单元格的值
def __init__(self): rowtitle=[u'第1行',u'第2行',u'第3行',u'第4行',] coltitle=[u'第1列',u'第2列',u'第3列',u'第4列',] wx.Frame.__init__(self,None,title=u'表格',size=(450,500)) grid=wx.grid.Grid(self)#定义表格控件 grid.CreateGrid(4,4) for i in range(4): grid.SetRowLabelValue(i,rowtitle[i])#行标题 grid.SetColLabelValue(i,coltitle[i])#列标题 for j in range(4): grid.SetCellValue(i,j,str(j))#设置单元格的值
def buildmshidistance(snb, cog_p, inh_p, output1, input_v1): show_panel = snb.show_panel aa = ValidateDoubleLoop.outer_level_loop(cog_p, inh_p, output1, input_v1) yy = np.array(aa) y = yy[0] m = np.array(output1) n = len(m) d = ms.mashidistance(y, n, m) d1 = zi.Orang(d, len(d)) show_panel = snb.show_panel grid = snb.grid_out grid.CreateGrid(1, 13) grid.SetRowLabelValue(0, '马氏距离') grid.SetRowLabelAlignment(horiz=wx.ALIGN_TOP, vert=wx.ALIGN_TOP) for i in range(13): grid.SetColLabelValue(i, '%d' % (i + 1)) if (i < len(d)): grid.SetCellValue(0, i, str(round(d[i], 3))) axes = snb.axes axes2 = snb.axes2 canvas = snb.canvas canvas2 = snb.canvas2 axes.clear() # lpred, = axes.plot(y_pred, 'r', label='predict value') # ltest, = axes.plot(y_test, 'g', label='real value') print "========================" x = [] for i in range(len(d)): x.append(float(str(round(d[i], 8)))) print x print "========================" d = x axes.boxplot(d) axes.set(ylabel='Markov distance', title='Simulation of Markov distance') axes2.set(ylabel='Markov distance', title='data analysis') name_list = ['sum', 'var', '1/4', '3/4', 'median'] axes2.bar(range(len(d1)), d1, color='black', tick_label=name_list, width=0.6) # axes.legend(handles=[lpred, ltest], labels=['predict value', 'real value']) canvas.draw() canvas2.draw() show_panel.SetupScrolling() show_panel.Layout()
def __init__(self, td): wx.Frame.__init__(self, None, title="Grid Headers", size=(500, 200)) grid = wx.grid.Grid(self) grid.CreateGrid(5, 5) for row in range(5): grid.SetRowLabelValue(row, self.rowLabels[row]) grid.SetColLabelValue(row, self.colLabels[row]) for col in range(5): grid.SetCellValue( row, col, "(%s,%s)" % (self.rowLabels[row], self.colLabels[col])) grid.SetCellValue(0, 0, "shendi") grid.SetCellValue(0, 1, "12345.0") grid.SetCellValue(0, 2, "1") self.__grid = grid self.__td = td self.__td.RegTradeCallback(self.__OnTd)
def buildKLdistance(snb, cog_p, inh_p, output1, input_v1): aa = ValidateDoubleLoop.outer_level_loop(cog_p, inh_p, output1, input_v1) m = np.array(output1) # cankao y = np.array(aa) #fahgnzhen d = kl.KLdistanse(y, m) show_panel = snb.show_panel grid = snb.grid_out grid.CreateGrid(1, 13) grid.SetRowLabelValue(0, 'kl') grid.SetRowLabelAlignment(horiz=wx.ALIGN_TOP, vert=wx.ALIGN_TOP) for i in range(13): grid.SetColLabelValue(i, '%d' % (i + 1)) if (i < len(d)): grid.SetCellValue(0, i, str(round(d[i], 3))) show_panel.Layout() show_panel.SetupScrolling()
def __init__(self, parent, id, G): wx.Frame.__init__(self, parent, id, 'Breadboard', size=(1194, 250)) grid = wx.grid.Grid(self) grid.CreateGrid(10, 64) grid.SetRowLabelSize(22) grid.SetColMinimalAcceptableWidth(10) for row in range(10): t1 = chr(row + 97) grid.SetRowLabelValue(row, t1) for col in range(64): t2 = str(col + 1) t = t1 + t2 grid.SetColLabelValue(col, t2) grid.SetColSize(col, 18) grid.SetCellValue(row, col, t) grid.SetCellBackgroundColour(row, col, wx.CYAN) grid.SetReadOnly(row, col, isReadOnly=True) print "Right click where you want to start." grid.Bind(wx.grid.EVT_GRID_CELL_LEFT_CLICK, self.OnCellLeftClick) print G
def OnSize(self, evt): if self.GetAutoLayout(): self.Layout() #github test # Then we call CreateGrid to set the dimensions of the grid # (10 rows and 7 columns) grid.CreateGrid(10, 7) my_date = date.today() index = my_date.weekday() for i in range(0, 7): if index == 7: index = 0 grid.SetColLabelValue(i, calendar.day_name[index]) index = index + 1 time_label = 9 for i in range(0, 10): grid.SetRowLabelValue(i, (str(time_label) + ":00")) time_label = time_label + 1 # We can set the sizes of individual rows and columns # in pixels grid.SetRowSize(0, 60) grid.SetColSize(0, 120) # And set grid cell contents as strings grid.SetCellValue(0, 0, 'wxGrid is good') testString = "Hello" #Read from xml file # We can specify that some cells are read.only grid.SetCellValue(0, 3, testString) grid.SetReadOnly(0, 3) # We can specify the some cells will store numeric # values rather than strings. Here we set grid column 5 # to hold floating point values displayed with width of 6 # and precision of 2 grid.SetColFormatFloat(5, 6, 2) grid.SetCellValue(0, 6, '3.1415') self.Show()
def __init__(self, parent, id, TableTitle, row_headers, col_headers, data): wx.Frame.__init__(self, parent, id, title = TableTitle, size=(640,480)) # add icon self.SetIcon(parent.get_icon()) pane = wx.Panel(self, -1, style = wx.TAB_TRAVERSAL | wx.CLIP_CHILDREN) # mass table. Keep a reference for when the Peak Viewer uses this class grid = self.grid = wx.grid.Grid(pane, -1) grid.CreateGrid(len(row_headers), len(col_headers)) # Set row/column Headers for i,row in enumerate(row_headers): grid.SetRowLabelValue(i, row) dc = wx.MemoryDC() dc.SelectObject(wx.NullBitmap) grid.SetRowLabelSize(dc.GetTextExtent(max(row_headers, key=lambda r: len(r)))[0]) dc.Destroy() for i,col in enumerate(col_headers): grid.SetColLabelValue(i, col) # Print Data for row in range(len(row_headers)): for col in range(len(col_headers)): if data[row][col] is not None: grid.SetCellValue(row, col, "%0.2f" % data[row][col]) box = wx.BoxSizer() box.Add(grid, 1, wx.EXPAND|wx.ALL, 5) pane.SetSizerAndFit(box) w,h = self.GetSize() self.SetMinSize((w/2,h/2))
def __init__(self): wx.Frame.__init__(self, None, -1, "My Frame", size=(300, 300)) scrolledWindow = wx.ScrolledWindow(self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.HSCROLL | wx.VSCROLL) scrolledWindow.SetScrollRate(5, 5) bSizerScrolled = wx.BoxSizer(wx.VERTICAL) #panel = wx.Panel(self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.ALL|wx.EXPAND) panel = wx.Panel(scrolledWindow, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.ALL | wx.EXPAND) bSizerPanel = wx.BoxSizer(wx.VERTICAL) #scrolledWindow = wx.ScrolledWindow(panel, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.HSCROLL|wx.VSCROLL) #scrolledWindow.SetScrollRate(5, 5) #bSizerScrolled = wx.BoxSizer(wx.VERTICAL) bSizerText = wx.BoxSizer(wx.HORIZONTAL) panel.Bind(wx.EVT_MOTION, self.OnMove) #self.staticText = wx.StaticText(scrolledWindow, -1, "Pos:") self.staticText = wx.StaticText(panel, -1, "Pos:") bSizerText.Add(self.staticText, 0, wx.ALIGN_CENTER | wx.ALL, 5) #self.posCtrl = wx.TextCtrl(scrolledWindow, -1, "") self.posCtrl = wx.TextCtrl(panel, -1, "") bSizerText.Add(self.posCtrl, 0, wx.ALIGN_CENTER | wx.ALL, 5) #grid = wx.grid.Grid(scrolledWindow, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.ALL) grid = wx.grid.Grid(panel, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.ALL) grid.CreateGrid(5, 5) rowLabels = ["uno", "dos", "tres", "quatro", "cinco"] colLabels = ["one", "two", "three", "four", "five"] for row in range(5): grid.SetRowLabelValue(row, rowLabels[row]) for col in range(5): grid.SetColLabelValue(col, colLabels[col]) for row in range(5): for col in range(5): grid.SetCellValue(row, col, "(%s, %s)" % (row, col)) #bSizerScrolled.Add(bSizerText, 1, wx.ALIGN_CENTER|wx.ALL, 5) #bSizerScrolled.Add(grid, 1, wx.ALIGN_CENTER|wx.ALL, 5) #scrolledWindow.Layout() #scrolledWindow.SetSizer(bSizerScrolled) #bSizerScrolled.Fit(grid) bSizerPanel.Add(bSizerText, 1, wx.ALIGN_CENTER | wx.ALL, 5) bSizerPanel.Add(grid, 1, wx.ALIGN_CENTER | wx.ALL, 5) #bSizerPanel.Add(scrolledWindow, 1, wx.EXPAND|wx.ALL, 5) panel.SetSizer(bSizerPanel) bSizerScrolled.Add(panel, 1, wx.EXPAND | wx.ALL, 5) scrolledWindow.Layout() scrolledWindow.SetSizer(bSizerScrolled) bSizerScrolled.Fit(panel) #bSizerFrame.Add(panel, 1, wx.ALIGN_CENTER|wx.EXPAND|wx.ALL, 5) #self.SetSizer(bSizerFrame) self.Layout()
def InitUI(self): vbox = wx.BoxSizer(wx.VERTICAL) (server, group, item) = self.rulePath labelText = u"地址:{}.{}.{}".format(server, group, item) addressLabel = wx.StaticText(self, -1, label=labelText) font = wx.Font(10, wx.DEFAULT, wx.NORMAL, wx.NORMAL) addressLabel.SetFont(font) vbox.Add(addressLabel, flag=(wx.ALL | wx.ALIGN_CENTER | wx.BOTTOM), border=5) grid = wx.grid.Grid(self) grid.CreateGrid(6, 2) grid.SetDefaultRowSize(25) grid.SetColLabelValue(0, u"值") grid.SetColLabelValue(1, u"报警信息") grid.SetRowLabelValue(0, u'低低') grid.SetRowLabelValue(1, u'低') grid.SetRowLabelValue(2, u'高') grid.SetRowLabelValue(3, u'高高') grid.SetRowLabelValue(4, u'当') grid.SetRowLabelValue(5, u'间隔时间(分)') grid.SetRowLabelSize(70) # attr = wx.grid.GridCellAttr() # attr.SetEditor(wx.grid.GridCellChoiceEditor()) # attr.SetRenderer(wx.grid.GridCellChoiceEditor(['5', '15', '30', '60'], True)) grid.SetCellEditor(4, 0, wx.grid.GridCellChoiceEditor([u'真', u'假'], True)) grid.SetCellValue(4, 0, u'假') grid.SetCellEditor(5, 0, wx.grid.GridCellChoiceEditor(['5', '15', '30', '60'], True)) grid.SetCellValue(5, 0, '5') grid.SetColSize(0, 50) grid.SetColSize(1, 300) grid.SetDefaultCellAlignment(wx.ALIGN_CENTRE, wx.ALIGN_CENTRE) grid.SetCellValue(5, 1, u"当前温度:{}".format(self.itemValue[0])) grid.SetReadOnly(5, 1, True) vbox.Add(grid, proportion=1, flag=(wx.ALL | wx.ALIGN_CENTER)) btn = wx.Button(self, -1, label=u"确定") btn.Bind(wx.EVT_BUTTON, lambda event, grid=grid: self.btnClick(event, grid)) vbox.Add(btn, proportion=1, flag=(wx.TOP | wx.CENTRE), border=5) self.SetSizer(vbox) if self.rule.isBool: (dang1, dang2) = self.rule.dang interal = self.rule.interal grid.SetCellValue(4, 0, u'真' if dang1 else u'假') grid.SetCellValue(4, 1, dang2) grid.SetCellValue(5, 0, interal) else: (lower1, lower2) = self.rule.lower (low1, low2) = self.rule.low (high1, high2) = self.rule.high (higher1, higher2) = self.rule.higher interal = self.rule.interal grid.SetCellValue(0, 0, lower1) grid.SetCellValue(0, 1, lower2) grid.SetCellValue(1, 0, low1) grid.SetCellValue(1, 1, low2) grid.SetCellValue(2, 0, high1) grid.SetCellValue(2, 1, high2) grid.SetCellValue(3, 0, higher1) grid.SetCellValue(3, 1, higher2) grid.SetCellValue(5, 0, interal)
def __init__(self, parent, input_para): rect_parent = parent.GetRect() print rect_parent pos_target = rect_parent.GetTopRight() wx.Frame.__init__(self, parent, -1, "Resource Grid", pos=pos_target, size=(1000, 700)) panel = wx.Panel(self, -1) sizer_grid = wx.GridBagSizer(0, 0) usr_style = wx.ALIGN_CENTER_HORIZONTAL | wx.ALIGN_CENTER_VERTICAL grid = wx.grid.Grid(self, -1) grid.CreateGrid(12 * 2, 14) cell_width = 20 grid.DisableDragColSize() grid.DisableDragGridSize() grid.DisableDragRowSize() grid.SetRowLabelAlignment(wx.CENTER, wx.CENTER) clo_num = grid.GetNumberCols() row_num = grid.GetNumberRows() for i in range(0, row_num): grid.SetRowLabelValue(i, str(row_num - i - 1)) grid.AutoSizeRowLabelSize(i) grid.SetRowLabelSize(cell_width) grid.SetDefaultRowSize(cell_width) for j in range(0, clo_num): grid.SetColLabelValue(j, str(j)) grid.AutoSizeColLabelSize(j) grid.SetRowLabelSize(cell_width) grid.SetDefaultColSize(cell_width) grid.SetDefaultCellBackgroundColour(wx.Colour(192, 192, 192)) #pdcch for i in range(0, row_num): for j in range(0, clo_num): grid.SetReadOnly(i, j) if (j < input_para['pdcch_symbol']): grid.SetCellBackgroundColour(i, j, wx.GREEN) if ((int(grid.GetRowLabelValue(i)) - 1) % 4 == 0): grid.SetCellBackgroundColour(i, j, wx.Colour(66, 66, 111)) #pdsch for i in range(0, row_num): for j in range(input_para['start_symbol'], clo_num): if (j - input_para['start_symbol'] < input_para['symbol_length']): grid.SetCellBackgroundColour(i, j, wx.Colour(255, 255, 255)) #pdsch dmrs for j in range(0, len(input_para['dmrs_pos_list'])): for i in range(0, row_num): if input_para['dmrs_length'] == 0 and j == 0: grid.SetCellBackgroundColour( i, input_para['dmrs_pos_list'][j], wx.Colour(153, 204, 50)) continue if input_para['dmrs_length'] == 1 and (j == 1 or j == 0): grid.SetCellBackgroundColour( i, input_para['dmrs_pos_list'][j], wx.Colour(153, 204, 50)) continue else: grid.SetCellBackgroundColour( i, input_para['dmrs_pos_list'][j], wx.Colour(234, 234, 173)) sizer_grid.Add(grid, pos=(0, 0), span=(5, 5), flag=wx.EXPAND | usr_style) lbl_pdcch = wx.StaticText(self, -1, u' PDCCH ', style=usr_style) lbl_pdcch.SetBackgroundColour(wx.GREEN) sizer_grid.Add(lbl_pdcch, pos=(7, 0), span=(1, 1), flag=wx.EXPAND | usr_style) lbl_pdcch_dmrs = wx.StaticText( self, -1, u' PDCCH DMRS ', style=usr_style, ) lbl_pdcch_dmrs.SetBackgroundColour(wx.Colour(66, 66, 111)) lbl_pdcch_dmrs.SetForegroundColour(wx.Colour(255, 255, 255)) sizer_grid.Add( lbl_pdcch_dmrs, pos=(7, 1), span=(1, 1), flag=wx.EXPAND | usr_style, ) lbl_pdsch = wx.StaticText(self, -1, u' PDXCH ', style=usr_style) lbl_pdsch.SetBackgroundColour(wx.Colour(255, 255, 255)) lbl_pdsch.SetForegroundColour(wx.Colour(0, 0, 0)) sizer_grid.Add(lbl_pdsch, pos=(7, 2), span=(1, 1), flag=wx.EXPAND | usr_style) lbl_fl_dmrs = wx.StaticText(self, -1, u'Front Loaded DMRS', style=usr_style) lbl_fl_dmrs.SetBackgroundColour(wx.Colour(153, 204, 50)) lbl_fl_dmrs.SetForegroundColour(wx.Colour(255, 255, 255)) sizer_grid.Add(lbl_fl_dmrs, pos=(8, 0), span=(1, 1), flag=wx.EXPAND | usr_style) lbl_add_dmrs = wx.StaticText(self, -1, u'Add DMRS', style=usr_style) lbl_add_dmrs.SetBackgroundColour(wx.Colour(234, 234, 173)) lbl_add_dmrs.SetForegroundColour(wx.Colour(0, 0, 0)) sizer_grid.Add(lbl_add_dmrs, pos=(8, 1), span=(1, 1), flag=wx.EXPAND | usr_style) b_close = wx.Button(self, -1, "Close") self.Bind(wx.EVT_BUTTON, self.close_window, b_close) sizer_grid.Add(b_close, pos=(10, 0), span=(2, 5), flag=wx.EXPAND | usr_style) self.equal = b_close self.SetSizer(sizer_grid) sizer_grid.Fit(self) self.Show()
def __init__(self, soma, dend): """ creates a grid and fill it with AP kinetics from soma and dendrites Arguments: soma_AP -- Spike object for the soma dend_AP -- Spike object for the dendrite see Spike() class for more details """ # first check that both soma and dend are Spike() instances if not isinstance(soma, Spike) or not isinstance(dend, Spike): print('wrong argument, did you create a Spike object???') return 0 # initialize the wxframe wx.Frame.__init__(self, None, \ title = "AP parameters (from threshold)", size = (740,135)) # wxgrid columns self.col = [ "Threshold\n (mV/ms)", "Onset\n (ms)", "Onset\n (mV)", "Baseline\n (mV)", "AP Peak\n (mV)", "AP Peak\n (ms)", "Half-width\n (ms)", "Vmax\n (mV/ms)" ] # wxgrid rows self.row = ["Soma", "Dend", "latency"] # Grid grid = wx.grid.Grid(self) grid.CreateGrid(len(self.row), len(self.col)) # Set grid labels for i in range(len(self.col)): grid.SetColLabelValue(i, self.col[i]) for i in range(len(self.row)): grid.SetRowLabelValue(i, self.row[i]) # Create a list with the AP parameters for the dendrite somalist = [ soma.show_threshold(), soma.tonset, soma.thr, soma.base, soma.peak, soma.tpeak, soma.t50, soma.max_rise ] # Fill soma values in the grid for i in range(len(self.col)): grid.SetCellValue(0, i, "%.4f" % somalist[i]) # Create a list with the AP parameters for the dendrite dendlist = [ dend.show_threshold(), dend.tonset, dend.thr, dend.base, dend.peak, dend.tpeak, dend.t50, dend.max_rise ] # Fill dend values in the grid for i in range(len(self.col)): grid.SetCellValue(1, i, "%.4f" % dendlist[i]) # Calculate latencies with different methods # onset latency grid.SetCellValue(2, 1, "%.4f" % (dend.tonset - soma.tonset)) # peak latency grid.SetCellValue(2, 5, "%.4f" % (dend.tpeak - soma.tpeak)) # half-width latency grid.SetCellValue(2, 6, "%.4f" % (dend.t50_left - soma.t50_left))