The element in justpy cannot handle the event properly

206 Views Asked by At

After running the codes provided in the tutorial of justpy

import justpy as jp

def my_click(self, msg):
    self.text = 'I was clicked'

def event_demo():
    wp = jp.WebPage()
    d = jp.Div(text='Not clicked yet', a=wp, classes='w-48 text-xl m-2 p-1 bg-blue-500 text-white')
    d.on('click', my_click)
    return wp

jp.justpy(event_demo)

I received the following errors whenever I opening the webpage on 127.0.0.1:8000. The layout of the webpage can be rendered properly, but the events of the elements cannot, i.e. the element can't be clicked.

JustPy ready to go on http://127.0.0.1:8000
ERROR base_events: Exception in callback _ProactorReadPipeTransport._loop_reading(<_OverlappedF...bits\r\n\r\n'>)
handle: <Handle _ProactorReadPipeTransport._loop_reading(<_OverlappedF...bits\r\n\r\n'>)>
Traceback (most recent call last):
  File "C:\Users\User\AppData\Local\Programs\Python\Python38\lib\asyncio\events.py", line 81, in _run
    self._context.run(self._callback, *self._args)
  File "C:\Users\User\AppData\Local\Programs\Python\Python38\lib\asyncio\proactor_events.py", line 318, in _loop_reading
    self._data_received(data)
  File "C:\Users\User\AppData\Local\Programs\Python\Python38\lib\asyncio\proactor_events.py", line 269, in _data_received
    self._protocol.data_received(data)
  File "C:\Users\User\AppData\Local\Programs\Python\Python38\lib\site-packages\uvicorn\protocols\http\h11_impl.py", line 124, in data_received
    self.handle_events()
  File "C:\Users\User\AppData\Local\Programs\Python\Python38\lib\site-packages\uvicorn\protocols\http\h11_impl.py", line 173, in handle_events
    self.handle_upgrade(event)
  File "C:\Users\User\AppData\Local\Programs\Python\Python38\lib\site-packages\uvicorn\protocols\http\h11_impl.py", line 245, in handle_upgrade
    protocol = self.ws_protocol_class(
  File "C:\Users\User\AppData\Local\Programs\Python\Python38\lib\site-packages\uvicorn\protocols\websockets\websockets_impl.py", line 62, in __init__
    super().__init__(
  File "C:\Users\User\AppData\Local\Programs\Python\Python38\lib\site-packages\websockets\legacy\server.py", line 201, in __init__
    super().__init__(**kwargs)
TypeError: __init__() got an unexpected keyword argument 'logger'

May I ask why it happens and how it can be solved? Thanks for your patience and sorry for my bad English.

1

There are 1 best solutions below

0
On

I ran into the same issue today. The solution was to update the websockets package:

pip install -U websockets

websockets is v11.0.3 in my Python environment now. Tried the sample code again, works nicely.