473,671 Members | 2,176 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 4363
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
5788
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 command-line, but invoked in an Tkinter-Program i got the strange Exception:...
2
3520
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 thread) and I have to pass UTF-8 encoded strings to Tk widgets (i.e. I cannot directly pass Unicode...
1
2805
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
10590
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
2243
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 cause printing
0
13461
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 modules that are fantom errors. # Py2Exe version 6.3 setup file for wxPython GUI programs. #...
6
2369
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. It seems that the characters will only get mixed if the user has typed them into the widget, but if...
0
1003
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 solution would simply be to go back one character before asking the word start:...
0
8912
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8819
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8669
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6222
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5692
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4403
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2809
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2049
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1807
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.