Mar-24-2017, 07:19 PM
(This post was last modified: Mar-24-2017, 07:37 PM by BlazingD4NG3R.)
Hey so I am learning python and i am doing stuff with tkinter and GUIs. I am trying to make a quiz however there is an error and i dont quite know how to fix it. the error is on line 21 and here is what it says
Exception in Tkinter callback
Traceback (most recent call last):
File "C:\Users\Invate\AppData\Local\Programs\Python\Python36-32\lib\tkinter\__init__.py", line 1699, in __call__
return self.func(*args)
File "C:/Users/Invate/Desktop/Stuff/quiz.py", line 21, in click2
output.delete(0.0, END)
File "C:\Users\Invate\AppData\Local\Programs\Python\Python36-32\lib\tkinter\__init__.py", line 2673, in delete
self.tk.call(self._w, 'delete', first, last)
_tkinter.TclError: bad entry index "0.0"
it happens when i run and press the get answers button i made.
PLEASE HELP ME I REALLY WANT TO COMPLETE THIS SO I CAN MOVE ON!
Exception in Tkinter callback
Traceback (most recent call last):
File "C:\Users\Invate\AppData\Local\Programs\Python\Python36-32\lib\tkinter\__init__.py", line 1699, in __call__
return self.func(*args)
File "C:/Users/Invate/Desktop/Stuff/quiz.py", line 21, in click2
output.delete(0.0, END)
File "C:\Users\Invate\AppData\Local\Programs\Python\Python36-32\lib\tkinter\__init__.py", line 2673, in delete
self.tk.call(self._w, 'delete', first, last)
_tkinter.TclError: bad entry index "0.0"
it happens when i run and press the get answers button i made.
from tkinter import * import random window = Tk() window.title("Quiz") question = "" def click(): questions = list(questionslist.keys()) question = random.choice(questions) question1.insert(END, question) def click1(): questions = list(questionslist.keys()) question = random.choice(questions) question1.delete(0.0, END) question1.insert(END, question) def click2(): output.delete(0.0, END) try: answers = questionslist[question] except: answers = "There is no entry for this word." output.insert(END, answers) b = "Get Question" getquestion1 = Button(window, text=b, width=10, command=click1).grid(row=0, column=0, sticky=W) b2 = "Get Answer" getquestion1 = Button(window, text=b2, width=10, command=click2).grid(row=3, column=0, sticky=W) question1 = Text(window, width=40, height=3, wrap=WORD, background="light green") question1.grid(row=2, column=0, columnspan=2, sticky=W) output = Entry(window, width=75, bg="light green") output.grid(row=4, column= 0, sticky=W) questionslist = { 'What is 1+1?': "2" } window.mainloop()
PLEASE HELP ME I REALLY WANT TO COMPLETE THIS SO I CAN MOVE ON!