wxGrid?

T

Tom Lee

#
# Python 2.2.3, wxWindows/wxPython 2.4.1
#
# The code:
#

from wxPython.wx import *

class TestFrame( wxFrame ):
def __init__( self ):
wxFrame.__init__( self, None, -1, 'TestGrid' )

# the problem line >>> NameError: global name 'wxGrid' is not defined

grid = wxGrid( self, -1 )
grid.AppendCols( 2 )
grid.AppendRows( 3 )
grid.SetCellValue( 0, 0, 'Testing' )
self.Show( True )
return True

class TestApp( wxApp ):
def OnInit( self ):
frame = TestFrame()
self.SetTopWindow( frame )

return True


if __name__ == '__main__':
app = TestApp( 0 )
app.MainLoop()


#
# Any ideas?
#
 
C

Cousin Stanley

Tom ...

I was able to run your script
by adding two lines ...

from wxPython.grid import *

and

grid.CreateGrid( 3 , 2 )

Cousin Stanley

-----------------------------------------------------------

'''
NewsGroup .... comp.lang.python
Date ......... 2003-09-03
Posted_By .... Tom Lee
Edited_By .... Stanley C. Kitching
'''

from wxPython.wx import *
from wxPython.grid import *

class TestFrame( wxFrame ) :

def __init__( self ) :

wxFrame.__init__( self , None, -1 , 'TestGrid' ,
size = ( 430 , 185 ) )

grid = wxGrid( self, -1 )

grid.CreateGrid( 3 , 2 )

grid.AppendCols( 2 )
grid.AppendRows( 3 )

grid.SetCellValue( 0 , 0 , 'Testing' )

self.Show( True )

class TestApp( wxApp ) :

def OnInit( self ) :

frame = TestFrame()

self.SetTopWindow( frame )

return True

if __name__ == '__main__' :

app = TestApp( 0 )

app.MainLoop()
 
C

Cousin Stanley

I was able to run your script
by adding two lines ...

AND ... deleting ... return True
from the __init__ method
 
T

Tom Lee

Cousin said:
I was able to run your script
by adding two lines ...

AND ... deleting ... return True
from the __init__ method

Oops how'd that get in there. :S that was meant for OnInit

Cheers, your solution works perfectly. Is there any place I can look up
controls like this that are grouped externally to the rest of the
wxpython classes?

wxWindows provides excellent docs, but I can't seem to find much in the
way of python module/package names for certain controls (such as
wxPython.stc)

Regardless, thanks again.

Tom L
 

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,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top