Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

Problems with grid

Help
2008-04-01
2013-05-01
  • I'm trying to write with wx and boa a simple plotting utility for doing all the repetitive stuff I use for plotting. I tried to use wxgrid (since I think I will not need to use the tables) but when I init the table with the code

    self.grid1 = wx.grid.Grid(id=wxID_FRAME1GRID1, name='grid1',
                  parent=self.panel4, pos=wx.Point(0, 0), size=wx.Size(728, 264),
                  style=0)
            self.grid1.EnableGridLines(True)
            self.grid1.SetHelpText('')
            self.grid1.Bind(wx.grid.EVT_GRID_SELECT_CELL,
                  self.OnGrid1GridSelectCell)
            self.grid1.CreateTable(50,50)

    even it it works when I make it run, when I open the editor it gives me error (3 imput required, while in the help for wx.grid it seems only 2 are needed)
    any hint ?
    Does someone have some code snippets for importing a txt file in a grid ?
    Thanks
    Giorgio

     
    • Can you provide the full exception you are getting.

      A text file into a grid?  Are you sure that a grid is the right widget?  Wouldn't a textctrl be better, or is the text file containing CSV data?

      If it is the later then look into the Python csv module to read the file and then write the data to the grid (see the wxPython demo - Grid_megaExample).

      Werner

       
    • I will try the wxpython grid_megaExample because it's exactly what I want to do. I laredy have a csv file and want to see (and eventually edit in the grid) The exception I get when I write this code (which correctly works)

      self.grid1.CreateGrid(50,50,selmode=wx.grid.Grid.SelectCells)

      is

      ttp://img515.imageshack.us/my.php?image=errorkf3.jpg

      (it's the screeshot of the error)
      Thanks for the reply
      Giorgio

       
    • I will try the wxpython grid_megaExample because it's exactly what I want to do. I laredy have a csv file and want to see (and eventually edit in the grid) The exception I get when I write this code (which correctly works)

      self.grid1.CreateGrid(50,50,selmode=wx.grid.Grid.SelectCells)

      is

      http://img515.imageshack.us/my.php?image=errorkf3.jpg

      (it's the screeshot of the error)
      Thanks for the reply
      Giorgio

       
      • Hi Giorgio,

        Quote:
        The exception I get when I write this code (which correctly works
        Endquote:

        Either it works or it gives you an exception - both is a bit of a contradiction :).

        I guess you are making the mistake of adding "user code" to the "boa generated" code, if you add the line you have a problem with after self._init_ctrls(parent) then it should work fine.

        partial code:
                self.grid1 = wx.grid.Grid(id=wxID_FRAME1GRID1, name='grid1',
                      parent=self.panel1, pos=wx.Point(0, 0), size=wx.Size(200, 100),
                      style=0)

                self._init_sizers()

            def __init__(self, parent):
                self._init_ctrls(parent)
               
                self.grid1.CreateGrid(50, 50, selmode=wx.grid.Grid.SelectCells)

        Werner

         
    • Thanks for the message Werner, now everything works !
      Giorgio