Reputation: 35
I'm working on my computing project for school, and I'm having trouble getting anything the user inputs to save to a .csv file. I'm using Python 3.2.2 and Tkinter as the GUI. No matter what I enter into the fields I get the wrong output into the csv, similar to ".54540776.54541280," etc. I've basically had to teach myself this stuff as I've gone along so I'm probably just making a stupid mistake somewhere. I've tried using the csv module in Python and I can't get that working. I haven't been able to find anything similar (that I understand to be the same anyway). I've uploaded my code to pastebin to make it more readable: http://pastebin.com/FarMtWdZ
Upvotes: 0
Views: 429
Reputation: 45542
note: I didn't read all of the code, but this addresses the crux of the problem.
The problem is with how you are pulling the contents of an Entry
. Don't use str(your_entry)
, rather use your_entry.get()
.
from Tkinter import *
root = Tk()
e = Entry(root)
e.insert(0, "a default value")
e.pack()
print "str(e) =>", str(e) # str() just gives us Tk's internal identifier
print "e.get() =>", e.get() # use get() for contents of Entry
root.mainloop()
gives
str(e) => .33906776
e.get() => a default value
Upvotes: 4