Mike Gasser | 4 Oct 2006 03:27
Picon
Favicon

Unicode in Tkinter in MacOS

This may be just a Mac problem, but I find that in MacOS (10.4) I can only get Tkinter to display the characters in the Latin-1 set and Japanese.  Possibly others, I don't know, but many Unicode characters display as garbage characters.  The simplest way to illustrate this is with the little Romanian "hello world" program that Jason Orendorff uses to illustrate Unicode display in Tkinter on his oft-cited "Unicode for Programmers" site: http://www.jorendorff.com/articles/unicode/python.html

###############################################
# hello-romanian.py - Demonstrates Tkinter's Unicode support
#
# This sample code accompanies the article "Unicode for Programmers"
# at http://www.jorendorff.com/articles/unicode .

from Tkinter import *
import tkFont

root = Tk()
myFont = tkFont.Font(size=18)
w = Label(root, text=u'Bun\u0103-diminea\u021ba, lume', font=myFont)
w.pack()

root.mainloop()
####################################################

The two non-Latin-1 characters in the Romanian string appear as squares.  This also happens when I explicitly set the
font family to a Unicode font like 'Arial Unicode' or 'Lucida Grande'.  Of course it's not just Romanian.  I need Ethiopic
in particular, and will need other character sets later on, and I can't get it to work.

