def setup_grid(grid, title): """ This function only works with type wx.grid.Grid The it will create a grid that is like the one found in LinkCtrl/View. :param grid: :return: """ grid.CreateGrid(6, 2) grid.EnableEditing(False) grid.EnableGridLines(True) grid.SetGridLineColour(wx.Colour(0, 0, 0)) grid.EnableDragGridSize(False) # Columns grid.EnableDragColMove(False) grid.EnableDragColSize(True) grid.SetColLabelSize(0) grid.SetColLabelAlignment(wx.ALIGN_CENTER, wx.ALIGN_CENTER) grid.SetColSize(0, 110) # Rows grid.EnableDragRowSize(True) grid.SetRowLabelSize(0) grid.SetRowLabelAlignment(wx.ALIGN_CENTER, wx.ALIGN_CENTER) # Defaults grid.SetDefaultCellBackgroundColour(wx.Colour(255, 255, 255)) # white grid.SetDefaultCellAlignment(wx.ALIGN_LEFT, wx.ALIGN_TOP) # Set Cell Values grid.SetCellValue(0, 0, " %s" % title) grid.SetCellValue(1, 0, " Variable Name") grid.SetCellValue(2, 0, " Geometry Type") grid.SetCellValue(3, 0, " Geometry Count") grid.SetCellValue(4, 0, " Coordinate System") grid.SetCellValue(5, 0, " Spatial Extent") # set the default background color grid.SetDefaultCellBackgroundColour('WHITE') # change color and size of header grid.SetCellSize(0, 0, 1, 2) # span cols 0 and 1 grid.SetCellBackgroundColour(0, 0, wx.Colour(195, 195, 195)) # Grey # set the table column size grid.SetColSize(0, 133) grid.SetColSize(1, 155) # change color of properties for i in range(1, grid.GetNumberRows()): grid.SetCellBackgroundColour(i, 0, wx.Colour(250, 250, 250)) # light Grey grid.SetGridLineColour(wx.Colour(195, 195, 195))
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 draw_table(self, i, x, y): results = self.type_result[i] # size = self.ssize[i] size_of_par = self.size_of_par[i] grid = self.tables[i] grid.SetMaxSize(wx.Size(320, 360)) grid.SetMinSize(wx.Size(320, 360)) names = self.names[i] grid.CreateGrid(28, 13) grid.EnableEditing(True) grid.EnableGridLines(True) grid.EnableDragGridSize(False) grid.SetMargins(0, 0) # Columns grid.EnableDragColMove(False) grid.EnableDragColSize(True) grid.SetColLabelSize(30) grid.SetColLabelAlignment(wx.ALIGN_CENTRE, wx.ALIGN_CENTRE) i = 0 for namei in names: grid.SetColLabelValue(i, namei) i += 1 # 设置内容 # Rows grid.EnableDragRowSize(True) grid.SetRowLabelSize(80) grid.SetRowLabelAlignment(wx.ALIGN_CENTRE, wx.ALIGN_CENTRE) # Label Appearance # Cell Defaults grid.SetDefaultCellAlignment(wx.ALIGN_LEFT, wx.ALIGN_TOP) """"设置内容""" j = 0 for result in results: i = 0 for row in result: # 截段输出 numpy 抽样结果过长 grid.SetCellValue(i, j, str(("%.3f" % row))) i = i + 1 j += 1 self.gbSizer_show.Add(grid, wx.GBPosition(x, y), wx.GBSpan(1, 3), wx.ALL, 5) return y + size_of_par
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_grid(self, grid): # Grid grid.CreateGrid(7, 2) grid.EnableEditing(False) grid.EnableGridLines(True) grid.SetGridLineColour(wx.Colour(0, 0, 0)) grid.EnableDragGridSize(False) grid.SetMargins(0, 0) # Columns grid.EnableDragColMove(False) grid.EnableDragColSize(True) grid.SetColLabelSize(0) grid.SetColLabelAlignment(wx.ALIGN_CENTRE, wx.ALIGN_CENTRE) # Rows grid.EnableDragRowSize(True) grid.SetRowLabelSize(0) grid.SetRowLabelAlignment(wx.ALIGN_CENTRE, wx.ALIGN_CENTRE) # Label Appearance # Cell Defaults grid.SetDefaultCellBackgroundColour(wx.Colour(255, 255, 255)) grid.SetDefaultCellAlignment(wx.ALIGN_LEFT, wx.ALIGN_TOP) # Set Cell Values grid.SetCellValue(0, 0, " Variable") grid.SetCellValue(1, 0, " Name") grid.SetCellValue(2, 0, " Description") grid.SetCellValue(3, 0, " Unit") grid.SetCellValue(4, 0, " Name") grid.SetCellValue(5, 0, " Type") grid.SetCellValue(6, 0, " Abbreviation") grid.SetCellBackgroundColour(0, 0, wx.Colour(195, 195, 195)) grid.SetCellBackgroundColour(0, 1, wx.Colour(195, 195, 195)) grid.SetCellBackgroundColour(3, 0, wx.Colour(195, 195, 195)) grid.SetCellBackgroundColour(3, 1, wx.Colour(195, 195, 195)) grid.SetGridLineColour(wx.Colour(195, 195, 195)) self.resize_grid_to_fill_white_space(grid)
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()