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""")
To extend and revise my remarks my error is
File "C:\Python24\Lib\site-packages\boa-constructor\test of
snake\csoundgrid.py", line 8, in create_grid
win = Grid_MegaExample.MegaTable(self, data, colnames, pugins)
NameError: global name 'self' is not defined
Script terminated.
- Hide quoted text -
- Show quoted text -
···
_________________________________________________________________
Use your PC to make calls at very low rates https://voiceoam.pcs.v2s.live.com/partnerredirect.aspx