473,546 Members | 2,244 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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_MegaExampl e.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.PyGridTabl eBase.__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.GetNumberR ows()
self._cols = self.GetNumberC ols()

My code is

import wx.grid
import os
import sys
import string
import Grid_MegaExampl e

def create_grid():
win = Grid_MegaExampl e.MegaTable(sel f, data, colnames, pugins)
win.Show(True)

def create_colums(l ine):
"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(l ine)
testline = 'true'
if testline == 'true':
for word in line:
data.append(wor d)
create_grid()
create_sco_grid ("""test.sco""" )


http://www.dexrow.com

Oct 16 '06 #1
3 1654
To extend and revise my remarks my error is

File "C:\Python24\Li b\site-packages\boa-constructor\tes t of
snake\csoundgri d.py", line 8, in create_grid
win = Grid_MegaExampl e.MegaTable(sel f, 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_MegaExampl e.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.PyGridTabl eBase.__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.GetNumberR ows()
self._cols = self.GetNumberC ols()

My code is

import wx.grid
import os
import sys
import string
import Grid_MegaExampl e

def create_grid():
win = Grid_MegaExampl e.MegaTable(sel f, data, colnames, pugins)
win.Show(True)

def create_colums(l ine):
"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(l ine)
testline = 'true'
if testline == 'true':
for word in line:
data.append(wor d)
create_grid()
create_sco_grid ("""test.sco""" )


http://www.dexrow.com
Oct 16 '06 #2
Er*********@msn .com <Er*********@ms n.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
Er*********@msn .com schrieb:
To extend and revise my remarks my error is

File "C:\Python24\Li b\site-packages\boa-constructor\tes t of
snake\csoundgri d.py", line 8, in create_grid
win = Grid_MegaExampl e.MegaTable(sel f, 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_MegaExampl e.MegaTable(dat a, colnames, pugins)
win.Show(True)

should get you to the next error ;)

cheers
paul

Oct 16 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1800
by: Marc | last post by:
Hi all, Perplexed by this. I thought the sticky option was supposed to accomplish this task, but it doesn't seem to be working. Here is what I'm trying to accomplish. Window ---------------------------- | --Beginning of group-- | Cell1 Cell2 Cell3
6
2895
by: Brian Holbrook | last post by:
I am new to VB .Net. Is there anything close to what a flex grid was in VB 6.0? By this I mean being able to manipulate and add text data that is not in a database. I would be taking data from a text box and adding it or updating data that already exists in the grid. Again I am using VB .Net in a Smart Device application. Any direction...
3
1885
by: SAM | last post by:
Hey guys, Long time Access programmer, but never had to bother with these things until now. First, I use ADO all the time in VB, but now I need to use it in Access 2K. I never remember/know how to link the required libraries to get ADO functionality. It was easy enough in VB. Second, I've been surviving so far with subforms but I...
0
1826
by: Reza Nabi | last post by:
Dear All: Banckgroud: I have a datagrid which lives inside a repeater. Which is working fine. What i need is to dyanamically set the column width of the grid (which lieves inside the repeater). Is there any way, we accomplish this? Any advice on this would be greatly appreciated. Reza. ---BEGIN PART Of ListApp.aspx --->
4
4471
by: Girish | last post by:
Im trying to create a grid within a grid programmatically. Ive been successful in doing this but I need the embedded grid to fire its ItemDataBound event so I can handle it. The event does not seem to fire for some reason. The code is below. Look towards the end of the CustomerDataGrid_OnItemDataBound(object sender, DataGridItemEventArgs e)...
2
1184
by: nullref | last post by:
Hello. I am wondering about the ability of the data grid for being able to maintain state of data when paginating. I am trying to figure out if I can use the grid to enable editing of data that is paginated in the grid but that doesn't save the updates with every pagination action. Can this be done and what is the best strategy for...
2
3664
by: Questman | last post by:
Good afternoon, Does anyone have any code that implements, or approaches implementing, a cross-browser DHTML/JS solution to provide an Excel-like Grid on a web page - I'm trying to convert an old Java client/server data maintenance program to the web - the main display is in a grid format, which allows the user to select multiple rows and...
117
18416
by: phil-news-nospam | last post by:
Is there really any advantage to using DIV elements with float style properies, vs. the old method of TABLE and TR and TD? I'm finding that by using DIV, it still involves the same number of elements in the HTML to get everything just right. When you consider the class attribute on the DIV elements, there's not much size savings anymore...
2
2781
by: mdock | last post by:
Hello, I have a javascript grid on my ASP page which displays information about the history of specific units produced in our manufacturing facility. One of the results is the order number on which the unit was shipped. If the unit was not shipped, obviously there is no order number; the default value of this field on the data table is 0. ...
0
7507
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7698
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7461
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7794
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5361
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5080
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3492
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3472
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
747
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.