Connecting Tech Pros Worldwide Help | Site Map
 
 
LinkBack Thread Tools Search this Thread
  #1  
Old October 16th, 2006, 05:35 AM
Eric_Dexter@msn.com
Guest
 
Posts: n/a
Default wx.grid question (trying to use code from Grid_Example.py)

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

  #2  
Old October 16th, 2006, 05:35 AM
Eric_Dexter@msn.com
Guest
 
Posts: n/a
Default Re: wx.grid question (trying to use code from Grid_Example.py)

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
Eric_Dexter@msn.com wrote:
Quote:
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
  #3  
Old October 16th, 2006, 09:15 AM
Nick Craig-Wood
Guest
 
Posts: n/a
Default Re: wx.grid question (trying to use code from Grid_Example.py)

Eric_Dexter@msn.com <Eric_Dexter@msn.comwrote:
Quote:
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 <nick@craig-wood.com-- http://www.craig-wood.com/nick
  #4  
Old October 16th, 2006, 02:25 PM
paul
Guest
 
Posts: n/a
Default Re: wx.grid question (trying to use code from Grid_Example.py)

Eric_Dexter@msn.com schrieb:
Quote:
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

 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 205,248 network members.