wx.grid.Grid.SetCellHighlightPenWidth(width)

Hi Jean,

Thank you for your answer. I derive my own grid from wx.grid.Grid,
and set the Highlight pen width in the constructor:

-->--
class AppsGrid(wx.grid.Grid):

    def __init__(self, parent):
        wx.grid.Grid.__init__(self, parent, id=-1, size=(280,200))

        table = AppsDataTable()
        self.table = table
        self.SetTable(table, True)

        self.SetRowLabelSize(0)
        self.SetColSize(0,20)
        self.SetColSize(1,160)
        self.SetColSize(2,74)
        self.SetMargins(0,0)
        self.EnableDragGridSize(0)
        self.SetLabelFont(self.GetCellFont(0,0))
        self.SetColLabelSize(22)
        
        self.SetCellHighlightPenWidth(1)
        
        # Make column of application name read-only
        attr = wx.grid.GridCellAttr()
        attr.SetReadOnly()
        self.SetColAttr(1,attr)
        
        wx.grid.EVT_GRID_CELL_LEFT_DCLICK(self, self.OnLeftDClick)
        wx.grid.EVT_GRID_CELL_LEFT_CLICK(self, self.OnLeftClick)

--<--

The trace I get when the interpreter hits the line

        self.SetCellHighlightPenWidth(1)

Is:

Traceback (most recent call last):
  File "C:\ksta\Sysadmin\Sysadmin.py", line 422, in OnClose
    size=(1060,860),
style=wx.DEFAULT_FRAME_STYLE|wx.NO_FULL_REPAINT_ON_RESIZE)
  File "C:\ksta\Sysadmin\Sysadmin.py", line 233, in __init__
    self.MakeMainWindow()
  File "C:\ksta\Sysadmin\Sysadmin.py", line 253, in MakeMainWindow
    self.tabw = MainTabs(self,-1)
  File "C:\ksta\Sysadmin\Sysadmin.py", line 97, in __init__
    self.ben = TabUser(sw,mainf)
  File "C:\ksta\Sysadmin\TabUser.py", line 479, in __init__
    atab = AppsTable(wp)
  File "C:\ksta\Sysadmin\AppsTable.py", line 186, in __init__
    grid = AppsGrid(self)
  File "C:\ksta\Sysadmin\AppsTable.py", line 130, in __init__
    self.SetCellHighlightPenWidth(1)
  File "C:\Python24\Lib\site-packages\wx-2.6-msw-ansi\wx\grid.py", line
1659, in SetCellHighlightPenWidth
    return _grid.Grid_SetCellHighlightPenWidth(*args, **kwargs)
PyAssertionError: C++ assertion "uiIndex < m_nCount" failed in
..\..\include\wx/dynarray.h(812)

Hope this helps clear things up. By the way: Is there some kind of
reference regarding the events that a given control (for example,
Grid) generates? http://www.wxpython.org/docs/api/wx.grid.Grid-class.html
contains no event information.

cheers,
  Alex

···

-----Original Message-----
From: Jean Brouwers [mailto:mrjean1@gmail.com]
Sent: Thursday, September 15, 2005 7:59 PM
To: wxPython-users@lists.wxwidgets.org
Subject: Re: [wxPython-users] wx.grid.Grid.SetCellHighlightPenWidth(width)

It is hard to tell from the code and tracebck in your message, but
SetCellHighlightPenWidth works fine in our case as follows

  import wx, wx.grid as grid
  class Agrid(grid.Grid):
      ...
      def SetFocus(self):
          grid.Grid.SetCellHighlightPenWidth(self, 1)
      ...
      def OnLostFocus(self, event):
          grid.Grid.SetCellHighlightPenWidth(self, 0)
          event.Skip()
      ...

HTH, /Jean Brouwers

On 9/14/05, Suzuki Alex <Alex.Suzuki@ksta.ktzh.ch> wrote:
Hi list,

I'm deriving a custom grid from wxGrid, and I'm not so happy with
the cell-highlighting, the highlight is to wide, aesthetically not
so pleasing. Then I discovered

  wx.grid.Grid.SetCellHighlightPenWidth (self, width)

in the documentation, but I get this error message:

  [... parent traces ...]
    grid = AppsGrid(self)
  File "C:\ksta\Sysadmin\AppsTable.py", line 131, in __init__
    self.SetCellHighlightPenWidth (1)
  File "C:\Python24\Lib\site-packages\wx-2.6-msw-ansi\wx\grid.py", line
