[wxPython] wxGrid and display

Hello,
I am using a custom wxGrid, for displaying a long list of words from a
dictionary. (source below)

With this I do have three problems:

a) I always get two columns, the first one has words, the second is
completely empty.

b) The contents is not resized as expected. (perhaps I do something else
wrong, as the anchors do not behave as expected as well)

c) I when I doubleclick on a word, I can edit it, rather then selecting
it with my own routine. When the column is expanded above the visible
width, I can select the word as expected.

thanks for your patience

Horst

from wxPython.wx import *
from wxPython.grid import *

class Wordlist(wxPyGridTableBase):
    def __init__(self, dict = None):
        wxPyGridTableBase.__init__(self)
        self.dict = dict

    def GetNumberRows(self):
        if (self.dict == None):
            return 0
        else:
            return self.dict.GetNumberEntries()

    def GetNumberCols(self):
        return 1

    def IsEmptyCell(self,row, col):
        return false

    def IsEditable(self):
        return false

    def GetEditable(self):
        return false

    def GetValue(self, row, col):
        if (self.dict == None):
            return ""
        else:
            return self.dict.GetEntry(row)

<snip/>

class WordListGrid(wxGrid):
    def __init__(self, parent,size,pos):
        wxGrid.__init__(self, parent, 1, size=size, pos=pos)
        self.table = Wordlist()
        self.SetTable(self.table, true)
        self.EnableGridLines(false)
        self.SetColLabelSize(0)
        self.SetRowLabelSize(0)
        EVT_SIZE(self, self.SetMySize)

    def SetMySize(self):
        size = self.GetSize()
        self.table.SetColSize(0,size)
        self.SetSize(self.GetSize())

    def SetDictionary(self, dict):
        self.table.SetDictionary(dict)

    def SetClick(self, routine):
        self.routine = routine
        EVT_GRID_CELL_LEFT_DCLICK(self, self.OnDClick)
        EVT_LEFT_DOWN(self, self.OnDClick)

    def OnDClick(self, evt):
        self.routine( self.table.GetValue( evt.GetRow(),evt.GetCol() ) )
        evt.Skip()

<snip/>
def SetWordlist(self, parent):
        self.grdWords = Wordlist.WordListGrid( parent = self.panel1, pos=wxPoint(0,70), size=wxSize(152,376))
        self.grdWords.SetConstraints(LayoutAnchors(self.panel1, true, true, true, true))
        self.grdWords.SetClick(self.OnWlistDouble )

···

--
Horst@freedict.de
Horst Eyermann
Germany

You need a dictionary? - visit http://www.freedict.de
for free (GPL) dictionaries (unix; windows work in progress)
For windows, visit http://www.freedict.de/wbuch

A article (in German) about dictionary efforts on the net
http://www.heise.de/tp/deutsch/inhalt/on/5927/1.html

With this I do have three problems:

a) I always get two columns, the first one has words, the second is
completely empty.

b) The contents is not resized as expected. (perhaps I do something else
wrong, as the anchors do not behave as expected as well)

c) I when I doubleclick on a word, I can edit it, rather then selecting
it with my own routine. When the column is expanded above the visible
width, I can select the word as expected.

Please send a complete self-contained sample that shows the problems.

···

--
Robin Dunn
Software Craftsman
robin@AllDunn.com Java give you jitters?
http://wxPython.org Relax with wxPython!