The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.
|
 |
|
Dev Shed Forums
> Programming Languages
> Python Programming
|
Error Exception in Tkinter callback
Discuss Error Exception in Tkinter callback in the Python Programming forum on Dev Shed. Error Exception in Tkinter callback Python Programming forum discussing coding techniques, tips and tricks, and Zope related information. Python was designed from the ground up to be a completely object-oriented programming language.
|
|
 |
|
|
|
|

Dev Shed Forums Sponsor:
|
|
|

November 8th, 2003, 11:45 AM
|
 |
Contributing User
|
|
Join Date: Aug 2003
Location: Somewhere over the Rainbow
Posts: 128
Time spent in forums: 3 h 54 m 28 sec
Reputation Power: 10
|
|
|
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)
|

November 8th, 2003, 01:00 PM
|
 |
Hello World :)
|
|
Join Date: Mar 2003
Location: Hull, UK
|
|
Sounds too me like there isn't an option called 'font'? I'm not big GUI guy (i should add that to my profile  , not that i'd pick Tkinter even if i was) so i can't really confirm or deny that..
Mark.
__________________
programming language development: www.netytan.com – Hula
|

November 8th, 2003, 09:52 PM
|
 |
Contributing User
|
|
Join Date: Aug 2003
Location: Somewhere over the Rainbow
Posts: 128
Time spent in forums: 3 h 54 m 28 sec
Reputation Power: 10
|
|
|
Sorry, I fixed, the problem was self.window.config(font=font)
|
Developer Shed Advertisers and Affiliates
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|