I have to create popup dialog box which contains text field using tkinter module in Python 2(not Python 3). My other program has many Python2 modules(I have written whole code in Python 2) and so I can't go for Python 3. Here is my code which works fine in Python 3 but not in Python 2.
from tkinter import simpledialog
from tkinter import *
def s():
print(simpledialog.askstring("hai","inp"))
root = Tk()
b = Button(root, text="popup",command=s)
b.pack()
root.geometry("400x400")
root.mainloop()
This is the error :
Exception in Tkinter callback
Traceback (most recent call last):
File "/usr/lib/python2.7/lib-tk/Tkinter.py", line 1550, in __call__
return self.func(*args)
File "popup.py", line 4, in s
print(simpledialog.askstring("hai","inp"))
AttributeError: 'module' object has no attribute 'askstring'
Please mention any alternatives to achieve this function in Python 2. Thank you