wxGrid?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Tom Lee

    wxGrid?

    #
    # 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.SetCellVal ue( 0, 0, 'Testing' )
    self.Show( True )
    return True

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

    return True


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


    #
    # Any ideas?
    #

  • Cousin Stanley

    #2
    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.pytho n
    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.SetCellVal ue( 0 , 0 , 'Testing' )

    self.Show( True )

    class TestApp( wxApp ) :

    def OnInit( self ) :

    frame = TestFrame()

    self.SetTopWind ow( frame )

    return True

    if __name__ == '__main__' :

    app = TestApp( 0 )

    app.MainLoop()


    Comment

    • Cousin Stanley

      #3
      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


      Comment

      • Tom Lee

        #4
        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

        Comment

        Working...