I am using Tkinter and I am having trouble with the get method. I saw that it was a common issue (here for example 'NoneType' object has no attribute 'get') but I don't really understand how to fix it.
I thought that station_I.get() was suppose to return a string variable but apparently I was wrong.
What is this issue due to ?
PS: I am using Tkinter with Python 2.7
Here is the error I get:
Exception in Tkinter callback
Traceback (most recent call last):
File "C:\Users\python\Anaconda2\lib\lib-tk\Tkinter.py", line 1542, in __call__
return self.func(*args)
File "C:/Users/python/Documents/project.py", line 168, in path
print station_I.get()
AttributeError: 'NoneType' object has no attribute 'get'
Here is my code:
from Tkinter import *
import ttk
def path():
print station_I.get()
window = Tk()
stations = ["1","2","3"]
text = StringVar()
text.set("Path: ")
station_I = ttk.Combobox(window, values = stations).place(x=50, y=50)
station_F = ttk.Combobox(window, values = stations).place(x=50, y=100)
bouton = Button(window, command = path, text = "Calculate").place(x=125,y=150)
label = Label(window, textvariable = text).place(x=50,y=225)
window.geometry("330x400")
window.mainloop()