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

E

Eric_Dexter

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
 
E

Eric_Dexter

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.

http://www.dexrow.com
 
P

paul

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.
This has nothing to do with wx, you just don't use "self" if you're
_calling_ a method. So:

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

should get you to the next error ;)

cheers
paul
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,780
Messages
2,569,611
Members
45,280
Latest member
BGBBrock56

Latest Threads

Top