Problem storing wx.grid contents in a python list

Let me start by saying, I am not a trained programmer, just very interested in learning. I will understand if some people think it is the height of arrogance for me to even attempt to write a database app using sqlite3, Python and wxPython but here I am… I have an problem with trying to get the cell values of multiple rows in a grid stored in a list as tuples. I can only seem to get the values of the last row in my grid stored inside the list. I have attached a sample of code showing where I am stuck.

Any help will be appreciated greatly… Cheers

Proj_Editor_Code_Sample_1.py (2.49 KB)

Hello Dean,
in the for-loop, with every iteration you are initializing common.gridData. That’s why only the last row will be in common.gridData.

for row in range(common.rNum):
order = str(self.grid1.GetCellValue(row, 0))
slip = str(self.grid1.GetCellValue(row, 1))
date = str(self.grid1.GetCellValue(row, 2))
cust = str(self.grid1.GetCellValue(row, 3))
prod = str(self.grid1.GetCellValue(row, 4))
fin = str(self.grid1.GetCellValue(row, 5))
qty = str(self.grid1.GetCellValue(row, 6))
common.gridData = [] # <— put this line before ‘for row…’
common.gridData.append((order,slip,date,cust,prod,fin,qty))

``

Dean Benfield wrote:

Let me start by saying, I am not a trained programmer, just very
interested in learning. I will understand if some people think it is
the height of arrogance for me to even attempt to write a database app
using sqlite3, Python and wxPython but here I am....

Not at all! That's a very common need and a very solvable problem. A
large percentage of the business applications in the world today do
exactly this task, so learning how to manipulate a database and expose
it through a UI is a skill you can put on a rèsúme.

···

--
Tim Roberts, timr@probo.com
Providenza & Boekelheide, Inc.

If that’s the “height of arrogance” , then I must be terribly arrogant as I’ve written on this topic on my blog on multiple occasions. You might find them helpful, although I’m not using the Grid widget in my examples:

···

On Friday, May 1, 2015 at 2:00:22 AM UTC-5, Dean Benfield wrote:

Let me start by saying, I am not a trained programmer, just very interested in learning. I will understand if some people think it is the height of arrogance for me to even attempt to write a database app using sqlite3, Python and wxPython but here I am… I have an problem with trying to get the cell values of multiple rows in a grid stored in a list as tuples. I can only seem to get the values of the last row in my grid stored inside the list. I have attached a sample of code showing where I am stuck.

Any help will be appreciated greatly… Cheers

Thanks very much for the help on this one. I have almost finished this particular section of my program and have almost completed the frames used to enter data into my database. Mike, thanks for pointing me to those articles. They will definitely come in handy as I look at ways of displaying database information but also export it to spreadsheets for generating picking slips and the like. Cheers again.

···

On Friday, May 1, 2015 at 5:00:22 PM UTC+10, Dean Benfield wrote:

Let me start by saying, I am not a trained programmer, just very interested in learning. I will understand if some people think it is the height of arrogance for me to even attempt to write a database app using sqlite3, Python and wxPython but here I am… I have an problem with trying to get the cell values of multiple rows in a grid stored in a list as tuples. I can only seem to get the values of the last row in my grid stored inside the list. I have attached a sample of code showing where I am stuck.

Any help will be appreciated greatly… Cheers