|
Error Exception in Tkinter callback
Hi, I have an error in my code:
bash-2.05b$ python NOTEPAD.py
Exception in Tkinter callback
Traceback (most recent call last):
File "/usr/lib/python2.2/lib-tk/Tkinter.py", line 1300, in __call__
return apply(self.func, args)
File "NOTEPAD.py", line 110, in set_font
self.window.config(font=font)
File "/usr/lib/python2.2/lib-tk/Tkinter.py", line 1093, in configure
self.tk.call((self._w, 'configure')
TclError: unknown option "-font"
WHAT COULD BE THE PROBLEM? THANKS
Code:
def change_font(self):
def set_font():
if self.size_check.get() == 1:
if self.font_check.get() == 1:
font = ('times', 10, 'normal')
elif self.font_check.get() == 2:
font = ('system', 10, 'normal')
elif self.font_check.get() == 3:
font = ('courier', 10, 'normal')
else:
font = ('helvetica', 10, 'normal')
elif self.size_check.get() == 2:
if self.font_check.get() == 1:
font = ('times', 12, 'normal')
elif self.font_check.get() == 2:
font = ('system', 12, 'normal')
elif self.font_check.get() == 3:
font = ('courier', 12, 'normal')
else:
font = ('helvetica', 12, 'normal')
elif self.size_check.get() == 3:
if self.font_check.get() == 1:
font = ('times', 14, 'normal')
elif self.font_check.get() == 2:
font = ('system', 14, 'normal')
elif self.font_check.get() == 3:
font = ('courier', 14, 'normal')
else:
font = ('helvetica', 14, 'normal')
else:
if self.font_check.get() == 1:
font = ('times', 18, 'normal')
elif self.font_check.get() == 2:
font = ('system', 18, 'normal')
elif self.font_check.get() == 3:
font = ('courier', 18, 'normal')
else:
font = ('helvetica', 18, 'normal')
self.window.config(font=font)
top.destroy()
top = Toplevel(width=100, height=100)
top.title("Cambio de Fuente")
top.resizable(height=0, width=0)
top.focus_set()
self.size_check = IntVar()
self.size_check.set(2)
self.font_check = IntVar()
self.font_check.set(1)
self.style_check = IntVar()
self.style_check.set(1)
size_1 = Radiobutton(top, text="10", variable=self.size_check, value=1)
size_2 = Radiobutton(top, text="12", variable=self.size_check, value=2)
size_3 = Radiobutton(top, text="14", variable=self.size_check, value=3)
size_4 = Radiobutton(top, text="18", variable=self.size_check, value=4)
font_1 = Radiobutton(top, text="Times", variable=self.font_check, value=1)
font_2 = Radiobutton(top, text="System", variable=self.font_check, value=2)
font_3 = Radiobutton(top, text="Courier", variable=self.font_check, value=3)
font_4 = Radiobutton(top, text="Helvetica", variable=self.font_check, value=4)
size_1.grid(row=0, column=0)
size_2.grid(row=0, column=1)
size_3.grid(row=0, column=2)
size_4.grid(row=0, column=3)
font_1.grid(row=1, column=0)
font_2.grid(row=1, column=1)
font_3.grid(row=1, column=2)
font_4.grid(row=1, column=3)
cancel = Button(top, width=6, text="cancel", command=top.destroy, relief=RIDGE)
cancel.grid(row=2, column=1)
ok = Button(top, width=6, text="ok", command=set_font, relief=RIDGE)
ok.grid(row=2, column=2)
|