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

local file picker example error on nicegui 2.1.0 #3695

Closed
zak-45 opened this issue Sep 7, 2024 · 2 comments
Closed

local file picker example error on nicegui 2.1.0 #3695

zak-45 opened this issue Sep 7, 2024 · 2 comments
Labels
documentation Improvements or additions to documentation
Milestone

Comments

@zak-45
Copy link

zak-45 commented Sep 7, 2024

Description

Hi,

just tested the local_file_picker example and got this error when click on OK after selected a file :

JavaScript did not respond within 1.0 s

Traceback (most recent call last):
  File "C:\Program Files\Python311\Lib\asyncio\tasks.py", line 500, in wait_for
    return fut.result()
           ^^^^^^^^^^^^
  File "C:\Program Files\Python311\Lib\asyncio\locks.py", line 213, in wait
    await fut
asyncio.exceptions.CancelledError

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "C:\Users\zak-4\PycharmProjects\WLEDVideoSync\.venv\Lib\site-packages\nicegui\javascript_request.py", line 26, in __await__
    yield from asyncio.wait_for(self._event.wait(), self.timeout).__await__()
  File "C:\Program Files\Python311\Lib\asyncio\tasks.py", line 502, in wait_for
    raise exceptions.TimeoutError() from exc
TimeoutError

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "C:\Users\zak-4\PycharmProjects\WLEDVideoSync\.venv\Lib\site-packages\nicegui\events.py", line 417, in wait_for_result
    await result
  File "C:\Users\zak-4\PycharmProjects\WLEDVideoSync\zla.py", line 82, in _handle_ok
    rows = await ui.run_javascript(f'getElement({self.grid.id}).gridOptions.api.getSelectedRows()')
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\zak-4\PycharmProjects\WLEDVideoSync\.venv\Lib\site-packages\nicegui\client.py", line 209, in send_and_wait
    return await JavaScriptRequest(request_id, timeout=timeout)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\zak-4\PycharmProjects\WLEDVideoSync\.venv\Lib\site-packages\nicegui\javascript_request.py", line 28, in __await__
    raise TimeoutError(f'JavaScript did not respond within {self.timeout:.1f} s') from e
TimeoutError: JavaScript did not respond within 1.0 s

The double-click work as expected....

This not happened on nicegui 1.4.37, where all is functional.

OS version: win 11
Python : 3.11 x64

@zak-45
Copy link
Author

zak-45 commented Sep 7, 2024

Have seen some breaking changes.
looks like this solve the problem :

    async def _handle_ok(self):
        await ui.context.client.connected()
        rows = await self.grid.get_selected_rows()
        # rows = await ui.run_javascript(f'getElement({self.grid.id}).gridOptions.api.getSelectedRows()')
        self.submit([r['path'] for r in rows])

need to put

         rows = await self.grid.get_selected_rows()

instead

        rows = await ui.run_javascript(f'getElement({self.grid.id}).gridOptions.api.getSelectedRows()')

@falkoschindler
Copy link
Contributor

Thanks for reporting this issue and providing a solution, @zak-45! I quickly fixed it in 4ffe19f.

@falkoschindler falkoschindler added the documentation Improvements or additions to documentation label Sep 8, 2024
@falkoschindler falkoschindler added this to the 2.2 milestone Sep 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

2 participants