By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,923 Members | 1,279 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,923 IT Pros & Developers. It's quick & easy.

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

P: n/a
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

Oct 16 '06 #1
Share this Question
Share on Google+
3 Replies


P: n/a
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
Er*********@msn.com wrote:
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
Oct 16 '06 #2

P: n/a
Er*********@msn.com <Er*********@msn.comwrote:
I am having trouble trying to reuse the code that was provided in the
wxdemo package of wxpython.
I suggest you ask this question on the wxpython mailing list which has
lots of very well informed contributors (not me - I'm just learning!).

http://www.wxpython.org/maillist.php

--
Nick Craig-Wood <ni**@craig-wood.com-- http://www.craig-wood.com/nick
Oct 16 '06 #3

P: n/a
Er*********@msn.com schrieb:
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

Oct 16 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.