Python Code Error with Tkinter? -
when try run code gives me nasty error:
exception in tkinter callback traceback (most recent call last): file "c:\python33\lib\tkinter\__init__.py", line 1475, in __call__ return self.func(*args) file "e:\tkinter\count_num_challenge.py", line 39, in count_num num in range(start, end): typeerror: 'entry' object cannot interpreted integer please don't know wrong! tried int() around entry did not work either if guys can me out great. in need of assistance
from tkinter import * class application(frame): def __init__(self, master): super(application, self).__init__(master) self.grid() self.create_widgets() def create_widgets(self): # create instruction label label(self, text = "enter starting number ending number." ).grid(row = 0, column = 0, sticky = w) # create entry box starting/ending self.starting_num = entry(self) self.starting_num.grid(row = 2, column = 0, sticky = w) self.ending_num = entry(self) self.ending_num.grid(row = 3, column = 0, sticky = w) # create text box self.result_txt = text(self, width = 20, height = 10, wrap = word) self.result_txt.grid(row = 4, column = 0, columnspan = 1) # submit button button(self, text = "count numbers", command = self.count_num ).grid(row = 5, column = 0, sticky = w) def count_num(self): start = self.starting_num end = self.ending_num num in range(start, end): print(num) self.result_txt.delete(0.0, end) self.result_txt.insert(0.0, count_num) # main root = tk() root.title("count numbers") app = application(root) root.mainloop()
in code, self.starting_num instance of entry widget, trying use if number error message telling you.
i'm going guess intent use value of entry widget, in case need use start=int(self.starting_num.get()), though need handle case entry emply or has non-digits in it. same goes ending_num
Comments
Post a Comment