1659, in SetCellHighlightPenWidth
    return _grid.Grid_SetCellHighlightPenWidth(*args, **kwargs)
PyAssertionError: C++ assertion "uiIndex < m_nCount" failed in
..\..\include\wx/dynarray.h(812)

What am I doing wrong? Any help would be much appreciated. I'm using
wxPython 2.6.1 and Python 2.4.1.

cheers, Alex

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org
For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org

There is nothing wrong that I can discern. Also, I tried using self.SetCellHighlightPenWidth(1) and
grid.Grid.SetCellHighlightPenWidth(self,1) inside the init() method**
and the results are the same: the cell box has the expected width.

The main (only?) difference left is that you are using wxPython 2.6 on
Windows while we run wxPython 2.4.2.4 on Linux. But the change
log <http://www.wxpython.org/CHANGES.html> does not show anything
recent for SetCellHighlightPenWidth. Unfortunately, I can not try
our grid code on Windows since it does not run there for reasons
unrelated to wxPython.

To your other question, check these (older) doc pages for wxPython

<http://wxwidgets.org/manuals/2.5.3/wx_contents.html>
<http://wxwidgets.org/manuals/2.5.3/wx_classref.html>

They show (most of) the events. For example for the Grid class

<http://wxwidgets.org/manuals/2.5.3/wx_wxgrid.html#wxgrid>

/Jean Brouwers

**) For comparison, here is the entire init() method from our grid class:

import wx, wx.grid as grid

class Agrid(grid.Grid):
_parent = None
_table = None

def __init__(self, parent, table=None):
    if parent:
        self._parent = parent
        wx.EVT_SIZE(parent, ...)
    grid.Grid.__init__(self, parent, -1)
    if table:
        self._table = table
        self.SetTable(self._table, False)
     # from GridCustTable.py example
    self.SetRowLabelSize(0)  # removes first column?
    self.SetMargins(8, 0)  # w, h
    self.AutoSizeColumns(False)
    self.SetDefaultCellAlignment(wx.ALIGN_CENTRE, wx.ALIGN_CENTRE)
    self.EnableEditing(False)
    self.SetRowMinimalAcceptableHeight(2)  # XXX for Windoz
    self.SetColMinimalAcceptableWidth(2)  # ditto
    self.SetLabelBackgroundColour(wx.LIGHT_GREY)
    self.AutoSizeColumns(False)  # setAsMin=False!
    self.ClearSelection()
     # handle some keys
    wx.EVT_KEY_DOWN(self.GetGridWindow(), ...)
     # catch resize events
    grid.EVT_GRID_ROW_SIZE(self, ...)
    grid.EVT_GRID_COL_SIZE(self, ...)
     # catch cell events
    grid.EVT_GRID_CELL_LEFT_CLICK( self, ...)
    grid.EVT_GRID_CELL_LEFT_DCLICK(self, ...)
    grid.EVT_GRID_CELL_RIGHT_CLICK( self, ...)
    grid.EVT_GRID_CELL_RIGHT_DCLICK(self, ...)
     # catch label events, top level
    grid.EVT_GRID_LABEL_LEFT_CLICK( self, ...)
    grid.EVT_GRID_LABEL_LEFT_DCLICK(self, ...)
    grid.EVT_GRID_LABEL_RIGHT_CLICK( self, ...)
    grid.EVT_GRID_LABEL_RIGHT_DCLICK(self, ...)
     # keyboard focus
    wx.EVT_KILL_FOCUS(self.GetGridWindow(), self.OnLostFocus)
    grid.Grid.SetCellHighlightPenWidth(self, 1)
....
···

On 9/18/05, Suzuki Alex Alex.Suzuki@ksta.ktzh.ch wrote:

Hi Jean,

Thank you for your answer. I derive my own grid from wx.grid.Grid,
and set the Highlight pen width in the constructor:

–>–
class AppsGrid(wx.grid.Grid):

def __init__(self, parent):

    wx.grid.Grid.__init__(self, parent, id=-1, size=(280,200))

    table = AppsDataTable()
    self.table = table
    self.SetTable(table, True)

    self.SetRowLabelSize(0)

