wx.grid question (trying to use code from Grid_Example.py)

Eric_Dexter at msn.com Eric_Dexter at msn.com
Mon Oct 16 00:46:00 EDT 2006


I am having trouble trying to reuse the code that was provided in the
wxdemo package of wxpython.  The program I am trying to use parts of is
Grid_MegaExample.py thier code is

class MegaTable(Grid.PyGridTableBase):
    """
    A custom wx.Grid Table using user supplied data
    """
    def __init__(self, data, colnames, plugins):
        """data is a list of the form
        [(rowname, dictionary),
        dictionary.get(colname, None) returns the data for column
        colname
        """
        # The base class must be initialized *first*
        Grid.PyGridTableBase.__init__(self)
        self.data = data
        self.colnames = colnames
        self.plugins = plugins or {}
        # XXX
        # we need to store the row length and column length to
        # see if the table has changed size
        self._rows = self.GetNumberRows()
        self._cols = self.GetNumberCols()

My code is

import wx.grid
import os
import sys
import string
import Grid_MegaExample

def create_grid():
    win = Grid_MegaExample.MegaTable(self, data, colnames, pugins)
    win.Show(True)

def create_colums(line):
    "creates colums based on what is passed to subroutine"
    for word in line:
        colnames = word

def create_sco_grid(from_file):
    "reads .sco file and inputs it into a wx.grid"
    data = []
    infile = open(from_file, 'r')
    testline = 'false'
    for line in infile:
        if """;<sco_header>""" in line:
            create_colums(line)
            testline = 'true'
        if testline == 'true':
            for word in line:
                data.append(word)
    create_grid()
create_sco_grid("""test.sco""")
            
        
        
        
http://www.dexrow.com




More information about the Python-list mailing list