Am I missing something?  Or is this a limitation of Tkinter in MacOS (in which case it's not going to be very useful for me)?

(I'm running Python 2.5, but this happened in 2.4 too.)

Mike Gasser
Indiana University
_______________________________________________
Tkinter-discuss mailing list
Tkinter-discuss <at> python.org
http://mail.python.org/mailman/listinfo/tkinter-discuss
mkieverpy | 4 Oct 2006 16:27
Picon

Re: Unicode in Tkinter in MacOS

Mike Gasser wrote:
> This may be just a Mac problem, but I find that in MacOS (10.4) I can
> only get Tkinter to display the characters in the Latin-1 set and
> Japanese.  Possibly others, I don't know, but many Unicode characters
> display as garbage characters.  The simplest way to illustrate this
> is with the little Romanian "hello world" program that Jason
> Orendorff uses to illustrate Unicode display in Tkinter on his oft-
> cited "Unicode for Programmers" site: http://www.jorendorff.com/
> articles/unicode/python.html
> ...

Earlier on this year or late last year I had similar problems
(with extendedA and B characters). I finally dropped the idea.
As far as I can remember from googling the web for a solution
is that this problem was/is due to brokenness of Tk (Tk Aqua) on the newer MacOSs.
A reference I just refound: http://aspn.activestate.com/ASPN/Mail/Message/tcl-mac/2865240
My problems were with Python 2.3.5 with Tcl/Tk 8.4.
I do not follow the development on MacOS regularly, so I cannot tell you the current state
of affairs.

Hope this helps,

Matthias Kievernagel
mkiever-at-web-dot-de
mkieverpy | 4 Oct 2006 16:27
Picon

Re: Unicode in Tkinter in MacOS

Mike Gasser wrote:
> This may be just a Mac problem, but I find that in MacOS (10.4) I can
> only get Tkinter to display the characters in the Latin-1 set and
> Japanese.  Possibly others, I don't know, but many Unicode characters
> display as garbage characters.  The simplest way to illustrate this
> is with the little Romanian "hello world" program that Jason
> Orendorff uses to illustrate Unicode display in Tkinter on his oft-
> cited "Unicode for Programmers" site: http://www.jorendorff.com/
> articles/unicode/python.html
> ...

Earlier on this year or late last year I had similar problems
(with extendedA and B characters). I finally dropped the idea.
As far as I can remember from googling the web for a solution
is that this problem was/is due to brokenness of Tk (Tk Aqua) on the newer MacOSs.
A reference I just refound: http://aspn.activestate.com/ASPN/Mail/Message/tcl-mac/2865240
My problems were with Python 2.3.5 with Tcl/Tk 8.4.
I do not follow the development on MacOS regularly, so I cannot tell you the current state
of affairs.

Hope this helps,

Matthias Kievernagel
mkiever-at-web-dot-de
mkieverpy | 4 Oct 2006 16:11
Picon

Re: Unicode in Tkinter in MacOS

Mike Gasser wrote:
> This may be just a Mac problem, but I find that in MacOS (10.4) I can
> only get Tkinter to display the characters in the Latin-1 set and
> Japanese.  Possibly others, I don't know, but many Unicode characters
> display as garbage characters.  The simplest way to illustrate this
> is with the little Romanian "hello world" program that Jason
> Orendorff uses to illustrate Unicode display in Tkinter on his oft-
> cited "Unicode for Programmers" site: http://www.jorendorff.com/
> articles/unicode/python.html
> ...

Earlier on this year or late last year I had similar problems
(with extendedA and B characters). I finally dropped the idea.
As far as I can remember from googling the web for a solution
is that this problem was/is due to brokenness of Tk (Tk Aqua) on the newer MacOSs.
A reference I just refound: http://aspn.activestate.com/ASPN/Mail/Message/tcl-mac/2865240
My problems were with Python 2.3.5 with Tcl/Tk 8.4.
I do not follow the development on MacOS regularly, so I cannot tell you the current state
of affairs.

Hope this helps,

Matthias Kievernagel
mkiever-at-web-dot-de
Franz Steinhaeusler | 5 Oct 2006 10:05
Picon
Picon

Applications written in TkInter

Hi,

I wonder, if there is a site with a collection
of written TkInter programs.

I did not find any summary.

for pyGtk there exist for example:

http://www.pygtk.org/applications.html

and for wxPython:

http://wiki.wxpython.org/index.cgi/wxPythonPit_Apps

--

-- 

Franz Steinhaeusler
Sorin Schwimmer | 6 Oct 2006 23:57
Picon
Favicon

(no subject)

Hi All,

I am trying to use a textbox in an undecorated window. It works under Windows, it fails under Linux. Here is a test code:

<code>
from Tkinter import *

root=Tk()

root['bg']='' # transparent background
root.overrideredirect(1) # get rid of border
root.geometry("+80+120") # place on screen

root.focus_set() # take focus

bt=Button(text="End",command=root.quit)
bt.grid(row=0, stick=E) # a button to allow window's closure
tx=Text(bg='white',height=3)
tx.grid() # a text widget
tx.focus() # give focus to text

root.mainloop()
</code>

Under Linux, only mouse events are acknowledged, while the keyboard is ignored. How should I proceed?

Thanks for you advice,
Sorin

_______________________________________________
Tkinter-discuss mailing list
Tkinter-discuss <at> python.org
http://mail.python.org/mailman/listinfo/tkinter-discuss
Metz, Bobby W, WWCS | 7 Oct 2006 00:42
Picon
Favicon

Re: (no subject)

Don't know if this will make a difference, but try two things.
 
1st, turn off the overrideredirect and see if that changes anything.  I've seen strange things with that before which caused some widgets to not behave properly at random times.
 
2nd, you could explicitly set the Tx master=root.  I'm not sure that matters, but just a stab.
 
B
 
 

From: tkinter-discuss-bounces <at> python.org [mailto:tkinter-discuss-bounces <at> python.org] On Behalf Of Sorin Schwimmer
Sent: Friday, October 06, 2006 2:58 PM
To: tkinter-discuss <at> python.org
Subject: [Tkinter-discuss] (no subject)

Hi All,

I am trying to use a textbox in an undecorated window. It works under Windows, it fails under Linux. Here is a test code:

<code>
from Tkinter import *

root=Tk()

root['bg']='' # transparent background
root.overrideredirect(1) # get rid of border
root.geometry("+80+120") # place on screen

root.focus_set() # take focus

bt=Button(text="End",command=root.quit)
bt.grid(row=0, stick=E) # a button to allow window's closure
tx=Text(bg='white',height=3)
tx.grid() # a text widget
tx.focus() # give focus to text

root.mainloop()
</code>

Under Linux, only mouse events are acknowledged, while the keyboard is ignored. How should I proceed?

Thanks for you advice,
Sorin

_______________________________________________
Tkinter-discuss mailing list
Tkinter-discuss <at> python.org
http://mail.python.org/mailman/listinfo/tkinter-discuss
mkieverpy | 7 Oct 2006 10:29
Picon

Re: Textbox in undecorated window (was - no subject -)

Sorin Schwimmer wrote:
>I am trying to use a textbox in an undecorated window. It works under Windows, it fails under Linux.
>Here is a test code:
> ...

The code works fine for me. What does not work?
SuSE Linux 9.x, Python 2.4.1, Tk/Tcl 8.4.6, X11 with twm.

What's your Linux configuration?

Matthias Kievernagel
mkiever at web dot de
Sorin Schwimmer | 7 Oct 2006 21:28
Picon
Favicon

Re: Textbox in undecorated window (was - no subject -)

Hi again,

Thanks Bobby, thanks Mathias. Sorry for forgeting to type the subject.

Right now I have the piece of code working with the overrideredirect commented out. It's not the way I wanted, but it's working. Setting the master explicitely to root doesn't help.

My configuration is Gentoo (kernel 2.6.11), Python 2.4., Tcl/Tk 8.4.? (don't know how to find out the third digit), KDE 3.3 (3.4 on some other machines). What I try to accomplish is to be able to edit some text in the textbox, but not to cover too much of the screen (so the user knows the context in which the textbox was invoked and act accordingly). The problem is that my textbox is not editable.

Thanks again,
Sorin

_______________________________________________
Tkinter-discuss mailing list
Tkinter-discuss <at> python.org
http://mail.python.org/mailman/listinfo/tkinter-discuss
Sorin Schwimmer | 12 Oct 2006 17:45
Picon
Favicon

Fw: Tkinter's createfilehandler - attempt to run parallel threads

This question was posted on python-list <at> python.org, but found no answer there. Maybe here I'll be lucky...

Thanks,
Sorin

----- Forwarded Message ----
From: Sorin Schwimmer <sxn02 <at> yahoo.com>
To: python-list <at> python.org
Sent: Thursday, July 27, 2006 1:20:21 PM
Subject: Tkinter's createfilehandler - attempt to run parallel threads

Hi,

The project that I'm working for runs a PostgreSQL database on a remote machine and several Python clients all over the place. The objects usualy have in their constructor a query to the database. As the query is executed on the remote machine, I'm trying to be fancy and execute it while building my Tkinter interface.

The following code illustrates what I'm attempting to do:

<code>
#! /usr/bin/python

from pg import DB
from Tkinter import *

class thrd:
  def __init__(s,r):
    print 'Executing __init__'
    db=DB('design',host='xx.xx.xx.xx',user='yyyy') # relevant IP and user needed
    print 'db=DB(...'
    tkinter.createfilehandler(db,tkinter.READABLE|tkinter.WRITABLE,s.th)
    print 'createfile...'
    Label(r,text='Let\'s see the results').grid()
    print 'Label...'
    s.b=Button(r,text='GO')
    print 's.b=Button...'
    s.b.bind('<Button-1>',s.rslt)
    print 's.b.bind...'
    s.b.grid()
    print 's.b.grid()'
    print '__init__ done'

  def th(s,db,msk):
    print '->Executing th'
    s.r=db.query('select * from customers limit 10').getresult() # some query
    print '->s.r=...'
    tkinter.deletefilehandler(db)
    print '->deletefile...'
    db.close()
    print '->db.close()'
    print '->th done'

  def rslt(s,e):
    for i in s.r:
      print i

if __name__=='__main__':
  r=Tk()
  t=thrd(r)
  r.mainloop()
</code>

The output is:Executing __init__

<code>
db=DB(...
createfile...
Label...
s.b=Button...
s.b.bind...
s.b.grid()
__init__ done
->Executing th
->s.r=...
->deletefile...
->db.close()
->th done
</code>

and it basicly shows that everything happens sequentialy. Pressing the button gives the expected result, so everything is correct. How can I obtain the desired parallelism?

Thanks,
Sorin

Groups are talking. We´re listening. Check out the handy changes to Yahoo! Groups.


_______________________________________________
Tkinter-discuss mailing list
Tkinter-discuss <at> python.org
http://mail.python.org/mailman/listinfo/tkinter-discuss

Gmane