Replies: 3 comments 7 replies
-
Opening a dialog never blocks. Just like showing a window won't. This is not related to goroutines, the behaviour is the same from any code execution. |
Beta Was this translation helpful? Give feedback.
-
To add to the response from @andydotxyz, you can make a dialog block (sometimes useful in goroutines) by using either a channel or a |
Beta Was this translation helpful? Give feedback.
-
Is there some example code for this? I am running into the same problem. I want an error dialog to block until the button is clicked. The best I've been able to achieve using the above example is that the dialog gets displayed, but then the blocking channel prevents the dismiss button from being clicked. Using
|
Beta Was this translation helpful? Give feedback.
-
I am writing a fyne-app which does some work in the background using goroutines. Now I've tried to report errors within the background tasks to the user using dialog.ShowError. At a first view it seems to work, but it caused some strange behavior. Later I've found out that dialogShowError does not block if called from within a goroutine.
Let's look a some samples:
The "Test Error" message appears and after clicking on the OK-button the log message "After ShowError" is printed.
Now the goroutine case:
In this case it logs the "After ShowError" message after 2 secs without waiting to the click on the OK-button.
So it looks like dialogs are only usable from within the main thread.
I am familiar with Qt where I would use Timer-Events for such cases. I haven't found something similar in fyne. How do I start actions in the main thread after the mainloop is running? What patterns do you usually use to handle the above case (reporting results from background tasks to the ui)?
Mathias
Beta Was this translation helpful? Give feedback.
All reactions