Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exception when setting exit_on_escape #1967

Closed
matham opened this issue Mar 14, 2014 · 3 comments
Closed

Exception when setting exit_on_escape #1967

matham opened this issue Mar 14, 2014 · 3 comments
Labels
Component: core-providers kivy/core easy Should be easy to fix

Comments

@matham
Copy link
Member

matham commented Mar 14, 2014

If you run the following code:

from kivy.config import Config
Config.set('kivy', 'exit_on_escape', 0)
from kivy.base import EventLoop
EventLoop.ensure_window()
Config.set('kivy', 'exit_on_escape', 1)

You'll get the following exception:

     Config.set('kivy', 'exit_on_escape', 1)
   File "C:\kivy-dev\kivy\kivy\config.py", line 313, in set
     self._do_callbacks(section, option, value)
   File "C:\kivy-dev\kivy\kivy\config.py", line 278, in _do_callbacks
     callback(section, key, value)
   File "C:\kivy-dev\kivy\kivy\core\window\__init__.py", line 801, in __exit
     WindowBase.on_keyboard.exit_on_escape = value
 AttributeError: 'instancemethod' object has no attribute 'exit_on_escape'

This post seems to describe why this is happening: https://stackoverflow.com/questions/7034063/adding-attributes-to-instancemethods-in-python. From there the fix seems to be to change WindowBase.on_keyboard.exit_on_escape = value to WindowBase.on_keyboard.__func__.exit_on_escape = value. However, they also seem to imply that it is different between python 2 and 3, so I'm not sure that is the proper fix.

@mihaineacsu
Copy link
Contributor

@matham How about using WindowBase.__dict__['on_keyboard'].exit_on_escape = value ?
This would work on both Python 2 and 3.

@matham
Copy link
Member Author

matham commented Mar 15, 2014

@mihaineacsu Submit a pr for it :)

@mihaineacsu
Copy link
Contributor

Fixed via #1970 . Can be closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: core-providers kivy/core easy Should be easy to fix
Projects
None yet
Development

No branches or pull requests

3 participants