Reputation: 41
I searched around for this problem, and found the same question two times but for other versions of Julia. And the solutions didn't work for me. I'm using a Xubuntu 18.04 system.
I wrote this code with the documentation of Gtk.jl:
using Pkg
Pkg.add( "Gtk" )
using Gtk
win = GtkWindow( "Tuto GTK", 400, 200)
b = GtkButton( "Click me!" )
push!( win, b )
showall(win)
A simple example.
It works in REPL:
include( "file.jl" )
But it doesn't work with the command: julia file.jl
I think there may be some initialization code missing, but the julia executable doesn't seem to have a verbose option.
Can someone help,please?
Upvotes: 1
Views: 352
Reputation: 6086
Your program is exiting and closing the window before you see the Gtk window. In the REPL, the window is part of the REPL program and does not exit.
You need a wait loop. So, replace
showall(win)
with either
showall(win)
while(true) sleep(0.1) end
or, more smoothly,
c = Condition()
endit(w) = notify(c)
signal_connect(endit, win, :destroy)
showall(win)
wait(c)
Upvotes: 2