self.SetColSize(0,20)
self.SetColSize(1,160)
self.SetColSize(2,74)
self.SetMargins(0,0)
self.EnableDragGridSize(0)
self.SetLabelFont(self.GetCellFont(0,0))

self.SetColLabelSize(22)

    self.SetCellHighlightPenWidth(1)

    # Make column of application name read-only
    attr = wx.grid.GridCellAttr()
    attr.SetReadOnly()
    self.SetColAttr

(1,attr)

    wx.grid.EVT_GRID_CELL_LEFT_DCLICK(self, self.OnLeftDClick)
    wx.grid.EVT_GRID_CELL_LEFT_CLICK(self, self.OnLeftClick)

–<–

The trace I get when the interpreter hits the line

    self.SetCellHighlightPenWidth(1)

Is:

Traceback (most recent call last):
File “C:\ksta\Sysadmin\Sysadmin.py”, line 422, in OnClose
size=(1060,860),
style=wx.DEFAULT_FRAME_STYLE|wx.NO_FULL_REPAINT_ON_RESIZE
)
File “C:\ksta\Sysadmin\Sysadmin.py”, line 233, in init
self.MakeMainWindow()
File “C:\ksta\Sysadmin\Sysadmin.py”, line 253, in MakeMainWindow
self.tabw = MainTabs(self,-1)

File “C:\ksta\Sysadmin\Sysadmin.py”, line 97, in init
self.ben = TabUser(sw,mainf)
File “C:\ksta\Sysadmin\TabUser.py”, line 479, in init
atab = AppsTable(wp)
File “C:\ksta\Sysadmin\AppsTable.py”, line 186, in init

grid = AppsGrid(self)

File “C:\ksta\Sysadmin\AppsTable.py”, line 130, in init
self.SetCellHighlightPenWidth(1)
File “C:\Python24\Lib\site-packages\wx-2.6-msw-ansi\wx\grid.py”, line

1659, in SetCellHighlightPenWidth
return _grid.Grid_SetCellHighlightPenWidth(*args, **kwargs)
PyAssertionError: C++ assertion “uiIndex < m_nCount” failed in
…..\include\wx/dynarray.h(812)

Hope this helps clear things up. By the way: Is there some kind of
reference regarding the events that a given control (for example,
Grid) generates?
http://www.wxpython.org/docs/api/wx.grid.Grid-class.html

contains no event information.

cheers,
Alex

-----Original Message-----
From: Jean Brouwers [mailto:mrjean1@gmail.com
]
Sent: Thursday, September 15, 2005 7:59 PM
To: wxPython-users@lists.wxwidgets.org
Subject: Re: [wxPython-users] wx.grid.Grid.SetCellHighlightPenWidth(width)

It is hard to tell from the code and tracebck in your message, but
SetCellHighlightPenWidth works fine in our case as follows

import wx, wx.grid as grid
class Agrid(grid.Grid):

  def SetFocus(self):
      grid.Grid.SetCellHighlightPenWidth(self, 1)
  ...
  def OnLostFocus(self, event):
      grid.Grid.SetCellHighlightPenWidth(self, 0)
      event.Skip()

  ...

HTH, /Jean Brouwers

On 9/14/05, Suzuki Alex Alex.Suzuki@ksta.ktzh.ch wrote:
Hi list,

I’m deriving a custom grid from wxGrid, and I’m not so happy with

the cell-highlighting, the highlight is to wide, aesthetically not
so pleasing. Then I discovered

wx.grid.Grid.SetCellHighlightPenWidth (self, width)

in the documentation, but I get this error message:

[… parent traces …]
grid = AppsGrid(self)
File “C:\ksta\Sysadmin\AppsTable.py”, line 131, in init
self.SetCellHighlightPenWidth (1)
File “C:\Python24\Lib\site-packages\wx-
2.6-msw-ansi\wx\grid.py”, line
1659, in SetCellHighlightPenWidth
return _grid.Grid_SetCellHighlightPenWidth(*args, **kwargs)
PyAssertionError: C++ assertion “uiIndex < m_nCount” failed in

…..\include\wx/dynarray.h(812)

What am I doing wrong? Any help would be much appreciated. I’m using
wxPython 2.6.1 and Python 2.4.1.

cheers, Alex


To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org
For additional commands, e-mail:
wxPython-users-help@lists.wxwidgets.org


To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org

For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org

I just noticed, there are more recent 2.6.1 doc pages

