1
votes

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:

  • If I enter the statements sequentially in the REPL
  • If I write the code in a file (say file.jl) and issue 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?

1

1 Answers

1
votes

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)