•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the Python section within the Software Development category of DaniWeb, a massive community of 361,875 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,367 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Python advertiser:
Views: 1369 | Replies: 6
![]() |
•
•
Join Date: Apr 2007
Posts: 2
Reputation:
Rep Power: 0
Solved Threads: 0
I have a problem is phasing the extended charactors in TK(). Any help would be apreciated.
a='itself ‘a parody’.'
>>> a "return"
'itself \x91a parody\x92.'
>>> def display(data):
root = Tk()
scrollbar = Scrollbar(root)
myTextWidget= Text(root,yscrollcommand=scrollbar.set)
myTextWidget.insert(0.0, data)
scrollbar.config(command=myTextWidget.yview)
scrollbar.pack(side=RIGHT, fill=Y)
myTextWidget.pack(side=LEFT, expand=0, fill=BOTH)
>>> display(a)
I ended up geting " itself ムa parodyメ." as my result and I need the result to be "itself ‘a parody’."
a='itself ‘a parody’.'
>>> a "return"
'itself \x91a parody\x92.'
>>> def display(data):
root = Tk()
scrollbar = Scrollbar(root)
myTextWidget= Text(root,yscrollcommand=scrollbar.set)
myTextWidget.insert(0.0, data)
scrollbar.config(command=myTextWidget.yview)
scrollbar.pack(side=RIGHT, fill=Y)
myTextWidget.pack(side=LEFT, expand=0, fill=BOTH)
>>> display(a)
I ended up geting " itself ムa parodyメ." as my result and I need the result to be "itself ‘a parody’."
Hi,
to get the actual characters you need to specify the character encoding. Make sure when use/deal with non-ascii character you specify the encoding type.
So label displaying the text you wanted...
There are many encodings that Python supports. I have used UTF-8(UNICODE Tranformation Format).
To learn/know more about this you can go through the following link.
http://www.amk.ca/python/howto/unicode
kath.
•
•
•
•
I ended up geting " itself ムa parodyメ." as my result and I need the result to be "itself ‘a parody’."
to get the actual characters you need to specify the character encoding. Make sure when use/deal with non-ascii character you specify the encoding type.
So label displaying the text you wanted...
Python Syntax (Toggle Plain Text)
# -*- coding: UTF-8 -*- from Tkinter import * root = Tk() Label(root, text = "itself ‘a parody’.").pack() root.mainloop()
There are many encodings that Python supports. I have used UTF-8(UNICODE Tranformation Format).
To learn/know more about this you can go through the following link.
http://www.amk.ca/python/howto/unicode
kath.
challenge the limits
•
•
Join Date: Apr 2007
Posts: 2
Reputation:
Rep Power: 0
Solved Threads: 0
Thanks for the advice. It seems that I have to spend more time in encoding to get this to work.
The strange thing that I do not understand is when I do the below it is ok.
>>> text = "itself ‘a parody’."
>>> print text
itself ‘a parody’.
But when I display via Tkinter I will have a difference result like " itself ムa parodyメ.".
To me it is really strange that even a print statment can manage the characters but not via Tkinter...
The strange thing that I do not understand is when I do the below it is ok.
>>> text = "itself ‘a parody’."
>>> print text
itself ‘a parody’.
But when I display via Tkinter I will have a difference result like " itself ムa parodyメ.".
To me it is really strange that even a print statment can manage the characters but not via Tkinter...
•
•
Join Date: Oct 2004
Location: Mojave Desert
Posts: 2,275
Reputation:
Rep Power: 8
Solved Threads: 167
The problem is that US keyboards don't have a left and right singlequote character, so you need to escape the hex value of the character. This works in Python ...
If you feed string x to Tkinter's tcl language you get this --> "itself a parody."
In the USA at least it looks like you have to use the alt-key and keypad thingy and type 0145 and 0146 to construct your string. I do that with spanish characters.
python Syntax (Toggle Plain Text)
x = 'itself \x91a parody\x92.' print x # itself ‘a parody’.
In the USA at least it looks like you have to use the alt-key and keypad thingy and type 0145 and 0146 to construct your string. I do that with spanish characters.
Last edited by vegaseat : Apr 2nd, 2007 at 8:27 pm.
May 'the Google' be with you!
•
•
•
•
Thanks for the advice. It seems that I have to spend more time in encoding to get this to work.
The strange thing that I do not understand is when I do the below it is ok.
>>> text = "itself ‘a parody’."
>>> print text
itself ‘a parody’.
But when I display via Tkinter I will have a difference result like " itself ムa parodyメ.".
To me it is really strange that even a print statment can manage the characters but not via Tkinter...
Well even i am not quite sure about it. But Tkinter is a Python module for GUI. It is object-oriented layer on top of Tcl/Tk.
Tcl is a scripting language which comes with graphical extension called Tk. Through so called “bindings”, Tk can be used under other languages, such as Perl, Python, and Ruby.
And python installation packages available in forms, i.e, ansi and unicode. If you have used unicode format, then your IDE will print what you said above. Because it uses utf-8 as its default encoding.
So when used with Tkinter, undelying Tcl/Tk might interpret differently.
someone correct me if i am wrong somewhere..
thank you,
kath.
challenge the limits
![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
•
•
•
•
DaniWeb Python Marketplace
- Two monitors displaying identical image? (Monitors, Displays and Video Cards)
- Humor for those of us that can use it (Geeks' Lounge)
- Identifying Drivers needed (Windows 9x / Me)
Other Threads in the Python Forum
- Previous Thread: Triggering concurrent ftp processes in background
- Next Thread: Help - recursive



Linear Mode