<http://wxwidgets.org/manuals/2.6.1/wx_contents.html>
<http://wxwidgets.org/manuals/2.6.1/wx_wxgrid.html#wxgrid>

and even

<http://wxwidgets.org/manuals/2.6.1/wx_wxgridevent.html#wxgridevent>

Btw, these are wxWidget pages, not wxPython. My apologies.

/Jean Brouwers

···

On 9/19/05, Jean Brouwers mrjean1@gmail.com wrote:

There is nothing wrong that I can discern. Also, I tried using self.SetCellHighlightPenWidth(1) and
grid.Grid.SetCellHighlightPenWidth(self,1) inside the init() method**
and the results are the same: the cell box has the expected width.

The main (only?) difference left is that you are using wxPython 2.6 on
Windows while we run wxPython 2.4.2.4 on Linux. But the change
log <http://www.wxpython.org/CHANGES.html> does not show anything
recent for SetCellHighlightPenWidth. Unfortunately, I can not try
our grid code on Windows since it does not run there for reasons
unrelated to wxPython.

To your other question, check these (older) doc pages for wxPython

<http://wxwidgets.org/manuals/2.5.3/wx_contents.html>

<http://wxwidgets.org/manuals/2.5.3/wx_classref.html>

They show (most of) the events. For example for the Grid class

<http://wxwidgets.org/manuals/2.5.3/wx_wxgrid.html#wxgrid>

/Jean Brouwers

**) For comparison, here is the entire init() method from our grid class:

import wx, wx.grid as grid

....

class Agrid(grid.Grid):

_parent = None

_table = None



def __init__(self, parent, table=None):

    if parent:

        self._parent = parent

        wx.EVT_SIZE(parent, ...)

    grid.Grid.__init__(self, parent, -1)

    if table:

        self._table = table

        self.SetTable(self._table, False)

     # from GridCustTable.py example

    self.SetRowLabelSize(0)  # removes first column?

    self.SetMargins(8, 0)  # w, h

    self.AutoSizeColumns(False)

    self.SetDefaultCellAlignment(wx.ALIGN_CENTRE, wx.ALIGN_CENTRE)

    self.EnableEditing(False)

    self.SetRowMinimalAcceptableHeight(2)  # XXX for Windoz

    self.SetColMinimalAcceptableWidth(2)  # ditto

    self.SetLabelBackgroundColour(wx.LIGHT_GREY)

    self.AutoSizeColumns(False)  # setAsMin=False!

    self.ClearSelection()

     # handle some keys

    wx.EVT_KEY_DOWN(self.GetGridWindow(), ...)

     # catch resize events

    grid.EVT_GRID_ROW_SIZE(self, ...)

    grid.EVT_GRID_COL_SIZE(self, ...)

     # catch cell events

    grid.EVT_GRID_CELL_LEFT_CLICK( self, ...)

    grid.EVT_GRID_CELL_LEFT_DCLICK(self, ...)

    grid.EVT_GRID_CELL_RIGHT_CLICK( self, ...)

    grid.EVT_GRID_CELL_RIGHT_DCLICK(self, ...)

     # catch label events, top level

    grid.EVT_GRID_LABEL_LEFT_CLICK( self, ...)

    grid.EVT_GRID_LABEL_LEFT_DCLICK(self, ...)

    grid.EVT_GRID_LABEL_RIGHT_CLICK( self, ...)

    grid.EVT_GRID_LABEL_RIGHT_DCLICK(self, ...)

     # keyboard focus

    wx.EVT_KILL_FOCUS(self.GetGridWindow(), self.OnLostFocus)

    grid.Grid.SetCellHighlightPenWidth(self, 1)

....

On 9/18/05, Suzuki Alex <Alex.Suzuki@ksta.ktzh.ch > > wrote:

Hi Jean,

Thank you for your answer. I derive my own grid from wx.grid.Grid,
and set the Highlight pen width in the constructor:

–>–
class AppsGrid(wx.grid.Grid):

def __init__(self, parent):

    wx.grid.Grid.__init__(self, parent, id=-1, size=(280,200))

    table = AppsDataTable()
    self.table = table
    self.SetTable(table, True)

    self.SetRowLabelSize(0)

self.SetColSize(0,20)
self.SetColSize(1,160)
self.SetColSize(2,74)
self.SetMargins(0,0)
self.EnableDragGridSize(0)
self.SetLabelFont(self.GetCellFont(0,0))

