I need to write gui in Tkinter, which can select the csv file, read it and generate a sequence of buttons based on the names in the first line of the csv file (later the data in the csv file should be used to run a series of simulations).
So far I have managed to write a Tkinter gui that will read the csv file, but I'm stomping about how I should act:
from Tkinter import * import tkFileDialog import csv class Application(Frame): def __init__(self, master = None): Frame.__init__(self,master) self.grid() self.createWidgets() def createWidgets(self): top = self.winfo_toplevel() self.menuBar = Menu(top) top["menu"] = self.menuBar self.subMenu = Menu(self.menuBar) self.menuBar.add_cascade(label = "File", menu = self.subMenu) self.subMenu.add_command( label = "Read Data",command = self.readCSV) def readCSV(self): self.filename = tkFileDialog.askopenfilename() f = open(self.filename,"rb") read = csv.reader(f, delimiter = ",") app = Application() app.master.title("test") app.mainloop()
Any help is much appreciated!
source share