BGUI issue: 'module' object has no attribute 'OSKEY'

I need to have a robust GUI system for my game, and I think BGUI is just what I need.

But, when I try to use it with the example script given, I get this traceback error:


 line 38, in <dictcomp>
    self.keymap = {getattr(bge.events, val): getattr(bgui, val) for val in dir(bge.events) if val.endswith('KEY') or val.startswith('PAD')}
AttributeError: 'module' object has no attribute 'OSKEY'

I’ve been hunting around for a long time trying to find a solution to this particular problem, and digging through all the BGUI .py files trying to find where this line of code is.
After searching for ‘self.keymap’ in every py file in the BGUI folder, I get zero hits.

What is wrong, and how can I fix it?

It seems like you’re using an old version of BGUI

Yes. What if you delete last line of key_defs.py (sorry in your version maybe you had not this script) (OSKEY = 172)… Or change the value of OSKEY if its value != 172?

(You can download the last (I think) BGUI here: https://github.com/Moguri/bgui (download ZIP))

Yes, the newest version works just fine.
Thank you, that was quick!

What is OSKEY? It’s not mentionned here: http://www.blender.org/api/blender_python_api_2_74_0/bge.events.html, no?

It’s the windows key on Windows keyboards, not sure about other systems or layouts

Thank you!