pythonwxpythonwxgrid

Sort Data from wxgrid


I'm attempting to get values from wxgrid for the last column in my grid (column 11) and append to a list if the cell is not empty. I can't seem to figure out why the list is being filled with a whole lot of empty values

phase_change=[]
for i in range(100):
  if self.myGrid.GetCellValue(i, 11) != None:
    phase_change.append(self.myGrid.GetCellValue(i, 11))
  else:
    print self.myGrid.GetCellValue(i, 11)
for phase in phase_change:
  plt.axvline(x=phase, ymin=0, ymax=1.0, linewidth=12, color='w')
  plt.axvline(x=phase, ymin=0, ymax=1.0, linewidth=1, color='k')

Can someone explain to me how I'm screwing this up?


Solution

  • The value returned from calling GetCellValue on an empty cell is the empty string (i.e., ''), not None; therefore, the condition in your if statement always returns as true. Since the empty string evaluates as false, simply removing the "!= None" from the if statement should solve the problem.