-2

I am porting an application from linux to windows. Changing the encoding from utf-8 to windows-1250 doesn't help event.keyval which reports the following message for Polish letters:

character_e = event.string UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb3 in position 0: invalid start byte

the event is for the character 'ł' etc which mingw64 interprets as utf-8 (?)

Roman Nowak
  • 3
  • 1
  • 3

1 Answers1

0

According to the documentation, event.keyval is not a string or character. It is an integer (guint to be precise), see here.

You should probably use the GDK function gdk_keyval_to_unicode to convert it. In Python that should be Gdk.keyval_to_unicode. It takes one parameter; the keyval. Like this:

character = Gdk.keyval_to_unicode(event.keyval)
Roland Smith
  • 42,427
  • 3
  • 64
  • 94