Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > wxGrid?

Reply
Thread Tools

wxGrid?

 
 
Tom Lee
Guest
Posts: n/a
 
      09-03-2003
#
# 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?
#

 
Reply With Quote
 
 
 
 
Cousin Stanley
Guest
Posts: n/a
 
      09-03-2003
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()


 
Reply With Quote
 
 
 
 
Cousin Stanley
Guest
Posts: n/a
 
      09-03-2003
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


 
Reply With Quote
 
Tom Lee
Guest
Posts: n/a
 
      09-03-2003
Cousin Stanley wrote:

> 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

 
Reply With Quote
 
 
 
Reply

Thread Tools

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off




Advertisments