[PyCrust] European Keyboard Issues
Brought to you by:
pobrien
From: Patrick K. O'B. <po...@or...> - 2001-11-29 19:46:08
|
Can anyone offer suggestions on the best way to handle the issues explained in the message below? Thanks. --- Patrick K. O'Brien Orbtech.com - Your Source For Python Development Services -----Original Message----- From: Jean-Michel Fauth [mailto:jm...@bl...] Sent: Thursday, November 22, 2001 4:10 PM To: po...@or... Subject: PyCrust - patch Hello Patrick K. O'Brien Subject: PyCrust - I cooked your pie five minutes more... 1) I only have a phone connection. That's why I send this message directly to you mail address. Sourceforge is slow and I don't undestand very well how it works. 2) I am a new pythonist and find this language very nice (and powerfull). I tested all the editors, IDE, development tools... I could find on the web. After some personal tests, I decided to stay on wxPython and python of course. wxPython seems to be a brilliant work, it does everything I need and even more. I specially appreciate all the stuff for printing: wxPreviewCanvas, wxPrintData,... All these things that I cann't do with tkinter. For larger application, I am using wscite, the Scintilla editor (very good). One of the good points with python, it is the interpreter and its interactive window. I am not really happy with IDLE or IDLE-fork. PyCrust comes just in time for me. 3) I am using Python 2.1.1, wxPython 2.3.1 and window 98SE 4) PyCrust works fine on my machine, except for one point. It can not be used by people, who have an european keyboard. I mean a keyboard where you have to press Ctrl+Alt (or the special key AltGr, that combines both keys) in order to get the following characters: #, ¦ @ [ ] { } \ |. As you can see, these chars are quite important! If you cann't type them, bye, bye Python and PyCrust. I do know how many people are using PyCrust or PyShell, but I didn't find any people complaining about that. I found a solution, that's the reason for my mail. This is done in 2 steps. First, I created the following file, called kbddict.py #--------------------------------------------- # module kbddict.py # # 22 November 2001 # # - keyboard dictionnaries for european keyboards # - to be used with PyCrust and PyShell # - comment the unused langages # - tested with swiss french and swiss german # - in order to work properly, need a modification of the file shell.py #--------------------------------------------- # swiss french keyboard # mapping keys is not necessary for the dead keys ´ (219) and ~ (221) ?! kbd_dict = {51: '#', 50: '@', 49: '¦', 56: '¢', 186: '[', 192: ']', \ 220: '{', 223: '}', 226: '\\', 54: '¬', 55: '|', 69: ''} # swiss german keyboard # same as swiss french # mapping keys is not necessary for the dead keys ´ (219) and ~ (221) ?! #kbd_dict = {51: '#', 50: '@', 49: '¦', 56: '¢', 186: '[', 192: ']', \ # 220: '{', 223: '}', 226: '\\', 54: '¬', 55: '|', 69: ''} # insert other keyboard here #kbd_dict = {} #eof--------------------------------------------- This file creates dictionnaries for keys mapping. Secondly, I modified the file shell.py in the following way. In the 'import section', I added the following line: from kbddict import kbd_dict Then I modified the following method. def OnKeyDown(self, event): """Key down event handler. The main goal here is to not allow modifications to previous lines of text.""" key = event.KeyCode() ... ... ... elif key == WXK_INSERT: pass # added by jmf # keycode 219: ´and 221: ~ (dead keys) work ok !? elif event.ControlDown() and event.AltDown(): if key in kbd_dict.keys(): self.write(kbd_dict[key]) # end of added ... else: event.Skip() 5) I am speaking french and german, so I tested the both keyboards, swiss french and swiss german, with success. The keyboard list can be extended. 6) Despite the fact that it is working fine, I don't think, this is the solution to be used. The problem lies in ths wxStyledTextCtrl, this control does not manage the chars # \ @ [ ] ... correctly, the control wxTextCtrl does it! (I did not inform the wxPython.org). I noticed the same problem in the Boa constructor. Python is portable, but it must be portable for all languages and keyboards. 7) A final remark. I created an exe with py2exe. Icon are not allowed when using win98, 98SE or winME. 8) PyCrust is a delicious cake. It is certainly a good advertisement for wxPython and Python. Best regards. Jean-Michel Fauth, Martigny, Switzerland, an amateur programmer. jm...@bl... |