def displayTodayData(self): gridSizer = wx.GridBagSizer(4, 4) self.grid = wx.grid.Grid(self) self.grid.CreateGrid(0, 6) self.grid.SetColLabelValue(0, u'员工编号') self.grid.SetColLabelValue(1, u'员工名') self.grid.SetColLabelValue(2, u'所属班组') self.grid.SetColLabelValue(3, u'备注') self.grid.SetColLabelValue(4, u'修改操作') self.grid.SetColLabelValue(5, u'删除操作') self.grid.HideCol(0) self.grid.HideCol(4) self.grid.HideCol(5) self.Bind(wx.grid.EVT_GRID_CELL_LEFT_CLICK, self.onCellChoosen, self.grid) controller = UserController() users = controller.getAllUser() groupController = GroupController() rows = list( map(lambda x: [x.userId, x.userName, groupController.getGroupName(x.userGroup), x.userDesc], users)) self.updateGrid(rows) self.grid.AutoSize() gridSizer.Add(self.grid, pos=(1, 1), span=(1, 1), flag=wx.EXPAND | wx.TOP | wx.RIGHT, border=15) self.vBox.Add(gridSizer, wx.ALIGN_BOTTOM | wx.ALIGN_LEFT, 10)
def refreshGrid(self): controller = UserController() users = controller.getAllUser() groupController = GroupController() rows = list( map(lambda x: [x.userId, x.userName, groupController.getGroupName(x.userGroup), x.userDesc], users)) self.updateGrid(rows) self.grid.AutoSize()
def insertSingleUserIntoGrid(self, user): self.grid.InsertRows(0, 1) self.grid.SetCellValue(0, 0, str(user.userId)) self.grid.SetCellValue(0, 1, user.userName) groupController = GroupController() self.grid.SetCellValue(0, 2, groupController.getGroupName(user.userGroup)) self.grid.SetCellValue(0, 3, user.userDesc) self.grid.SetCellValue(0, 4, u'修改') self.grid.SetCellValue(0, 5, u'删除') self.grid.AutoSize() self.vBox.Layout()