Reputation: 312
I'm making a python program with a gui using Tkinter and its Text widget. I'm using python 2.7.3 and Ubuntu 14.04.
I'm using a "Canadian multilingual" keyboard layout as seen here: http://charsetplus.tripod.com/Keyboard/Latin/ENFR-CAN.htm
When I create the Text widget, everything works fine. Minimum working example:
from Tkinter import *
root=Tk()
text_widget=Text(root)
text_widget.pack()
root.mainloop()
I can then type dead-keys and accented characters with no problem as well as accents with no letter underneath by typing either a dead-key twice, or "dead-key + space"; e.g. ^ ¨
But if I execute functions in my program or switch to an other program then go back to my text widget, I can't type dead-keys anymore.
My program is math oriented and based on LaTeX, so the circumflex character ^ is pretty much essential.
So far my workaround has been to bind "Control-h" (for hat) on the Text widget to a function that inserts the correct character in the text widget:
self.text_widget.bind('<Control-h',self.circumflex)
# [...]
def circumflex(self,event):
event.widget.insert(INSERT,'^^')
This works but is annoying, and clearly not elegant.
Any help to resolve this issue would be greatly appreciated!
Thank you!
Upvotes: 3
Views: 248
Reputation: 781
It seems to be an concurency problem when other input method than XIM is use.
There is a lot of bugs opened about this problem (especialy this one: https://code.google.com/p/ibus/issues/detail?id=526)
A workaround is to deactivate any other input method before any call to tk:
os.environ['XMODIFIERS'] = "@im=none"
Upvotes: 1