Connecting Tech Pros Worldwide Help | Site Map

wxGrid?

Tom Lee
Guest
 
Posts: n/a
#1: Jul 18 '05
#
# 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?
#

Cousin Stanley
Guest
 
Posts: n/a
#2: Jul 18 '05

re: wxGrid?


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()


Cousin Stanley
Guest
 
Posts: n/a
#3: Jul 18 '05

re: wxGrid?


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

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

--
Cousin Stanley
Human Being
Phoenix, Arizona


Tom Lee
Guest
 
Posts: n/a
#4: Jul 18 '05

re: wxGrid?


Cousin Stanley wrote:
[color=blue]
> I was able to run your script
> by adding two lines ...
>
> AND ... deleting ... return True
> from the __init__ method
>[/color]

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

Closed Thread