You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jun 22, 2025. It is now read-only.
Repository navigation
This repository was archived by the owner on Jun 22, 2025. It is now read-only.
If you use Eel inside of a class, and are attempting to use class methods as exposed functions with the @eel.expose decorator, you receive an error
Traceback (most recent call last):
File "src\gevent\greenlet.py", line 716, in gevent._greenlet.Greenlet.run
File "C:\Python27\lib\site-packages\eel\__init__.py", line 241, in _process_message
return_val = _exposed_functions[message['name']](*message['args'])
TypeError: server_info() takes exactly 1 argument (0 given)
2019-08-17T05:52:30Z <Greenlet "Greenlet-0" at 0x3179c68: _process_message({u'args': [], u'call': 1.4319639678614375, u'name', <geventwebsocket.websocket.WebSocket object at 0x0)> failed with TypeError
I've addressed this by making the following changes to __init__.py:
Add a key named class_instance with a value of None to the _start_args dict.
_start_args= {
'mode': 'chrome', # What browser is used'host': 'localhost', # Hostname use for Bottle server'port': 8000, # Port used for Bottle server (use 0 for auto)'block': True, # Whether start() blocks calling thread'jinja_templates': None, # Folder for jinja2 templates'cmdline_args': ['--disable-http-cache'], # Extra cmdline flags to pass to browser start'size': None, # (width, height) of main window'position': None, # (left, top) of main window'geometry': {}, # Dictionary of size/position for all windows'close_callback': None, # Callback for when all windows have closed'app_mode': True, # (Chrome specific option)'all_interfaces': False, # Allow bottle server to listen for connections on all interfaces'disable_cache': True, # Sets the no-store response header when serving assets'class_instance': None, # Allow a class instance (i.e. self) to be passed to exposed functions
}
Add a check for _start_args['class_instance'] to the _process_message function, and prepend _start_args['class_instance'] to the function call, if it not None.
Then, when eel is used inside of a class, and is referencing class methods for exposed functions, you can start eel with class_instance=self as an option to allow those methods to work properly.
Reacted by Christoph Bühler, RobertErobert, BLOTHDARM and Vinicio Oliveira
I'm not sure this is an interface that I want to support at first impressions, but I'd love if you could share your use-case for wanting to use Eel with classes so that we can maybe hash out together if it's something I should change my mind on.
Activity
samuelhwilliams commentedon Dec 6, 2019
Hi @abovetheairwaves, thanks for sharing this.
I'm not sure this is an interface that I want to support at first impressions, but I'd love if you could share your use-case for wanting to use Eel with classes so that we can maybe hash out together if it's something I should change my mind on.