Python wx.grid() Examples
The following are 30
code examples of wx.grid().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
wx
, or try the search function
.
Example #1
Source File: MakeTorrent.py From BitTorrent with GNU General Public License v3.0 | 6 votes |
def __init__(self, parent, nodelist): Grid.__init__(self, parent, style=wx.WANTS_CHARS) self.CreateGrid( 0, 2, wx.grid.Grid.SelectRows) self.SetColLabelValue(0, _("Host")) self.SetColLabelValue(1, _("Port")) self.SetColRenderer(1, wx.grid.GridCellNumberRenderer()) self.SetColEditor(1, wx.grid.GridCellNumberEditor(0, 65535)) self.SetColLabelSize(self.GetTextExtent("l")[1]+4) self.SetRowLabelSize(1) self.SetSize((1000,1000)) self.storing = False self.Bind(wx.grid.EVT_GRID_CMD_CELL_CHANGE, self.store_value) self.append_node(('router.bittorrent.com', '65536')) for i, e in enumerate(nodelist.split(',')): host, port = e.split(':') self.append_node((host,port)) self.append_node(('',''))
Example #2
Source File: PDFjoiner.py From PyMuPDF-Utilities with GNU General Public License v3.0 | 6 votes |
def DuplicateRow(self, row): grid = self.GetView() if grid: zeile = [self.data[row][0], self.data[row][1], self.data[row][2], self.data[row][3], self.data[row][4]] self.data.insert(row, zeile) grid.BeginBatch() msg = gridlib.GridTableMessage( self, gridlib.GRIDTABLE_NOTIFY_ROWS_INSERTED, row, 1) grid.ProcessTableMessage(msg) grid.EndBatch() #============================================================================== # Remove a row #==============================================================================
Example #3
Source File: edit_windows.py From wxGlade with MIT License | 6 votes |
def wxname2attr(self, name): """Return the attribute specified by the name. Only wx attributes are supported. Example:: >>> self.wxname2attr('wx.version') <function version at 0x2cc6398> >>> self.wxname2attr('wx.VERSION') (2, 8, 12, 1, '') note: Exceptions especially NameError and AttributeError aren't caught.""" assert name.startswith('wx') #cn = self.codegen.get_class(self.codegen.cn(name)) cn = self.codegen.cn(name) namespace, cn = cn.rsplit(".",1) if namespace=="wx": import wx return getattr(wx, cn) if namespace=="wx.propgrid": import wx.propgrid return getattr(wx.propgrid, cn) if namespace=="wx.grid": import wx.grid return getattr(wx.propgrid, cn) raise ValueError("namespace %s not implemented"%namespace)
Example #4
Source File: commondialogs.py From CANFestivino with GNU Lesser General Public License v2.1 | 6 votes |
def _updateColAttrs(self, grid): """ wx.grid.Grid -> update the column attributes to add the appropriate renderer given the column name. Otherwise default to the default renderer. """ for row in range(self.GetNumberRows()): for col in range(self.GetNumberCols()): editor = wx.grid.GridCellTextEditor() renderer = wx.grid.GridCellStringRenderer() grid.SetReadOnly(row, col, self.Parent.Editable) grid.SetCellEditor(row, col, editor) grid.SetCellRenderer(row, col, renderer) grid.SetCellBackgroundColour(row, col, wx.WHITE)
Example #5
Source File: _sqlgrid.py From admin4 with Apache License 2.0 | 6 votes |
def Delete(self, rows): """ Delete(rows) expects rows in reverse sorted order """ query=pgQuery(self.tableSpecs.tabName, self.tableSpecs.GetCursor()) all=[] for row in rows: wh=[] for colname in self.tableSpecs.keyCols: wh.append("%s=%s" % (quoteIdent(colname), quoteValue(self.rows[row][colname]))) all.append("(%s)" % " AND ".join(wh)) query.AddWhere("\n OR ".join(all)) rc=query.Delete() self.grid.Freeze() self.grid.BeginBatch() for row in rows: self.grid.DeleteRows(row, 1, True) # msg=wx.grid.GridTableMessage(self, wx.grid.GRIDTABLE_NOTIFY_ROWS_APPENDED) self.grid.EndBatch() self.grid.ForceRefresh() self.grid.Thaw() return rc
Example #6
Source File: EtherCATManagementEditor.py From OpenPLC_Editor with GNU General Public License v3.0 | 6 votes |
def CreateSyncManagerTable(self): """ Create grid for "SyncManager" """ # declare Table object self.SyncManagersTable = SyncManagersTable(self, [], GetSyncManagersTableColnames()) self.SyncManagersGrid.SetTable(self.SyncManagersTable) # set grid alignment attr. (CENTER) self.SyncManagersGridColAlignements = [wx.ALIGN_CENTRE, wx.ALIGN_CENTRE, wx.ALIGN_CENTRE, wx.ALIGN_CENTRE, wx.ALIGN_CENTRE, wx.ALIGN_CENTRE] # set grid size self.SyncManagersGridColSizes = [40, 150, 100, 100, 100, 100] self.SyncManagersGrid.SetRowLabelSize(0) for col in range(self.SyncManagersTable.GetNumberCols()): attr = wx.grid.GridCellAttr() attr.SetAlignment(self.SyncManagersGridColAlignements[col], wx.ALIGN_CENTRE) self.SyncManagersGrid.SetColAttr(col, attr) self.SyncManagersGrid.SetColMinimalWidth(col, self.SyncManagersGridColSizes[col]) self.SyncManagersGrid.AutoSizeColumn(col, False) self.RefreshSlaveInfos()
Example #7
Source File: PDFoutline.py From PyMuPDF-Utilities with GNU General Public License v3.0 | 6 votes |
def OnIdle(self, evt): dlg = self.GetParent() if self.do_title: # did title changes happen? self.AutoSizeColumn(1) # resize title column w1 = max(self.GetEffectiveMinSize()[0], dlg.minwidth) w2 = dlg.PDFbild.Size[0] h = dlg.Size[1] dlg.Size = wx.Size(w1 + w2 + 60, h) dlg.Layout() # adjust the grid self.do_title = False if self.bookmark > 0: # did height changes happen? self.GetTable().SetValue(self.bookmark_row, 3, self.bookmark) self.Table.data[self.bookmark_row][3] = self.bookmark spad.oldpage = 0 # make sure page re-display PicRefresh(dlg, self.bookmark_page) self.bookmark = -1 if (time.clock() - spad.lastsave) > 60.0 and spad.lastsave >= 0.0: dlg.auto_save() evt.Skip() #============================================================================== # Event Method: cell is changing #==============================================================================
Example #8
Source File: PDFoutline.py From PyMuPDF-Utilities with GNU General Public License v3.0 | 6 votes |
def OnCellDClick(self, evt): row = evt.GetRow() # row col = evt.GetCol() # col dlg = self.GetParent() seite = self.GetTable().GetValue(row, 2) # make sure page is displayed PicRefresh(dlg, seite) if col != 3: # further handling only for height col evt.Skip() return self.bookmark_page = self.GetTable().GetValue(row, 2) # store page no self.bookmark_row = row # store grid row self.MakeCellVisible(row, col) h = self.GetTable().GetValue(row, 3) # get current height value h = max(int(h), 1) # should be > 0 maxh = spad.height # maxh is page height d = Slider(self, h, maxh) # create slider dialog d.ShowModal() # show it self.bookmark = d.slider.GetValue() # extract & store value evt.Skip() return #============================================================================== # Event Method: move row #==============================================================================
Example #9
Source File: recipe-580622.py From code with MIT License | 6 votes |
def DuplicateRow(self, row): grid = self.GetView() if grid: zeile = [self.data[row][0], self.data[row][1], self.data[row][2], self.data[row][3], self.data[row][4]] self.data.insert(row, zeile) grid.BeginBatch() msg = gridlib.GridTableMessage( self, gridlib.GRIDTABLE_NOTIFY_ROWS_INSERTED, row, 1) grid.ProcessTableMessage(msg) grid.EndBatch() #============================================================================== # Remove a row #==============================================================================
Example #10
Source File: EtherCATManagementEditor.py From OpenPLC_Editor with GNU General Public License v3.0 | 6 votes |
def OnButtonXmlToEEPROMImg(self, event): """ Create EEPROM data based XML data that current imported Binded to 'XML to EEPROM' button. @param event : wx.EVT_BUTTON object """ self.SiiBinary = self.Controler.CommonMethod.XmlToEeprom() self.HexCode, self.HexRow, self.HexCol = self.Controler.CommonMethod.HexRead(self.SiiBinary) self.UpdateSiiGridTable(self.HexRow, self.HexCol) self.SiiGrid.SetValue(self.HexCode) self.SiiGrid.Update() # ------------------------------------------------------------------------------- # For Hex View grid (fill hex data) # -------------------------------------------------------------------------------
Example #11
Source File: EtherCATManagementEditor.py From OpenPLC_Editor with GNU General Public License v3.0 | 6 votes |
def __init_data(self): """ Declare initial data. """ # flag for compact view self.CompactFlag = False # main grid의 rows and cols self.MainRow = [512, 512, 512, 512] self.MainCol = 4 # main grids' data range self.PageRange = [] for index in range(4): self.PageRange.append([512*index, 512*(index+1)]) # Previous value of register data for register description configuration self.PreRegSpec = {"ESCType": "", "FMMUNumber": "", "SMNumber": "", "PDIType": ""}
Example #12
Source File: EtherCATManagementEditor.py From OpenPLC_Editor with GNU General Public License v3.0 | 6 votes |
def __init__(self, parent, row, col, controler): """ Constructor @param parent: RegisterNotebook object @param row, col: size of the table @param controler: _EthercatSlaveCTN class in EthercatSlave.py """ self.parent = parent self.Data = {} self.Row = row self.Col = col self.Controler = controler self.RegisterAccessPanel = self.parent.parent.parent wx.grid.Grid.__init__(self, parent, -1, size=(820, 300), style=wx.EXPAND | wx.ALIGN_CENTRE_HORIZONTAL | wx.ALIGN_CENTER_VERTICAL) for evt, mapping_method in [(wx.grid.EVT_GRID_CELL_LEFT_CLICK, self.OnSelectCell), (wx.grid.EVT_GRID_CELL_LEFT_CLICK, self.OnSelectCell), (wx.grid.EVT_GRID_CELL_LEFT_DCLICK, self.OnRegModifyDialog)]: self.Bind(evt, mapping_method)
Example #13
Source File: mounting.py From kicad_mmccoo with Apache License 2.0 | 6 votes |
def AddOption(self, size, lib, foot): s = wx.SpinCtrlDouble(self.grid, value=str(size), inc=0.1) self.gridSizer.Add(s) print("lib {} foot {}".format(lib, foot)) l = wx.StaticText(self.grid, label=lib) self.gridSizer.Add(l, proportion=1) f = wx.StaticText(self.grid, label=foot) self.gridSizer.Add(f, proportion=1) b = wx.Button(self.grid, label="remove") self.gridSizer.Add(b) b.Bind(wx.EVT_BUTTON, self.OnRemove) self.therows[b.GetId()] = (s,l,f,b)
Example #14
Source File: recipe-580623.py From code with MIT License | 6 votes |
def NewRow(self, zeile): grid = self.GetView() if grid: if self.cur_row in range(len(self.data)): # insert in the middle? self.data.insert(self.cur_row, zeile) grid.BeginBatch() # inform the grid msg = gridlib.GridTableMessage(self, gridlib.GRIDTABLE_NOTIFY_ROWS_INSERTED, self.cur_row, 1) grid.ProcessTableMessage(msg) grid.EndBatch() else: # insert at end (append) self.data.append(zeile) grid.BeginBatch() # inform grid msg = gridlib.GridTableMessage(self, gridlib.GRIDTABLE_NOTIFY_ROWS_APPENDED, 1) grid.ProcessTableMessage(msg) grid.EndBatch() #============================================================================== # Duplicate a row, called with row number #==============================================================================
Example #15
Source File: ConfigEditor.py From OpenPLC_Editor with GNU General Public License v3.0 | 6 votes |
def _updateColAttrs(self, grid): """ wx.grid.Grid -> update the column attributes to add the appropriate renderer given the column name. Otherwise default to the default renderer. """ for row in range(self.GetNumberRows()): for col in range(self.GetNumberCols()): editor = None renderer = None colname = self.GetColLabelValue(col, False) if colname in ["Name", "Description"]: editor = wx.grid.GridCellTextEditor() renderer = wx.grid.GridCellStringRenderer() grid.SetReadOnly(row, col, False) else: grid.SetReadOnly(row, col, True) grid.SetCellEditor(row, col, editor) grid.SetCellRenderer(row, col, renderer) self.ResizeRow(grid, row)
Example #16
Source File: recipe-580623.py From code with MIT License | 6 votes |
def pdf_show(seite): page_idx = getint(seite) - 1 pix = PDFcfg.doc.getPagePixmap(page_idx, matrix = scaling) # the following method returns just RGB data - no alpha bytes # this seems to be required in Windows versions of wx. # on other platforms try instead: #bmp = wx.BitmapfromBufferRGBA(pix.w, pix.h, pix.samples) a = pix.samplesRGB() # samples without alpha bytes bmp = wx.BitmapFromBuffer(pix.w, pix.h, a) pix = None a = None return bmp #============================================================================== # PDFTable = a tabular grid class in wx #==============================================================================
Example #17
Source File: ConfigEditor.py From OpenPLC_Editor with GNU General Public License v3.0 | 6 votes |
def _updateColAttrs(self, grid): """ wx.grid.Grid -> update the column attributes to add the appropriate renderer given the column name. Otherwise default to the default renderer. """ for row in range(self.GetNumberRows()): for col in range(self.GetNumberCols()): editor = None renderer = None colname = self.GetColLabelValue(col, False) if colname in ["Position", "Value"]: editor = wx.grid.GridCellNumberEditor() renderer = wx.grid.GridCellNumberRenderer() else: editor = wx.grid.GridCellTextEditor() renderer = wx.grid.GridCellStringRenderer() grid.SetCellEditor(row, col, editor) grid.SetCellRenderer(row, col, renderer) grid.SetReadOnly(row, col, False) self.ResizeRow(grid, row)
Example #18
Source File: recipe-580623.py From code with MIT License | 6 votes |
def __init__(self): gridlib.PyGridTableBase.__init__(self) self.colLabels = ['Level','Title','Page'] self.dataTypes = [gridlib.GRID_VALUE_NUMBER, gridlib.GRID_VALUE_STRING, gridlib.GRID_VALUE_NUMBER, ] # initial load of table with outline data # each line consists of [lvl, title, page] # for display, we "indent" the title with spaces self.data = [[PDFcfg.inhalt[i][0], # indentation level " "*(PDFcfg.inhalt[i][0] -1) + \ PDFcfg.inhalt[i][1].decode("utf-8","ignore"), # title PDFcfg.inhalt[i][2]] \ for i in range(len(PDFcfg.inhalt))] if not PDFcfg.inhalt: self.data = [[0, "*** no outline ***", 0]] # used for correctly placing new lines. insert at end = -1 self.cur_row = -1 #============================================================================== # Methods required by wxPyGridTableBase interface. # Will be called by the grid. #==============================================================================
Example #19
Source File: EtherCATManagementEditor.py From OpenPLC_Editor with GNU General Public License v3.0 | 5 votes |
def OnSelectCell(self, event): """ Handles the event of the cell of the main table. @param event: wx.grid object (left click) """ # if reg_monitor_data is 0, it is initialization of register access. if self.RegMonitorData == 0: event.Skip() return 0 sub_row = 0 sub_col = 4 address = self.GetRowLabelValue(event.GetRow()) reg_sub_grid_data = [] BIT_RANGE, NAME, DESCRIPTIONS = range(3) # Check if this register's detail description is exist or not, # and create data structure for the detail description table ; sub grid if address in self.RegisterAccessPanel.RegisterSubGridDict: for element in self.RegisterAccessPanel.RegisterSubGridDict[address]: row_data = [] row_data.append(element[BIT_RANGE]) row_data.append(element[NAME]) bin_data = "{:0>16b}".format(int(self.GetCellValue(event.GetRow(), 1))) value_range = element[BIT_RANGE].split('-') value = (bin_data[8:16][::-1]+bin_data[0:8][::-1])[int(value_range[0]):(int(value_range[-1])+1)][::-1] row_data.append(str(int(('0b'+str(value)), 2))) if value in element[DESCRIPTIONS]: row_data.append(element[DESCRIPTIONS][value]) else: row_data.append('') reg_sub_grid_data.append(row_data) sub_row = sub_row + 1 self.parent.UpdateSubTable(sub_row, sub_col, reg_sub_grid_data) # event.Skip() updates UI of selecting cell event.Skip()
Example #20
Source File: EtherCATManagementEditor.py From OpenPLC_Editor with GNU General Public License v3.0 | 5 votes |
def __init__(self, parent, controler, row, col): """ Constructor @param parent: Reference to the parent HexView class @param controler: _EthercatSlaveCTN class in EthercatSlave.py @param row, col: Hex View grid size """ self.parent = parent self.Controler = controler self.Row = row self.Col = col wx.grid.Grid.__init__(self, parent, -1, size=(830, 450), style=wx.ALIGN_CENTRE_HORIZONTAL | wx.ALIGN_CENTER_VERTICAL)
Example #21
Source File: EtherCATManagementEditor.py From OpenPLC_Editor with GNU General Public License v3.0 | 5 votes |
def UpdateSiiGridTable(self, row, col): """ Destroy existing grid and recreate @param row, col : Hex View grid size """ self.HexViewSizer["view"].Detach(self.SiiGrid) self.SiiGrid.Destroy() self.SiiGrid = SiiGridTable(self, self.Controler, row, col) self.HexViewSizer["view"].Add(self.SiiGrid) self.SiiGrid.CreateGrid(row, col) self.SetSizer(self.HexViewSizer["view"]) self.HexViewSizer["view"].FitInside(self.parent.parent) self.parent.parent.FitInside()
Example #22
Source File: Issue385_step_2_Phoenix.py From wxGlade with MIT License | 5 votes |
def __init__(self, *args, **kwds): # begin wxGlade: MyFrame.__init__ kwds["style"] = kwds.get("style", 0) | wx.DEFAULT_FRAME_STYLE wx.Frame.__init__(self, *args, **kwds) self.SetSize((400, 682)) self.SetTitle("frame") self.grid_1 = wx.grid.Grid(self, wx.ID_ANY, size=(1, 1)) self.grid_1.CreateGrid(10, 0) self.Layout() # end wxGlade # end of class MyFrame
Example #23
Source File: edit_windows.py From wxGlade with MIT License | 5 votes |
def properties_changed(self, modified): WindowBase.properties_changed(self, modified) p = self.properties["flag"] if modified and "flag" in modified and self.parent.IS_SIZER: p._check_value() if "flag" in modified and "wxSHAPED" in p.value_set and self.proportion: self.properties["proportion"].set(0, notify=False) elif "option" in modified and self.proportion and "wxSHAPED" in p.value_set: p.remove("wxSHAPED", notify=False) if "border" in modified and self.border and not "flag" in modified: # enable border flags if not yet done if not p.value_set.intersection(p.FLAG_DESCRIPTION["Border"]): p.add("wxALL", notify=False) modified.append("flag") if not modified or ("option" in modified or "flag" in modified or "border" in modified or "size" in modified or "span" in modified): if self.parent.WX_CLASS=="wxGridBagSizer" and (not modified or "span" in modified) and self.span!=(1,1): # check span range, if pasted item would span more rows/cols than available span_p = self.properties["span"] max_span = self.sizer.check_span_range(self.index, *span_p.value) max_span = ( min(span_p.value[0],max_span[0]), min(span_p.value[1],max_span[1]) ) if max_span!=span_p.value: span_p.set(max_span, notify=False) if self.parent.IS_SIZER: self.sizer.item_properties_modified(self, modified) # if an item inside a flex grid sizer is set to EXPAND, inform the user if row and col are not growable if modified and "flag" in modified and self.parent.IS_SIZER and "growable_rows" in self.parent.properties: if p.previous_value is not None and "wxEXPAND" in p.value_set and not "wxEXPAND" in p.previous_value: row, col = self.parent._get_row_col(self.index) if not row in self.parent.growable_rows and not col in self.parent.growable_cols: wx.CallAfter(self.parent.ask_growable, row,col)
Example #24
Source File: _sqlgrid.py From admin4 with Apache License 2.0 | 5 votes |
def GetTypeName(self, _row, col): cd=self.GetColDef(col) if cd: return cd.type return wx.grid.GRID_VALUE_STRING
Example #25
Source File: _sqlgrid.py From admin4 with Apache License 2.0 | 5 votes |
def DeleteRows(self, row, count): for _ in range(count): del self.rows[row] self.grid.ProcessTableMessage(wx.grid.GridTableMessage(self, wx.grid.GRIDTABLE_NOTIFY_ROWS_DELETED, row, count)) return True
Example #26
Source File: _sqlgrid.py From admin4 with Apache License 2.0 | 5 votes |
def __init__(self, grid, tableSpecs, rowset): wx.grid.PyGridTableBase.__init__(self) self.grid=grid self.hasoids=self.grid.tableSpecs.hasoids self.colNames=rowset.colNames self.tableSpecs=tableSpecs self.rows=rowset.getDictList() self.canUpdate=len(tableSpecs.keyCols) self.readOnly=False self.attrs=[] self.Revert()
Example #27
Source File: Zone.py From admin4 with Apache License 2.0 | 5 votes |
def Check(self): ok=Record.Check(self) ok=self.CheckValid(ok, self.grid.GetNumberRows()>1, xlt("At least one record line required")) for row in range(self.grid.GetNumberRows()-1): if not ok: break vals=[] for col in range(self.grid.GetNumberCols()): val=self.grid.GetCellValue(row, col).strip() if val: vals.append(val) ok=self.CheckValid(ok, len(vals) == len(self.slotvals), xlt("Enter all values in row %d" % (row+1))) return ok
Example #28
Source File: Zone.py From admin4 with Apache License 2.0 | 5 votes |
def OnDelete(self, evt): self.changed=True self.grid.DeleteRows(self.cmRow, 1) self.OnCheck(evt)
Example #29
Source File: Zone.py From admin4 with Apache License 2.0 | 5 votes |
def AddExtraControls(self, res): self.grid=wxGrid.Grid(self) res.AttachUnknownControl("ValueGrid", self.grid) self.grid.Bind(wxGrid.EVT_GRID_CELL_CHANGED, self.OnCellChange) self.grid.Bind(wxGrid.EVT_GRID_EDITOR_SHOWN, self.OnEditorShown) self.grid.Bind(wxGrid.EVT_GRID_CELL_RIGHT_CLICK, self.OnRightClick)
Example #30
Source File: Zone.py From admin4 with Apache License 2.0 | 5 votes |
def OnCellChange(self, evt): if evt.GetRow() == self.grid.GetNumberRows()-1: self.grid.AppendRows(1) self.changed=True return self.OnCheck(evt)