I am trying to link entry variables to a function within Tkinter. I have 16 entry / variables that I want to use in my function. However, I'm struggling with the interface between the entry and the assigning of the variable.
my code:
import Tkinter
import pandas as pd
import numpy as np
class simulation_tk(Tkinter.Tk):
def __init__(self,parent):
Tkinter.Tk.__init__(self,parent)
self.parent = parent
self.initialize()
def initialize(self):
self.grid()
c2_low =Tkinter.StringVar()
c3_low =Tkinter.StringVar()
ic4_low =Tkinter.StringVar()
nc4_low =Tkinter.StringVar()
ic5_low =Tkinter.StringVar()
nc5_low =Tkinter.StringVar()
neoc5_low =Tkinter.StringVar()
n2_low = Tkinter.StringVar()
c2_high =Tkinter.StringVar()
c3_high =Tkinter.StringVar()
ic4_high =Tkinter.StringVar()
nc4_high =Tkinter.StringVar()
ic5_high =Tkinter.StringVar()
nc5_high =Tkinter.StringVar()
neoc5_high=Tkinter.StringVar()
n2_high = Tkinter.StringVar()
self.entry = Tkinter.Entry(self, textvariable = c2_low).grid(column=0,row=1,sticky='EW')
self.entry = Tkinter.Entry(self, textvariable = c2_high).grid(column=0,row=2,sticky='EW')
self.entry = Tkinter.Entry(self, textvariable = c3_low).grid(column=0,row=3,sticky='EW')
self.entry = Tkinter.Entry(self, textvariable = c3_high).grid(column=0,row=4,sticky='EW')
self.entry = Tkinter.Entry(self, textvariable = ic4_low).grid(column=1,row=1,sticky='EW')
self.entry = Tkinter.Entry(self, textvariable = ic4_high).grid(column=1,row=2,sticky='EW')
self.entry = Tkinter.Entry(self, textvariable = nc4_low).grid(column=1,row=3,sticky='EW')
self.entry = Tkinter.Entry(self, textvariable = nc4_high).grid(column=1,row=4,sticky='EW')
self.entry = Tkinter.Entry(self, textvariable = ic5_low).grid(column=0,row=5,sticky='EW')
self.entry = Tkinter.Entry(self, textvariable = ic5_high).grid(column=0,row=6,sticky='EW')
self.entry = Tkinter.Entry(self, textvariable = nc5_low).grid(column=0,row=7,sticky='EW')
self.entry = Tkinter.Entry(self, textvariable = nc5_high).grid(column=0,row=8,sticky='EW')
self.entry = Tkinter.Entry(self, textvariable = neoc5_low).grid(column=1,row=5,sticky='EW')
self.entry = Tkinter.Entry(self, textvariable = neoc5_high).grid(column=1,row=6,sticky='EW')
self.entry = Tkinter.Entry(self, textvariable = n2_low).grid(column=1,row=7,sticky='EW')
self.entry = Tkinter.Entry(self, textvariable = n2_high).grid(column=1,row=8,sticky='EW')
self.resizable(False,False)
self.resizable(False,False)
button = Tkinter.Button(self,text=u"simulate")
button.bind("<Button-1>", simulation)
button.grid(column=3,row=9)
def simulation(self):
#code for this not included but uses all 16 entries/variable
if __name__ == "__main__":
app = simulation_tk(None)
app.title('Simulation')
app.mainloop()
I want the input of my entry to be assigned to a variable which can then be used in a separate function (simulation)
grids to another line aswell). You can get contents ofEntryby callingself.entry1.get()