font display problem in IDLE

Kirill Simonov kirill at xyz.donetsk.ua
Wed Oct 3 22:04:38 CEST 2001


On Wed, Oct 03, 2001 at 10:45:48AM -0700, Oktay Safak wrote:
> 
> I use sitecustomize.py to use turkish encoding, the
> console gets it right but on IDLE, the characters
> special to my language are not displayed properly,
> some other funny characters are shown instead. When I
> write some text to a file and inspect the file with
> notepad I see that the characters are OK. So IDLE does
> what I want but does not show it properly. I tried to
> configure IDLE by changing the font it uses for
> display from its config file but somehow a sans-serif
> font shows up instead of courier new, and it still
> shows the wrong encoding. Any ideas? German and French
> fellows might have had a similar problem I guess.
>

I expect that you use Python 2.1 on Windows.

The recipe is:

Step 1:
Open file "Python21/Lib/lib-tk/FixTk.py", remove all lines and write the
following code:

import sys, os
if not os.environ.has_key('TCL_LIBRARY'):
    tcl_library = os.path.join(sys.prefix, "tcl", "tclX.Y")
    os.environ['TCL_LIBRARY'] = tcl_library

Step 2:
Open file "Python21/Tools/idle/Percolator.py", go to the line 23.
You need to insert two lines of code into the function "insert":

     def insert(self, index, chars, tags=None):
         # Could go away if inheriting from Delegator
         if index != 'insert':          # You need to add
            chars = unicode(chars)      # these lines.
         self.top.insert(index, chars, tags)

Step 3:
Open file "Python21/Tools/idle/PyShell.py", go to the line 470.
You need to add two lines:

         line = self.text.get("iomark", "end-1c")
         if type(line) == type(u""):    # You need to add
             line = line.encode()       # these lines.
         self.resetoutput()

And please tell me, does this recipe solves your problem?


\Xi





More information about the Python-list mailing list