wxGrid?

Discussion in 'Python' started by Tom Lee, Sep 3, 2003.

  1. Tom Lee

    Tom Lee Guest

    #
    # 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?
    #
     
    Tom Lee, Sep 3, 2003
    #1
    1. Advertising

  2. 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, Sep 3, 2003
    #2
    1. Advertising

  3. 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
     
    Cousin Stanley, Sep 3, 2003
    #3
  4. Tom Lee

    Tom Lee Guest

    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
     
    Tom Lee, Sep 3, 2003
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. GrayGeek

    Can't get wxGrid to work

    GrayGeek, Nov 4, 2003, in forum: Python
    Replies:
    2
    Views:
    766
    GrayGeek
    Nov 4, 2003
  2. Johnny Geling

    wxGrid (wxPYTHON) rowlabels

    Johnny Geling, Nov 13, 2003, in forum: Python
    Replies:
    6
    Views:
    424
    Johnny Geling
    Nov 17, 2003
  3. Kepes Krisztian

    How can I create a wxgrid dinamically ?

    Kepes Krisztian, Nov 24, 2003, in forum: Python
    Replies:
    0
    Views:
    367
    Kepes Krisztian
    Nov 24, 2003
  4. marvin

    editing a wxGrid

    marvin, Apr 17, 2004, in forum: Python
    Replies:
    0
    Views:
    550
    marvin
    Apr 17, 2004
  5. Tim Williams
    Replies:
    3
    Views:
    3,986
    Tim Williams
    May 15, 2004
Loading...

Share This Page