LinuxQuestions.org
Visit the LQ Articles and Editorials section
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 11-08-2003, 10:41 PM   #1
Gerardoj
Member
 
Registered: May 2003
Location: Somewhere over the Rainbow
Distribution: Slackware 9.x, Knoppix, Damn Small Linux, RedHat.
Posts: 465

Rep: Reputation: 30
Python and Tkinter Error


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)
 
Old 11-08-2003, 10:52 PM   #2
Gerardoj
Member
 
Registered: May 2003
Location: Somewhere over the Rainbow
Distribution: Slackware 9.x, Knoppix, Damn Small Linux, RedHat.
Posts: 465

Original Poster
Rep: Reputation: 30
Sorry, I fixed, the problem was self.window.config(font=font)
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
tkinter integration to python 2.3.4 gaddargarson Programming 1 03-09-2005 05:58 AM
Python / Tkinter : 2 quick questions infidel Programming 0 12-31-2004 05:19 PM
Python and Tkinter 1337 Twinkie Fedora 2 08-03-2004 12:35 PM
Python: Tkinter. Chu Programming 0 11-10-2003 02:56 AM
importing trouble....python...regarding Tkinter maseby Programming 0 11-03-2003 02:54 PM


All times are GMT -5. The time now is 06:46 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration