473,545 Members | 2,812 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Tkinter and utf-8

What font is Tkinter using for displaying utf-8 characters?

On my Windows XP, most of the characters with names (unicodedata.na me)
are displayed WYSIWYG.
However, on my Mandrake (warning: Linux newbie), most characters are
displayed as \u???? where ???? is the Hex code.

## start of script Tkinter_gui.py----------
import Tkinter
import ScrolledText
import codecs
import tkFont

##FONT = 'Courier'

class MyFrame(Tkinter .Frame):
def __init__(self, master=None):
self.root = master
Tkinter.Frame._ _init__(self, master)
self.pack(fill= Tkinter.BOTH, expand=1)
## self.textBox = ScrolledText.Sc rolledText(self , font=(FONT, 12))
self.textBox = ScrolledText.Sc rolledText(self ,
font=tkFont.Fon t(size=12))
self.textBox.pa ck(fill=Tkinter .BOTH, expand=1)

def write(self, txt):
self.textBox.in sert(Tkinter.EN D, txt)
self.textBox.se e(Tkinter.END)
self.textBox.up date_idletasks( )

if __name__ == '__main__':
root = Tkinter.Tk()

frame = MyFrame(root)

f = codecs.open('na med.txt', 'r', 'utf-8')
frame.write('\n '.join(f.read() .splitlines()))
f.close()

root.minsize(64 0, 480)
Tkinter.mainloo p()
## end of script ----------

Python 2.3.3 (#2, Feb 17 2004, 11:45:40)
[GCC 3.3.2 (Mandrake Linux 10.0 3.3.2-6mdk)] on linux2

and

Python 2.2.2 (#37, Oct 14 2002, 17:02:34) [MSC 32 bit (Intel)] on win32
MS Windows XP SP2

Please CC me directly as I am not subscribed

BTW, tried to e-mail directly (with 2 jpeg screenshots and the named.txt file)
but got the following:

This is an automatically generated Delivery Status Notification

Delivery to the following recipient failed permanently:

py*********@pyt hon.org

Technical details of failure:
PERM_FAILURE: SMTP Error (state 13): 553 rejected, message looks like spam.
Jul 18 '05 #1
7 4345
Hi !

In XP (and 2000), the display of unicode use the uniscribe motor. But the
standards win's versions are not (all) in top level. You MUST install more
recent version.

I had do this update, and, now, I can use really unicode in Windows (samples
: directory name in unicode, in windows explorer).
Sample code of tk display of unicode string :

root = Tk()
myFont = tkFont.Font(siz e=18)
w = Label(root, text=unicodstri ng, font=myFont)
w.pack()
root.mainloop()

Aaah ! Last "truc" : uniscribe is in USP10.DLL (look the version)


*sorry for my bad english*
@-salutations
--
Michel Claveau

Jul 18 '05 #2
Michel Claveau writes:
In XP (and 2000), the display of unicode use the uniscribe motor. But the
standards win's versions are not (all) in top level. You MUST install more
recent version.


Thank you.
Found a page on microsoft.com about Uniscribe and will be reading it
thoroughly.

Any tips for a Mandrake newbie for getting a few more characters displayed
WYSIWYG?
I am actually considering writing a replacement for SC UniPad which we use on
our Windows boxes.
Jul 18 '05 #3
Justin Ezequiel wrote:
Any tips for a Mandrake newbie for getting a few more characters displayed
WYSIWYG?


What characters specifically are you missing? In general, the answer is
"install more fonts". Tk is pretty smart in finding the right font,
provided an appropriate font is available. Do xlsfonts(1) to see whether
you have a good number of fonts installed. On my system, I get

martin@mira:~/work/py2.4/Lib$ xlsfonts|wc
8317 10959 495020

and I'm confident that Tk would display any character I could ever
encounter.

Regards,
Martin
Jul 18 '05 #4
Among others, I am missing characters in the range
017F 383 LATIN SMALL LETTER LONG S
to
036F 879 COMBINING LATIN SMALL LETTER X

my xlsfonts numbers:
448 539 24261

I'll get some help here re obtaining fonts.
Thank you.
Jul 18 '05 #5
Hi !
Mandrake newbie


What is Mandrake ? The magician ? A comic personn ?
I am not in love with Linux... ;o)
Michel Claveau


Jul 18 '05 #6
Justin Ezequiel <je*******@gmai l.com> wrote:
Among others, I am missing characters in the range
017F 383 LATIN SMALL LETTER LONG S
to
036F 879 COMBINING LATIN SMALL LETTER X my xlsfonts numbers:
448 539 24261
The numbers don't help a lot, but you can use xlsfonts to get better
information. Unicode encoding is 'iso10646-1', so do

xlsfonts -fn '*iso10646*'

to see what unicode fonts you have in the first place. Adding -lll
will list metrics for each character, so do (for example)

xlsfonts -lll -fn '*iso10646*' | grep 0x17f

to see all the metrics for LATIN SMALL LETTER LONG S. If any of these
have non-zero metrics, the character is available. Inspect the full
output to find the complete font name, and use 'xfd' to display the
font. On my system, for example, all *misc* fonts have this character,
but the *helvetica* fonts don't.

Finally, you have to make sure Tk uses the fonts. IIRC Tkinter allows
you to access the Tk option database, so set the font options
with X-style names. That should do the trick, but I didn't check.
I'll get some help here re obtaining fonts.
Thank you.


I use Debian, not Mandrake, but you should be able to download Mandrake
packages for fonts somewhere, if necessary. Make sure there is no version
clash with the X server you are using.

- Dirk
Jul 18 '05 #7
Dirk Thierbach writes:
xlsfonts -lll -fn '*iso10646*' | grep 0x17f

to see all the metrics for LATIN SMALL LETTER LONG S. If any of these
have non-zero metrics, the character is available. Inspect the full
output to find the complete font name, and use 'xfd' to display the
font. On my system, for example, all *misc* fonts have this character,
but the *helvetica* fonts don't.
Thanks, I will try this.
Finally, you have to make sure Tk uses the fonts. IIRC Tkinter allows
you to access the Tk option database, so set the font options
with X-style names. That should do the trick, but I didn't check.


Will have to research how this is done.
Thanks again.

BTW, in the meantime, I've copied and installed 'Arial Unicode MS' from my
WinXP box.
Explicitly telling Tkinter to use that font seems to work just find here on my
Mandrake box but I am uneasy about the legality of this.
Jul 18 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
5784
by: Jörg Maier | last post by:
Hey guys, i have a big problem using Tkinter and pexpect in cygwin. i try to program an winscp-like rsync Program for all posix Platforms (linux, macosx, cygwin). i got a class SslConnection with a method listDirectory that gives back a list of an remote directory using pexpect. this method works in linux, it works in cygwin-python from...
2
3506
by: Thomas | last post by:
I was used to pass Unicode strings to Tk widgets. IIRC, Tcl/Tk expects UTF-8 encoded strings, but Tkinter took care of that. This worked, as long as I was using Python/Tk on Red Hat 9 Linux (and on earlier versions). Now I switched to Fedora Core 1 Linux (where Python/Tk does not work without fixing it - but I described that in another...
1
2786
by: Eric Brunel | last post by:
Hi all, I'm in the process of localizing a Tkinter application and I'm struggling with a problem for which I can't figure out a solution. The following code: ------------------------------- from Tkinter import * root = Tk() root.tk.call('encoding', 'system', 'utf-8')
2
510
by: duane voth | last post by:
> #to control asyncore > while 1: > asyncore.loop(.1) > if not fromgui.empty(): > #handle messages from GUI The above doesn't work for me - asyncore.loop(<anything>) always blocks. The asyncore.poll(timeout=0.01) functions however works fine. Thus I have: while 1:
5
10563
by: Ali | last post by:
I was wondering how one would go about displaying unicode in a Label object in a Tkinter window. I am trying to display text in another language. Please help.
1
2241
by: Pekka Niiranen | last post by:
Hi there, after reading TkInter/thread -recipe: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/82965 I wondered if it was possible to avoid using threads for the following problem: I have script started from W2K console that normally prints ascii messages to the screen. However, I have command line "debug" -flag that might...
0
13442
bartonc
by: bartonc | last post by:
You can find the original author of the script by ggling " Py2Exe version 6.3 setup" The cool thing about this is that it calls py2exe, just in case you're uncomfortable with the command line. I had to search hi and lo for the example of how to exclude Tkinter. Coming soon: scipy includes and numpy include that gets rid of complaints of missing...
6
2362
by: Juha S. | last post by:
Hi, I'm writing a small text editor type application with Python 2.5 and Tkinter. I'm using the Tk text widget for input and output, and the problem is that when I try to save its contents to a .txt file, any Scandinavian letters such as "äöå ÄÖÅ" are saved incorrectly and show up as a mess when I open the .txt file in Windows Notepad. ...
0
998
by: Eric Brunel | last post by:
On Thu, 02 Oct 2008 21:57:01 +0200, kib2 <kib2@free.frwrote: Tk/Tkinter apparently considers the position 1.13 to be after the last word in the text. You get the same problem if you set the insertion point just after the word 'two' for example: text.index('insert') returns 1.7 and text.index('insert wordstart') returns 1.7 too... My...
0
7434
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7692
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7946
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7457
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6026
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5360
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3470
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1045
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
744
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.