I am trying to 'get' the newIPEntry and the newLocationEntry variables in my Python with Tkinter program, however I am faced with the error you see below. I have already searched here as I was writing this question, to get the answer after pulling my hair out from frustration of trying to figure it out by myself and searching for a solution for the last couple of days. I found the solution, however, I do not know how to fit the syntax of that solution(Getters in python, tkinter) into my current program partly presented here. I do not know how to proceed to take what I have already written and rewrite it to be similar to the solution I have linked.
def fixEntries(thisKVM, newIP, newLocation):
newIP = newIPEntry.get(newIPEntry)
newLocation = newLocationEntry.get(newLocationEntry)
a_file = open("kvmIPDefs.py", "r")
ipUpdate = a_file.readlines()
ipUpdate[thisKvm] = "kvm"+ thisKVM + "IP = \'" + newIP + "\'\n"
a_file = open("kvmIPDefs.py", "w")
a_file.writelines(ipUpdate)
a_file.close()
a_file = open("kvmLocDefs.py", "r")
locUpdate = a_file.readlines()
locUpdate[thisKvm] = "kvm"+ thisKVM + "Loc = \'" + newLocation + "\'\n"
a_file = open("kvmLocDefs.py", "w")
a_file.writelines(locUpdate)
a_file.close()
def editKVM(self):
editor = Tk()
thisKVM = self
editor.title('Edit KVM' + thisKVM)
editor.geometry("200x150")
global newIPEntry
global newLocationEntry
newIPEntry = StringVar()
newLocationEntry = StringVar()
frame = LabelFrame(editor, text="", padx=5, pady=5)
frame.grid(padx=10, pady=10)
newIPLabel = Label(frame, text="NEW IP", font=("Times", 12, "bold")).grid(row=0, column=0, columnspan=2)
newIPEntry = Entry(frame, textvariable=newIPEntry).grid(row=1, column=0, columnspan=2)
newLocationLabel = Label(frame, text="NEW LOCATION", font=("Times", 12, "bold")).grid(row=2, column=0, columnspan=2)
newLocationEntry = Entry(frame, textvariable=newLocationEntry).grid(row=3, column=0, columnspan=2)
editButton = Button(frame, text="EDIT", font=("Times", 12), padx=1, command=lambda: fixEntries(thisKVM, newIPEntry, newLocationEntry)).grid(row=4, column=0, columnspan=4, ipadx=30)
AttributeError: 'NoneType' object has no attribute 'get'