python - Highlight a row in wxGrid (with wxPython) when a cell in that row changes programatically -


How do I highlight a line after the update of the built-in PyGridTableBase? I can not get my head around it.

I am able to create linear lines for the first line line:

  ### Style a small table Def GetAttr (Self, Row, Column, Prop): attr = gridlib.GridCellAttr () if self.is_header (line): attr.SetReadOnly (1) attr.SetFont (wx.Font (10, wx.FONTFAMILY_DEFAULT, wx.NORMAL, wx.NORMAL)) attr.SetBackgroundColour (wx.LIGHT_GREY) attr.SetAlignment (wx.ALIGN_CENTRE, wx.ALIGN_CENTRE) if the prop is 'exposed' attr return: attr.SetBackgroundColour ( '# 14FF63') self.SetRowAttr (attr, line) # Ode any rows if the row% 2 == 1: attr.SetBackgroundColour ('# CCE6FF') Return Entry Return E do not  

But even after a fire.

You're doing the right thing, the only problem that comes to mind It is that you probably did not refresh the grid manually after the GridTableBase update. Here's a small work example that is expected to help you out

  Import wx, wx.grid class GridData (wx.grid.PyGridTableBase) :. _cols = "abc" Ksplit () _deta = [ "1 2 3" Ksplit (), "4 5 6" Ksplit (), "7 8 9" Ksplit ()] _hailaited = set () def Getklbelvlua ( Auto, Colors: Return self._cols [col] DEF GetNumberRows (self): Return Lane (self ._data) def GetNumberCols (self): Return Lane (self._cols) def GetValue (self, line, color): Return the self K_deta [row] [Cola] def SetValue self, row, column, val): self._data [row] [col] = Wall DEF GetAttr (self, row, column, or): attr = wx.grid.GridCellAttr ( ) Attr.SetBackgroundColour (wx.GREEN if line itself ._ Highlighted other wx.WHITE) Return AIR def set_value (self, row, col, val): self._highlighted.a Dd (row) self.SetValue (line, call, wall) class test (wx.frame): DEF __int __ (self): wx.frame .__ init __ (self, none) self.data = GridData () self .grid = wx.grid.Grid (self) self.grid.SetTable (self.data) Bitian = wx.Button (own label = "set a2 to x") Bitian .Bind (wx.EVT_BUTTON, self.OnTest) self.Sizer = wx.BoxSizer (wx.VERTICAL) self.Sizer.Add (self.grid, 1, wx.EXPAND) self.Sizer.Add (btn, 0, wx .EXPAND) def OnTest (self, event): Self.data.set_value (1, 0, "x") self.grid.Refresh () app = wx.PySimpleApp () app.TopWindow = Test () app.TopWindow Show () app.MainLoop ()  

Comments

Popular posts from this blog

c# - How to capture HTTP packet with SharpPcap -

jquery - SimpleModal Confirm fails to submit form -

php - Multiple Select with Explode: only returns the word "Array" -