Open MillironX opened 3 years ago
Possibly similar issue: ask_dialog
, when run in a script, doesn't close when a dialog choice is selected and thus never returns.
From: https://discourse.julialang.org/t/problem-with-gui-ask-dialog/73224/9
using Gtk
state = ask_dialog("Find Steady-state solution and start rom steady-state?", "No", "Yes")
println("never reached")
if !isinteractive()
@async Gtk.gtk_main()
end
Sticking a println
between dlg =
and run(dlg)
seems to cause the bug for ask_dialog
to disappear.
This works
using Gtk
win = GtkWindow("gtkwait")
if !isinteractive()
@async Gtk.gtk_main()
end
@async begin
state = ask_dialog("Find Steady-state solution and start rom steady-state?", "No", "Yes")
println("never reached")
end
if !isinteractive()
Gtk.waitforsignal(win,:destroy)
end
So the event loop needs to be started first. Then the ask_dialog needs to be in an async block since otherwise the Gtk.gtk_main()
will not run because of a missing yield
. An finally I need a window to stop the app from closing. This could of course also be done differently.
Ah good. Then we'll need the documentation to be adjusted. Currently it says to put all GUI code in front of Gtk.gtk_main()
.
https://juliagraphics.github.io/Gtk.jl/latest/manual/nonreplusage/#
Yes. But my example is not yet nice for consumption within the docu. I think we need to distinguish two cases.
The one where you have a window and no interactive code like above, i.e. GUI code
in that context really means building the GUI and no callbacks/drawing involved.
The second use case is that with interactions going on. Then you need the extra task.
Here is a better version of use case 2:
using Gtk
if !isinteractive()
@async Gtk.gtk_main()
end
t = @async begin
state = ask_dialog("Find Steady-state solution and start rom steady-state?", "No", "Yes")
println("never reached")
end
if !isinteractive()
wait(t)
end
When calling
open_dialog()
oropen_dialog_native()
from a script file, the value is never returned and the process hangs at the line whereopen_dialog()
is called.Steps to reproduce
Create a file with the following:
gtktest.jl
Run using
Select a file and double-click it or click "open"
Expected results
The path of the file you selected should be printed. E.g.
Actual results
The dialog goes away, but the nothing is printed to the terminal, and the prompt doesn't return (the process hangs)
Running interactively
This problem does not occur if running in the REPL, although Gtk still complains
What I've tried
sudo dnf reinstall gdk-pixbuf2 shared-mime-info -y
rm -rf ~/.julia
] add GTK3_jll
brew install adwaita-icon-theme
locate libcolorreload-gtk-module.so
(output:/usr/lib64/gtk-3.0/modules/libcolorreload-gtk-module.so
, so no action taken)open_dialog()/open_dialog_native()
from https://juliagraphics.github.io/Gtk.jl/latest/manual/filedialogs/My system info
] add Gtk