self.SetColLabelSize(22)

    self.SetCellHighlightPenWidth(1)

    # Make column of application name read-only
    attr = wx.grid.GridCellAttr()
    attr.SetReadOnly()

    self.SetColAttr

(1,attr)

    wx.grid.EVT_GRID_CELL_LEFT_DCLICK(self, self.OnLeftDClick)
    wx.grid.EVT_GRID_CELL_LEFT_CLICK(self, self.OnLeftClick)

–<–

The trace I get when the interpreter hits the line

    self.SetCellHighlightPenWidth(1)

Is:

Traceback (most recent call last):
File “C:\ksta\Sysadmin\Sysadmin.py”, line 422, in OnClose
size=(1060,860),

style=wx.DEFAULT_FRAME_STYLE|wx.NO_FULL_REPAINT_ON_RESIZE
)
File “C:\ksta\Sysadmin\Sysadmin.py”, line 233, in init
self.MakeMainWindow()
File “C:\ksta\Sysadmin\Sysadmin.py”, line 253, in MakeMainWindow
self.tabw = MainTabs(self,-1)

File “C:\ksta\Sysadmin\Sysadmin.py”, line 97, in init
self.ben = TabUser(sw,mainf)
File “C:\ksta\Sysadmin\TabUser.py”, line 479, in init
atab = AppsTable(wp)
File “C:\ksta\Sysadmin\AppsTable.py”, line 186, in init

grid = AppsGrid(self)

File “C:\ksta\Sysadmin\AppsTable.py”, line 130, in init
self.SetCellHighlightPenWidth(1)
File “C:\Python24\Lib\site-packages\wx-2.6-msw-ansi\wx\grid.py”, line

1659, in SetCellHighlightPenWidth
return _grid.Grid_SetCellHighlightPenWidth(*args, **kwargs)
PyAssertionError: C++ assertion “uiIndex < m_nCount” failed in
…..\include\wx/dynarray.h(812)

Hope this helps clear things up. By the way: Is there some kind of
reference regarding the events that a given control (for example,
Grid) generates? [

wxPython API Documentation — wxPython Phoenix 4.2.2 documentation](wxPython API Documentation — wxPython Phoenix 4.2.2 documentation)
contains no event information.

cheers,
Alex

-----Original Message-----
From: Jean Brouwers [mailto:
mrjean1@gmail.com
]
Sent: Thursday, September 15, 2005 7:59 PM
To: wxPython-users@lists.wxwidgets.org

Subject: Re: [wxPython-users] wx.grid.Grid.SetCellHighlightPenWidth(width)

It is hard to tell from the code and tracebck in your message, but
SetCellHighlightPenWidth works fine in our case as follows

import wx, wx.grid as grid
class Agrid(grid.Grid):

  def SetFocus(self):
      grid.Grid.SetCellHighlightPenWidth(self, 1)
  ...
  def OnLostFocus(self, event):
      grid.Grid.SetCellHighlightPenWidth(self, 0)
      event.Skip()


  ...

HTH, /Jean Brouwers

On 9/14/05, Suzuki Alex <Alex.Suzuki@ksta.ktzh.ch > > > wrote:
Hi list,

I’m deriving a custom grid from wxGrid, and I’m not so happy with

the cell-highlighting, the highlight is to wide, aesthetically not
so pleasing. Then I discovered

wx.grid.Grid.SetCellHighlightPenWidth (self, width)

in the documentation, but I get this error message:

[… parent traces …]
grid = AppsGrid(self)
File “C:\ksta\Sysadmin\AppsTable.py”, line 131, in init
self.SetCellHighlightPenWidth (1)
File “C:\Python24\Lib\site-packages\wx-
2.6-msw-ansi\wx\grid.py”, line
1659, in SetCellHighlightPenWidth
return _grid.Grid_SetCellHighlightPenWidth(*args, **kwargs)
PyAssertionError: C++ assertion “uiIndex < m_nCount” failed in

…..\include\wx/dynarray.h(812)

What am I doing wrong? Any help would be much appreciated. I’m using
wxPython 2.6.1 and Python 2.4.1.

cheers, Alex


To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org
For additional commands, e-mail:
wxPython-users-help@lists.wxwidgets.org


To unsubscribe, e-mail:
wxPython-users-unsubscribe@lists.wxwidgets.org

For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org