def on_click(self, event): item = event.GetItem() selId = self.tree.GetItemData(item) fItem = team_search_Dict[selId] if fItem == '': return False if (('isFolder' in fItem.Origin) and (fItem.Origin['isFolder'] == True)): return False # 获取查询项ID item_id = fItem.NodeId # 获取数据 tasks = getTaskDetails(project['id'], item_id) self.data = GridData(tasks) # self.grid = wx.grid.Grid(self) # grid.ClearGrid() # global _init # if _init == True: # _init = False # grid.SetTable(self.data) # grid.AutoSize() # self.data.set_value(1, 0, "x") grid.Refresh()
def __init__(self, parent, vlist=[], ntitle="Values"): wx.Frame.__init__(self, parent, -1, ntitle, wx.DefaultPosition, wx.Size(400, 500)) global dir_path self.SetMenu() icon_path = os.path.join(dir_path, "Icon") self.icon = wx.Icon(os.path.join(icon_path, "Text.ico"), wx.BITMAP_TYPE_ICO) self.SetIcon(self.icon) wx.BeginBusyCursor() self.grid = grid = wx.Grid(self, -1) rtotal = len(vlist) try: ctotal = len(vlist[0]) except: ctotal = 1 grid.CreateGrid(rtotal, ctotal) grid.SetColLabelAlignment(wx.ALIGN_LEFT, wx.ALIGN_BOTTOM) row = 0 for val in vlist: col = 0 for set in val: grid.SetCellValue(row, col, str(set)) col += 1 row += 1 grid.AutoSizeRows() grid.Refresh() wx.EndBusyCursor()
def changeGrid(grid, data, colnames, rownames, oddcol="#f0f0f0", evencol="white"): if len(data) > 0: model = MinimalGridTableModel(len(data), len(data[0]), data, colnames, rownames, oddcol, evencol) grid.SetTable(model, True) grid.Refresh() grid.AutoSizeRows() grid.AutoSizeColumns() return grid
def ResetView(self): """ (Grid) -> Reset the grid view. Call this to update the grid if rows and columns have been added or deleted """ grid = self.grid current_rows = self.grid.GetNumberRows() current_cols = self.grid.GetNumberCols() grid.BeginBatch() for current, new, delmsg, addmsg in [ (current_rows, self.GetNumberRows(), wx.grid.GRIDTABLE_NOTIFY_ROWS_DELETED, wx.grid.GRIDTABLE_NOTIFY_ROWS_APPENDED), (current_cols, self.GetNumberCols(), wx.grid.GRIDTABLE_NOTIFY_COLS_DELETED, wx.grid.GRIDTABLE_NOTIFY_COLS_APPENDED) ]: if new < current: msg = wx.grid.GridTableMessage(self, delmsg, new, current - new) grid.ProcessTableMessage(msg) elif new > current: msg = wx.grid.GridTableMessage(self, addmsg, new - current) grid.ProcessTableMessage(msg) self.UpdateValues() grid.EndBatch() # Reset cell sizes to standard cell size grid.SetDefaultRowSize(grid.GetDefaultRowSize(), resizeExistingRows=True) grid.SetDefaultColSize(grid.GetDefaultColSize(), resizeExistingCols=True) # Adjust rows row_heights = grid.code_array.row_heights for key in row_heights: if key[1] == grid.current_table and \ key[0] < self.code_array.shape[0]: row = key[0] if row_heights[key] is None: # Default row size grid.SetRowSize(row, grid.GetDefaultRowSize()) else: grid.SetRowSize(row, row_heights[key]) # Adjust columns col_widths = grid.code_array.col_widths for key in col_widths: if key[1] == grid.current_table and \ key[0] < self.code_array.shape[1]: col = key[0] if col_widths[key] is None: # Default row size grid.SetColSize(col, grid.GetDefaultColSize()) else: grid.SetColSize(col, col_widths[key]) # update the scrollbars and the displayed part # of the grid grid.Freeze() grid.AdjustScrollbars() grid.Refresh() grid.Thaw()
def _data_changed(self): grid = self.GetView() flag = wx.grid.GRIDTABLE_REQUEST_VIEW_GET_VALUES msg = wx.grid.GridTableMessage(self, flag) grid.ProcessTableMessage(msg) grid.Refresh()
def _end_model_reset(self): grid = self.GetView() grid.SetTable(self) grid.Refresh()
def showSqlData(self,data,grid): table = MyDataTable(data[1],data[0]) grid.SetTable(table) grid.AutoSize() grid.Refresh()