def OnOpenLogcatClicked(self, event): if user_now == ID_WORKER_UNAVIABLE: wx.MessageBox(message="未检测到用户,请进行识别", caption="警告") else: self.loadDataBase(2) # 必须要变宽才能显示 scroll self.SetSize(980, 560) grid = wx.grid.Grid(self, pos=(320, 0), size=(640, 500)) grid.CreateGrid(100, 4) for i in range(100): for j in range(4): grid.SetCellAlignment(i, j, wx.ALIGN_CENTER, wx.ALIGN_CENTER) grid.SetColLabelValue(0, "序号") # 第一列标签 grid.SetColLabelValue(1, "姓名") grid.SetColLabelValue(2, "识别时间") grid.SetColLabelValue(3, "操作") grid.SetColSize(0, 120) grid.SetColSize(1, 120) grid.SetColSize(2, 150) grid.SetColSize(3, 150) grid.SetCellTextColour(1, 1, 'red') for i, id in enumerate(self.logcat_id): grid.SetCellValue(i, 0, str(id)) grid.SetCellValue(i, 1, self.logcat_name[i]) grid.SetCellValue(i, 2, self.logcat_datetime[i]) grid.SetCellValue(i, 3, self.logcat_late[i]) pass
def __init__(self, parent): wx.Frame.__init__(self, parent, title='Statistics') wtl = CsvTimeLogger() statistics = wtl.get_statistics() panel = wx.Panel(self) top_sizer = wx.BoxSizer(wx.VERTICAL) grid = wx.grid.Grid(self, -1) grid.CreateGrid(len(statistics), 2) # + 1 due to summary row at end grid.SetColLabelValue(0, "Day") grid.SetColLabelValue(1, "Worked") grid.SetRowLabelSize(0) for i, (k, v) in enumerate(statistics.items()): grid.SetCellValue(i, 1, format_timedelta(v)) grid.SetCellAlignment(i, 1, wx.ALIGN_RIGHT, wx.ALIGN_CENTER) if isinstance(k, dt.date): grid.SetCellValue(i, 0, k.strftime('%a %Y-%m-%d')) grid.SetCellAlignment(i, 0, wx.ALIGN_RIGHT, wx.ALIGN_CENTER) rel_extra_time = v.total_seconds() / dt.timedelta(hours=4).seconds grid.SetCellBackgroundColour(i, 1, get_color_red_white_blue(rel_extra_time)) else: grid.SetCellValue(i, 0, k) grid.AutoSize() top_sizer.Add(grid, 0, wx.CENTER) panel.SetSizer(top_sizer) top_sizer.Fit(self) self.Show()
def grid_setup(self): """Perform the initial setup and layout of the grid.""" # @type grid wx.grid.Grid grid = self.panel.gridExp #General settings #grid.SetSelectionMode(wx.grid.Grid.wxGridSelectRows) #Label width/height grid.SetColLabelSize(40) grid.SetRowLabelSize(40) #Find that the grid should be num_angles = len(model.instrument.inst.angles) num_cols = 4 + num_angles if grid.GetNumberCols() > num_cols: grid.DeleteCols(0, grid.GetNumberCols() - num_cols) if grid.GetNumberCols() < num_cols: grid.AppendCols(num_cols - grid.GetNumberCols()) #The column headers grid.SetColLabelValue(0, "Use?") grid.SetColSize(0, 50) #Column # of the criterion self.criterion_col = num_angles + 1 grid.SetColLabelValue(self.criterion_col, "Stopping\nCriterion") grid.SetColSize(self.criterion_col, 180) grid.SetColLabelValue(self.criterion_col + 1, "Criterion\nValue") grid.SetColSize(self.criterion_col + 1, 100) grid.SetColLabelValue(self.criterion_col + 2, "Comment") grid.SetColSize(self.criterion_col + 2, 120) for (i, anginfo) in enumerate(model.instrument.inst.angles): grid.SetColLabelValue( i + 1, anginfo.name + "\n(" + anginfo.friendly_units + ")") grid.SetColSize(i + 1, 100)
def OnOpenLogcatClicked(self, event): self.loadDataBase(2) self.SetSize(980, 560) grid = wx.grid.Grid(self, pos=(320, 0), size=(640, 500)) grid.CreateGrid(100, 4) for i in range(100): for j in range(4): grid.SetCellAlignment(i, j, wx.ALIGN_CENTER, wx.ALIGN_CENTER) grid.SetColLabelValue(0, "工号") #第一列标签 grid.SetColLabelValue(1, "姓名") grid.SetColLabelValue(2, "打卡时间") grid.SetColLabelValue(3, "是否迟到") grid.SetColSize(0, 120) grid.SetColSize(1, 120) grid.SetColSize(2, 150) grid.SetColSize(3, 150) grid.SetCellTextColour("NAVY") for i, id in enumerate(self.logcat_id): grid.SetCellValue(i, 0, str(id)) grid.SetCellValue(i, 1, self.logcat_name[i]) grid.SetCellValue(i, 2, self.logcat_datetime[i]) grid.SetCellValue(i, 3, self.logcat_late[i]) pass
def OnOpenRecordClicked(self, event): self.callDataBase(2) grid = wx.grid.Grid(self, pos=(320, 0), size=(600, 500)) grid.CreateGrid(100, 4) for i in range(100): for j in range(4): grid.SetCellAlignment(i, j, wx.ALIGN_CENTER, wx.ALIGN_CENTER) grid.SetColLabelValue(0, "学号") grid.SetColLabelValue(1, "姓名") grid.SetColLabelValue(2, "签到时间") grid.SetColLabelValue(3, "是否迟到") grid.SetColSize(0, 100) grid.SetColSize(1, 100) grid.SetColSize(2, 150) grid.SetColSize(3, 150) grid.SetCellTextColour("NAVY") for i, id in enumerate(self.Sign_Info_id): grid.SetCellValue(i, 0, str(id)) grid.SetCellValue(i, 1, self.Sign_Info_name[i]) grid.SetCellValue(i, 2, self.Sign_Info_time_info[i]) grid.SetCellValue(i, 3, self.Sign_Info_if_late[i]) pass
def set_grid_size(self, grid): grid.DisableDragRowSize() grid.DisableDragColSize() grid.SetColLabelValue(0, "NAME") grid.SetColLabelValue(1, "SCORE") for i in range(2): grid.SetRowSize(i, 30) grid.SetColSize(i, 120) grid.SetRowSize(2, 30)
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 populate_registerGrid(self, grid, registers): column_labels = ["name", "type", "isPointer", "read", "write"] for i, label in enumerate(column_labels): grid.SetColLabelValue(i,label) for i, reg in enumerate(registers.iteritems()): print reg grid.SetCellValue(i,0,reg[1].name)
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): #1 start grid.SetColLabelValue(row, self.colLabels[row]) #1 end grid.AppendRows() # panel=wx.Panel(self) # panel.SetBackgroundColour('White') # statusbar=self.CreateStatusBar() # # toolbar=self.CreateToolBar() # # toolbar.AddSimpleTool(wx.NewId(),images.getPyBitmap(), # # "New","Long help for 'New'") # # toolbar.Realize() # menuBar = wx.MenuBar() # menu1=wx.Menu() # menu1.Append(wx.NewId(),u"新字幕",u"新建一个字幕") # menu1.Append(wx.NewId(),u"打开字幕",u"打开一个字幕") # menu1.Append(wx.NewId(),u"保存字幕",u"保存一个字幕") # menuBar.Append(menu1,u"文件") # menu2=wx.Menu() # menu2.Append(wx.NewId(),u"撤销","Copy in status bar") # menu2.Append(wx.NewId(),u"复制","ctrl+c") # menu2.Append(wx.NewId(),u"粘贴","ctrl+v") # menu2.AppendSeparator() # menu2.Append(wx.NewId(),u"显示选项","Display Options") # menuBar.Append(menu2, u"编辑") # self.SetMenuBar(menuBar) # # print wx.grid.Grid.__doc__ # grid = wx.grid.Grid(self) # box = wx.BoxSizer(wx.HORIZONTAL) # box.Add(grid,0,wx.EXPAND) # grid.CreateGrid(5,5) # # print grid.CreateGrid.__doc__ # for row in range(5): # for col in range(5): # grid.SetCellValue(row, col, "(%s,%s)" % (row, col)) # grid.SetCellTextColour(1, 1, "red") # grid.SetCellFont(1,1, wx.Font(10, wx.SWISS, wx.NORMAL, wx.BOLD)) # grid.SetCellBackgroundColour(2, 2, "light blue") # attr = wx.grid.GridCellAttr() # attr.SetTextColour("navyblue") # attr.SetBackgroundColour("pink") # attr.SetFont(wx.Font(10, wx.SWISS, wx.NORMAL, wx.BOLD)) # grid.SetAttr(4, 0, attr) # grid.SetAttr(5, 1, attr) # grid.SetRowAttr(8, attr) # app = wx.PySimpleApp() # frame = TestFrame() # frame.Show() # app.MainLoop()
def __init__(self, parent): wx.Panel.__init__(self, parent, size=wx.DefaultSize) pnl2 = wx.lib.scrolledpanel.ScrolledPanel(self, 3, size=(1200, 500), pos=(10, 10), style=wx.SIMPLE_BORDER) pnl2.SetupScrolling() self.DueDateDatabase() self.sendsms() self.birthdaysms() conn = sqlite3.connect('MemberData.db') c = conn.cursor() c.execute('SELECT * FROM gym3') data = c.fetchall() conn.close() count = 0 for i in data: count += 1 grid = wx.grid.Grid(pnl2, -1) grid.CreateGrid(count, 8) grid.SetColSize(0, 120) grid.SetColSize(1, 200) grid.SetColSize(2, 150) grid.SetColSize(3, 150) grid.SetColSize(4, 120) grid.SetColSize(5, 120) grid.SetColSize(6, 150) grid.SetColLabelValue(0, "Enrollment No.") grid.SetColLabelValue(1, "Name") grid.SetColLabelValue(2, "Contact No.") grid.SetColLabelValue(3, "Residence No.") grid.SetColLabelValue(4, "Date of Joining") grid.SetColLabelValue(5, "Fee Paid") grid.SetColLabelValue(6, "Membership Time") grid.SetColLabelValue(7, "Status") z = -1 for i in data: z += 1 for j in range(0, 8): a = str(i[j]) grid.SetCellValue(z, j, a) grid.SetReadOnly(z, j) gbox = wx.BoxSizer() gbox.Add(grid, 1, wx.EXPAND) pnl2.SetSizer(gbox)
def __init__(self): wx.Dialog.__init__(self, None, -1, u'模板管理器', size=(500, 200)) #这里利用grid(其实用listCtrl就足够了,但是不会用--imageList的部分??) colLabels = [u'模板名', u'基本信息'] grid = wx.grid.Grid(self, -1, size=(500, 115)) grid.CreateGrid(len(data.column1), 2) grid.EnableEditing(False) #设置为不可编辑的状态 #设置表头 grid.SetColLabelValue(0, colLabels[0]) grid.SetColLabelValue(1, colLabels[1]) #设置表内容 ''' i = 0 while i < len(data.column1): grid.SetCellValue(i,0,data.column1[i]) grid.SetCellValue(i,1,data.column2[i]) ++i grid.AutoSizeColumns(setAsMin=True) ''' grid.SetCellValue(0, 0, data.column1[0]) grid.SetCellValue(0, 1, data.column2[0]) grid.SetCellValue(1, 0, data.column1[1]) grid.SetCellValue(1, 1, data.column2[1]) grid.AutoSizeColumns(setAsMin=True) grid.SetCellValue(2, 0, data.column1[2]) grid.SetCellValue(2, 1, data.column2[2]) grid.SetCellValue(3, 0, data.column1[3]) grid.SetCellValue(3, 1, data.column2[3]) #所有按钮 #NameButton = wx.Button(self,wx.ID_OK,u'更名',pos=(100,125)) NameButton = wx.Button(self, -1, u'更名', pos=(50, 125)) self.Bind(wx.EVT_BUTTON, self.OnName, NameButton) DeleteButton = wx.Button(self, -1, u'删除', pos=(150, 125)) self.Bind(wx.EVT_BUTTON, self.OnDelete, DeleteButton) AddButton = wx.Button(self, -1, u'新增', pos=(250, 125)) self.Bind(wx.EVT_BUTTON, self.OnAdd, AddButton) #这两个暂时没什么作用,也没绑定事件 CancelButton = wx.Button(self, wx.ID_CANCEL, u'取消', pos=(350, 125))
def __init__(self, parent, id, title, pos=wx.DefaultPosition, size=wx.DefaultSize, style=wx.DEFAULT_FRAME_STYLE, data=[], head=[], info=[]): wx.Frame.__init__(self, parent, id, title, pos, size, style) grid = wx.grid.Grid(self, -1) col = len(data[0]) row = len(data) colnum = len(head) inforownum = len(info) collen = [] for c in range(colnum): lmax = 0 for item in data: l = len(str(item[c])) if lmax < l: lmax = l l = len(str(head[c])) if lmax < l: lmax = l collen.append(lmax) grid.CreateGrid(row + inforownum, col) grid.SetRowSize(0, 30) for i, value in enumerate(collen): grid.SetColSize(i, value * 8 + 20) for i, item in enumerate(head): grid.SetColLabelValue(i, item) for irow, x in enumerate(data): for icol, item in enumerate(x): grid.SetCellValue(irow + inforownum, icol, str(item)) grid.SetReadOnly(irow + inforownum, icol) #设置头信息格 headstr = '' for item in info: headstr += item grid.SetCellSize(0, 0, inforownum, colnum) grid.SetCellValue(0, 0, headstr) self.Bind(wx.EVT_CLOSE, self.OnCloseWindow)
def CreateGrid(self, parent): grid = wx.grid.Grid(parent) grid.CreateGrid(len(list_jsj), len(list_jsj[0])) for row in range(len(list_jsj)): for col in range(len(list_jsj[row])): grid.SetColLabelValue(col, column_names[col]) grid.SetCellValue(row, col, list_jsj[row][col]) # 设置行和列自动调整 grid.AutoSize() return grid
def CreateGrid(self, parent): grid = wx.grid.Grid(parent) grid.CreateGrid(len(data), len(data[0])) for r in range(len(data)): for c in range(len(data[r])): grid.SetColLabelValue(c, column_names[c]) grid.SetCellValue(r, c, data[r][c]) grid.AutoSize() return grid
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 on_btn_refresh_click(self, event): data = utils.load_file()[-10:] # Create a wxGrid object fm = wx.Frame(self, -1, title='Log Info', size=(500, 300)) grid = wx.grid.Grid(fm, -1) grid.CreateGrid(len(data), 4) grid.SetColLabelValue(0, 'ID') grid.SetColLabelValue(1, 'Data') grid.SetColLabelValue(2, 'Nome') grid.SetColLabelValue(3, 'Mensagem') for row, x in enumerate(data): for col, value in enumerate(x): grid.SetCellValue(row, col, str(value)) grid.AutoSize() grid.AutoSizeColumn(3) fm.Centre() fm.Show()
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 OnOpenLogcatClicked(self, event): self.open_logcat.Enable(False) self.close_logcat.Enable(True) # 加载数据库 self.loadDataBase( 2) # 用一个列表返回数据库 不要赋值给self (data = xx.loadDataBase() ) # 必须要变宽才能显示 scroll self.SetSize(980, 560) grid = wx.grid.Grid(self, pos=(320, 0), size=(640, 500)) # 行数列数 grid.CreateGrid(100, 4) # 画水平与垂直线 for i in range(100): for j in range(4): grid.SetCellAlignment(i, j, wx.ALIGN_CENTER, wx.ALIGN_CENTER) # name of first row grid.SetColLabelValue(0, "工号") grid.SetColLabelValue(1, "姓名") grid.SetColLabelValue(2, "打卡时间") grid.SetColLabelValue(3, "是否迟到") # Size of each col grid.SetColSize(0, 120) grid.SetColSize(1, 120) grid.SetColSize(2, 150) grid.SetColSize(3, 150) grid.SetCellTextColour(wx.BLUE) for i, id in enumerate(self.logcat_id): grid.SetCellValue(i, 0, str(id)) grid.SetCellValue(i, 1, self.logcat_name[i]) grid.SetCellValue(i, 2, self.logcat_datetime[i]) grid.SetCellValue(i, 3, self.logcat_late[i]) grid.SetCellTextColour( i, 3, wx.RED ) if self.logcat_late[i] == '是' else grid.SetCellTextColour( i, 3, wx.GREEN) # Not allowed to edit grid.EnableEditing(False) pass
def CreateGrid(self, parent): grid = wx.grid.Grid(parent) grid.CreateGrid(len(data), len(data[0])) for row in range(len(data)): for col in range(len(data[row])): grid.SetColLabelValue(col, column_names[col]) grid.SetCellValue(row, col, data[row][col]) grid.AutoSize() return grid
def buidUISizer(self): flagsR = wx.CENTER hsizer = wx.BoxSizer(wx.HORIZONTAL) for _ in range(3): vSizer = wx.BoxSizer(wx.VERTICAL) # Row idx = 0 : show the PLC name/type and the I/O usage. nameLb = wx.StaticText(self, label="PLC Name: ".ljust(15)) self.nameLbList.append(nameLb) vSizer.Add(nameLb, flag=flagsR, border=2) vSizer.AddSpacer(10) gpioLbN = wx.StaticText(self, label="PLC I/O usage: ".ljust(15)) vSizer.Add(gpioLbN, flag=flagsR, border=2) self.gpioLbList.append(gpioLbN) vSizer.AddSpacer(10) vSizer.Add(wx.StaticLine(self, wx.ID_ANY, size=(180, -1), style=wx.LI_HORIZONTAL), flag=flagsR, border=2) vSizer.AddSpacer(10) # Row idx =1 : show the PLC data. grid = wx.grid.Grid(self, -1) grid.CreateGrid(8, 4) grid.SetRowLabelSize(30) grid.SetColLabelSize(22) grid.SetColSize(0, 40) grid.SetColSize(1, 40) grid.SetColSize(2, 40) grid.SetColSize(3, 40) # Set the column label. grid.SetColLabelValue(0, 'IN') grid.SetColLabelValue(1, 'Val') grid.SetColLabelValue(2, 'OUT') grid.SetColLabelValue(3, 'Val') vSizer.Add(grid, flag=flagsR, border=2) self.gridList.append(grid) hsizer.Add(vSizer, flag=flagsR, border=2) hsizer.AddSpacer(5) return hsizer
def InitializeComponents(self): grid = wx.grid.Grid(self) grid.CreateGrid(5, 2) # Set column labels. grid.SetColLabelValue(0, "Title") grid.SetColLabelValue(1, "URL") # Set cell values. grid.SetCellValue(0, 0, "Google") grid.SetCellValue(0, 1, "http://google.com/") grid.SetCellValue(1, 0, "Yahoo! JAPAN") grid.SetCellValue(1, 1, "http://www.yahoo.co.jp/") grid.SetCellValue(2, 0, "Python") grid.SetCellValue(2, 1, "http://www.python.org/") grid.SetCellValue(3, 0, "Python Documentation") grid.SetCellValue(3, 1, "http://docs.python.org/") grid.SetCellValue(4, 0, "wxPython") grid.SetCellValue(4, 1, "http://www.wxpython.org/") # Alignment. grid.AutoSize()
def __init__(self, parent): wx.Panel.__init__(self, parent) font = wx.Font(wx.FONTSIZE_MEDIUM, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL) lbl1 = wx.StaticText(self, -1, "Legacy* : ", pos=(50, 50)) self.txt_lgy = wx.TextCtrl(self, id=wx.ID_ANY, pos=(140, 45), size=(200, 25)) btn_chk1 = wx.Button(self, -1, label="Check", pos=(360, 45)) lbl2 = wx.StaticText(self, -1, "Deflections : ", pos=(50, 100)) self.txt_lgy = wx.TextCtrl(self, id=wx.ID_ANY, pos=(140, 90), size=(200, 25)) btn_chk1 = wx.Button(self, -1, label="Check", pos=(360, 90)) lbl3 = wx.StaticText(self, -1, "PLOTING AREA*", pos=(500, 45)) lbl3.SetFont(font) vbox = wx.BoxSizer(wx.VERTICAL) plot_graph = wx.Panel(self, 1, name='PLOTING AREA*', pos=(500, 70), size=(650, 450)) plot_graph.SetBackgroundColour('#ededed') vbox.Add(plot_graph, wx.ID_ANY, wx.EXPAND) plot_graph.SetSizer(vbox) lbl4 = wx.StaticText(self, -1, "Deflections ", pos=(50, 180)) lbl4.SetFont(font) list_panel = wx.Panel(self, 1, name='Deflections', pos=(50, 200), size=(200, 200)) list_panel.SetBackgroundColour('#ededed') lst = wx.ListBox(list_panel, 1, style=wx.LB_DEFAULT, name='Deflections', pos=(50, 200), size=(200, 200)) btn_ppmeter = wx.Button(self, -1, label="Plot Parameters", pos=(270, 250)) lbl5 = wx.StaticText(self, -1, 'Scaling Deflections*', pos=(50, 450)) lbl5.SetFont(font) grid = wx.grid.Grid(self, 1, name='Scaling Deflections*', pos=(50, 475), size=(325, 110)) grid.CreateGrid(4, 2) # grid.HideRowLabels() grid.SetColLabelValue(0, 'Stage') grid.SetColLabelValue(1, 'Scaling') grid.SetColSize(0, 120) grid.SetColSize(1, 120)
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 CreateGrid(self, parent): grid = wx.grid.Grid(parent) grid.CreateGrid(len(data), len(data[0])) for r in range(len(data)): for c in range(len(data[r])): grid.SetColLabelValue(c, column_names[c]) grid.SetCellValue(r, c, data[r][c]) # if r % 2 == 0: # grid.SetCellBackgroundColour(r, c, "SEA green") # else: # grid.SetCellBackgroundColour(r, c, "SLATE blue") grid.AutoSize() return grid
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 getBranchesInArea(self, event): AreaClicked = event.GetString() branchesInAreaDF = self.__mutualMet.getAllBranchesInArea( self.__city.GetValue(), AreaClicked) branchesFrame = wx.Frame(None, -1, title="branches in area: " + AreaClicked, size=(500, 300)) grid = wx.grid.Grid(branchesFrame, -1) numOfColumns = branchesInAreaDF.shape[1] numOfRows = branchesInAreaDF.shape[0] grid.CreateGrid(numOfRows, numOfColumns) #set the dimensions of the grid grid.SetColLabelValue(0, "Chain Name") grid.SetColLabelValue(1, "Branch Name") for rowNum in range(numOfRows): for colNum in range(numOfColumns): grid.SetRowSize(rowNum, 50) grid.SetColSize(colNum, 200) cellString = branchesInAreaDF.iloc[rowNum][colNum].decode( 'cp1255', 'strict') grid.SetCellValue(rowNum, colNum, cellString) grid.SetReadOnly(rowNum, colNum) branchesFrame.Show()
def InitUI(self): panel = wx.Panel(self) font = wx.SystemSettings_GetFont(wx.SYS_SYSTEM_FONT) font.SetPointSize(9) vbox = wx.BoxSizer(wx.VERTICAL) grid = wx.grid.Grid(panel) grid.CreateGrid(10, 4) grid.SetColLabelValue(0, "IP") grid.SetColLabelValue(1, "Port") grid.SetColLabelValue(2, "LoginName") grid.SetColLabelValue(3, "Password") grid.SetDefaultColSize(160, resizeExistingCols=True) for row in range(10): for col in range(4): grid.SetCellValue(row, col, "cell (%d,%d)" % (row, col)) vbox.Add(grid, proportion=1, flag=wx.ALIGN_CENTER | wx.ALL, border=10) btn = wx.Button(panel, label='Detect') vbox.Add(btn, proportion=0, flag=wx.ALIGN_CENTER | wx.ALL, border=10) panel.SetSizer(vbox)
def on_saveButton(self, event, grid): """saves any editing of the grid but does not continue to the next window""" wait = wx.BusyInfo("Please wait, working...") wx.SafeYield() if self.grid_frame.drop_down_menu: # unhighlight selected columns, etc. self.grid_frame.drop_down_menu.clean_up() # remove '**' and '^^' from col labels starred_cols, hatted_cols = grid.remove_starred_labels() grid.SaveEditControlValue() # locks in value in cell currently edited grid.HideCellEditControl() # removes focus from cell that was being edited if grid.changes: self.onSave(grid) for col in starred_cols: label = grid.GetColLabelValue(col) grid.SetColLabelValue(col, label + '**') for col in hatted_cols: label = grid.GetColLabelValue(col) grid.SetColLabelValue(col, label + '^^') del wait
def CreateGrid(self, parent): grid = wx.grid.Grid(parent) grid.CreateGrid(len(data), len(data[0])) for r in range(len(data)): for c in range(len(data[r])): grid.SetColLabelValue(c, column_names[c]) grid.SetCellValue(r, c, data[r][c]) grid.SetCellAlignment(r, c, wx.ALIGN_CENTRE, wx.ALIGN_CENTRE) font = wx.Font(10, wx.SWISS, wx.NORMAL, wx.BOLD, False) grid.SetCellFont(r, c, font) if r % 2 == 0: grid.SetCellBackgroundColour(r, c, "SEA green") else: grid.SetCellBackgroundColour(r, c, "SLATE blue") grid.AutoSize() return grid