I have to admit that I am lost with wx.grid

I am lost with wx.grid, what I would like to do is to load a text file and place all the words in a grid. I would also like to look for a line that would be the colum '''';<header>''' and place that on the top of my grid. The only thing I have found is a data base thing that hasn't worked for me plus I don't have money for the book and I can't find it on the web any help would be nice.

https://sourceforge.net/projects/dex-tracker

(I am having trouble replying to the messages also I thought I had subscribed but have no idea how to reply with this system)

···

_________________________________________________________________
Find a local pizza place, music store, museum and more�then map the best route! http://local.live.com?FORM=MGA001

Eric Dexter wrote:

    I am lost with wx.grid, what I would like to do is to load a text file and place all the words in a grid. I would also like to look for a line that would be the colum '''';<header>''' and place that on the top of my grid. The only thing I have found is a data base thing that hasn't worked for me plus I don't have money for the book and I can't find it on the web any help would be nice.

Dex Tracker download | SourceForge.net

I started with one of the grid demos in the wxPython demo and came up with this. It should get you started...but do read that demo code.

#!/usr/local/python
"""

import wx
import wx.grid as gridlib

fileContents = """\
Column headers go here
This is a test of the
emergency broadcast system.
Had this been an actual
emergency, you would have been
told to sit down, put your
head between your legs,
and kiss your ass goodbye.
"""

···

#---------------------------------------------------------------------------

class WordGrid(gridlib.Grid):
    def __init__(self, parent, log):
        gridlib.Grid.__init__(self, parent, -1)

        self.loadFile()

        self.CreateGrid(len(self.rows), self.widestRow)

        for r, row in enumerate(self.rows):
            for c, col in enumerate(row):
                self.SetCellValue(r, c, col)
            self.SetColSize(c, 10*self.widestCol)

        for c, label in enumerate(self.header):
            self.SetColLabelValue(c, label)

    def loadFile(self):
        # you'd probably want to read a file here instead of a text string
        lines = fileContents.split('\n')
        self.header = lines[0].split()
        self.rows = [i.split() for i in lines[1:]]
        self.widestRow = max([len(r) for r in self.rows])
        self.widestCol = max([len(c) for c in [r for r in self.rows]])

#---------------------------------------------------------------------------

class TestFrame(wx.Frame):
    def __init__(self, parent, log):
        wx.Frame.__init__(self, parent, -1, "Simple Grid Demo", size=(640,480))
        grid = WordGrid(self, log)

#---------------------------------------------------------------------------

if __name__ == '__main__':
    import sys
    app = wx.PySimpleApp()
    frame = TestFrame(None, sys.stdout)
    frame.Show(True)
    app.MainLoop()

--
------------------------------------------------------------
Kent Quirk I'm making a game about global warming.
Game Architect Track the progress at:
CogniToy cognitoy.com - Diese Website steht zum Verkauf! - Informationen zum Thema cognitoy.