[wxPython] Cannot type [] nor {} in StyledTextCtrl

Hello,

trying to use wxStyledTextCtrl, i have just realized that i cannot type [, ], { nor }.

I am using Python 2.0 and wxPython 2.2.1 on W98. Keyboard is set to Spanish.

(To type those characters, i must press AltGr key. i don’t know if this is important)

I have tested that typing Alt+ascii code does work right (e.g. typing Alt + 123 inserts ‘{’).

I have also tested than keystrokes are trapped by a KEY_UP event.

Can anybody help? Thanks in advance.

This is the code i am using to test this:

from wxPython.wx import *
from wxPython.stc import *

import keyword

class TestSTC(wxStyledTextCtrl):
def init(self, parent, ID):
wxStyledTextCtrl.init(self, parent, ID)
EVT_KEY_UP(self, self.OnKeyPressed)

def OnKeyPressed(self, event):
key = event.KeyCode()
print key

if name == ‘main’:
import sys
app = wxPySimpleApp()
frame = wxFrame(None, -1, “Editor”, size=(640, 480))
ed = TestSTC(frame, -1)
frame.Show(true)
app.MainLoop()

Josu.

trying to use wxStyledTextCtrl, i have just realized that i
cannot type [, ],{ nor }. I am using Python 2.0 and wxPython
2.2.1 on W98. Keyboard is set to Spanish.

(To type those characters, i must press AltGr key. i don't know
if this is important)

I don't have anything but a US keyboard, butI think I have found the
problem. The EVT_CHAR handler is not passing the key to Scintilla if the
alt key is down. I'm assuming that AltGr will also set this flag. I've
made a change to the wxSTC code, but until a new release is made you can try
catching EVT_CHAR with a handler that looks like this as a work around:

def OnChar(self, evt):
    evt.m_altDown = false
    evt.Skip()

···

--
Robin Dunn
Software Craftsman
robin@AllDunn.com
http://wxPython.org Java give you jitters?
http://wxPROs.com Relax with wxPython!

_______________________________________________
wxPython-users mailing list
wxPython-users@lists.sourceforge.net
http://lists.sourceforge.net/mailman/listinfo/wxpython-users

Thanks for your answer

> trying to use wxStyledTextCtrl, i have just realized that i
> cannot type [, ],{ nor }. I am using Python 2.0 and wxPython
> 2.2.1 on W98. Keyboard is set to Spanish.
>
> (To type those characters, i must press AltGr key. i don't know
> if this is important)

I don't have anything but a US keyboard, butI think I have found the
problem. The EVT_CHAR handler is not passing the key to Scintilla if the
alt key is down. I'm assuming that AltGr will also set this flag.

I think (not sure) that AltGr is Ctrl + Alt

I've
made a change to the wxSTC code, but until a new release is made you can

try

catching EVT_CHAR with a handler that looks like this as a work around:

def OnChar(self, evt):
    evt.m_altDown = false
    evt.Skip()

does not work for me. I have found another (silly) work around:

  def OnChar(self, event):
    key = event.KeyCode()
    try:
      car = chr(key)
      if car in '\|@#¬{}?':
        self.InsertText(self.GetCurrentPos(), car)
        self.CmdKeyExecute(wxSTC_CMD_CHARRIGHT)
    except ValueError:
      pass

    event.Skip()

Note: '\|@#¬{}?' are the characters that must be inserted with AltGr in
Spanish keyboard.

By the way, Robin, your work is impressive, but your response time on this
list is much more. Thanks again.

Josu.

···

_______________________________________________
wxPython-users mailing list
wxPython-users@lists.sourceforge.net
http://lists.sourceforge.net/mailman/listinfo/wxpython-users

Note: '\|@#¬{}?' are the characters that must be inserted with AltGr in
Spanish keyboard.

Thanks. I'll change the code to check for these explicitly. Are there any
other characters that need AltGr on other European keyboards?

···

--
Robin Dunn
Software Craftsman
robin@AllDunn.com
http://wxPython.org Java give you jitters?
http://wxPROs.com Relax with wxPython!

_______________________________________________
wxPython-users mailing list
wxPython-users@lists.sourceforge.net
http://lists.sourceforge.net/mailman/listinfo/wxpython-users

>
> Note: '\|@#¬{}?' are the characters that must be inserted with AltGr in
> Spanish keyboard.
>

Thanks. I'll change the code to check for these explicitly. Are there any
other characters that need AltGr on other European keyboards?

I'm new on this list, but I feel qualified to abswer that one at least=)

On Swedish keyboards it's @£${}\| AND ~ for combination with any char, i.e. at least ã,õ,Ã,Õ, ñ, Ñ. To get those one hits altgr+~ and then the a,o,A,O.... keys.

Hope that is of some help.

···

--
Martin Sandin
http://come.to/vague/
_______________________________________________
wxPython-users mailing list
wxPython-users@lists.sourceforge.net
http://lists.sourceforge.net/mailman/listinfo/wxpython-users