November 18th, 2004, 06:48 PM
Join Date: Jul 2003
Time spent in forums: 2 h 23 m 23 sec
Reputation Power: 0
ok, I did alot of digging on the site and through the docs and I was able to get it to create the cells, and populate the cells doing this in the EVT_MENU for the open command from the menu I created.
def __init__(self, parent):
self.FileName=None # Default Filename for Save
def OnMenu1Items0Menu(self, event): # Open txt File
dlg = wxFileDialog(self, "Choose a file", ".", "", "*.*", wxOPEN)
if dlg.ShowModal() == wxID_OK:
filename = dlg.GetPath()
f = open(filename, 'r')
data = f.read()
lines = data.split('\n')
str00 = lines[6:8]
str01 = lines[8:10]
str02 = lines[6:8]
str03 = lines[8:10]
self.grid1.SetCellValue(0, 0, str00)
self.grid1.SetCellValue(0, 1, str01)
self.grid1.SetCellValue(1, 0, str02)
self.grid1.SetCellValue(1, 1, str03)
My file contained the sample data of:
which took the 89 AE and AF 44 and put them into the corresponding cells like I wanted.
Now how would I save it back to the file if I changed one of the variables like change AF to A9?
I tried to use similar code for the save event but im not doing something correctly because it keeps giving me an atribute error. I will keep digging around and maybe I will come across something in my further research.
I would actually like to simplify the code in a loop or something because I need a actual cell grid of (16,16) and I would really rather not have to call each cell when I want to put data into it or write to it.