Open varchasgopalaswamy opened 1 year ago
The posted code is working for me. Maybe its an operating system issue? I'm on Mac OS with Chrome.
Interesting. I'm on RHEL 9 and using GTK for Webview. I found QT did not work (I was getting a white blank screen). I am able to launch the file browser using Webview, e.g.
import webview
def open_file_dialog(window):
file_types = ('Image Files (*.bmp;*.jpg;*.gif)', 'All files (*.*)')
result = window.create_file_dialog(webview.OPEN_DIALOG, allow_multiple=True, file_types=file_types)
print(result)
if __name__ == '__main__':
window = webview.create_window('Open file dialog example', 'https://pywebview.flowrl.com/hello')
webview.start(open_file_dialog, window)
so I guess it's not an issue with Webview?
I turned on uvicorn_debug and got
DEBUG: < TEXT '42["event",{"id":12,"listener_id":"a96b632f-5e0...3cfa3ff0eb","args":[]}]' [84 bytes]
when I clicked on the "open file" dialog. I guess it's not able to get a connection to something since there's no reply?
It may be some code is blocking the main thread. Can anyone on Linux with GTK confirm this issue?
@NiklasNeugebauer, @JensOgorek, I already tried to reproduce this issue with @denniswittich, but we couldn't get GTK running. Could one of you, please, try to run the code from the original post and see if the file dialog works? Thanks!
I can confirm the error. Tried the code above, clicked on "Choose File" and connection is lost.
to add some info, for me it works fine if I am in debug mode (pytorch) but i get the same issue when i am in run mode.
I just reproduced the issue on an Ubuntu machine, but I have no clue why the dialog doesn't open.
I thought it might have to do with the button click, but this minimal pywebview example works perfectly fine:
import webview
class Api:
def open_file_dialog(self):
print(window.create_file_dialog(webview.OPEN_DIALOG, allow_multiple=True, file_types=()))
api = Api()
window = webview.create_window('Test', html='<button onclick="pywebview.api.open_file_dialog()">open dialog</button>', js_api=api)
webview.start()
Are we doing something wrong when sending the request to the other process? https://github.com/zauberzeug/nicegui/blob/460dbc1f1549bfc35cace6cdb76d7402762ae9a8/nicegui/native/native.py#L114-L123
Should we set block
or timeout
differently when calling get()
? I don't have my dev environment on this Linux machine, so it's a bit cumbersome to play around with the source code. Can anyone step in?
@falkoschindler I changed the code of native.py, but it seems it already get stuck at method_queue.put((name, args, kwargs))
for me.
I am trying nicegui and native=True, but things are not working for me.
If I try the code at the top from the OP:
from nicegui import app, ui
async def choose_file():
files = await app.native.main_window.create_file_dialog(allow_multiple=True)
for file in files:
ui.notify(file)
ui.button('choose file', on_click=choose_file)
ui.run(native=True)
The final error message is as follows:
File "/home/gsal/.conda/envs/py311nice/lib/python3.11/multiprocessing/synchronize.py", line 107, in __getstate__
raise RuntimeError('A SemLock created in a fork context is being '
RuntimeError: A SemLock created in a fork context is being shared with a process in a spawn context. This is not supported. Please use the same context to create multiprocessing objects and Process.
I am in Rocky9 and using a conda environment that I created (in the last 48 hours) with the latest nicegui
Description
I'm trying to use the example case provided in https://github.com/zauberzeug/nicegui/discussions/283
but when I try to run this, I get a message "Connection lost", and the file browser doesn't show up.