# Gtk example help

**URL:** https://discourse.julialang.org/t/gtk-example-help/92655
**Category:** New to Julia
**Tags:** question
**Created:** [January 8, 2023, 1:29am UTC](https://discourse.julialang.org/t/gtk-example-help/92655 "2023-01-08T01:29:33Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![rbme](https://avatars.discourse-cdn.com/v4/letter/r/ecb155/32.png) [@rbme](https://discourse.julialang.org/u/rbme)
#### Post date: [January 8, 2023, 1:29am UTC](https://discourse.julialang.org/t/gtk-example-help/92655/1 "2023-01-08T01:29:33Z")

</div>

New to programming and Julia. Trying out an example with the GTk package. It runs OK calling the .jl file under the julia REPL. include(“gtktest.jl”). Window comes up and when I press the button i get the "button was pressed " response. When I try to run the script under the windows command prompt c:\ julia gtktest.jl nothing happens. The path is good . it’s not a “path” issue. I placed the file in the same directory as the julia.exe executable.  
using Gtk

win = GtkWindow(“My First Gtk.jl Program”, 400, 200)

b = GtkButton(“Click Me”)  
push!(win,b)

function on\_button\_clicked(w)  
println(“The button has been clicked”)  
end  
signal\_connect(on\_button\_clicked, b, “clicked”)

showall(win)

---

<div class="post-metadata">

### Author: ![dylanxyz](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dylanxyz/32/36646_2.png) [@dylanxyz](https://discourse.julialang.org/u/dylanxyz)
#### Post date: [January 8, 2023, 6:45am UTC](https://discourse.julialang.org/t/gtk-example-help/92655/2 "2023-01-08T06:45:56Z")

</div>

From the [Non REPL Usage · Gtk.jl](https://juliagraphics.github.io/Gtk.jl/latest/manual/nonreplusage/#Non-REPL-Usage-1) documentation, your program should wait for the window to be closed if you wish to run the program outside of the Julia REPL, using this piece of code:

```julia
if !isinteractive()
    c = Condition()
    signal_connect(win, :destroy) do widget
        notify(c)
    end
    @async Gtk.gtk_main()
    wait(c)
end

```

Essentially, this will create a `Condition` object that the program will “wait” until it is notified when the window is closed. This will keep the program running instead of immediately closing.

---

<div class="post-metadata">

### Author: ![rbme](https://avatars.discourse-cdn.com/v4/letter/r/ecb155/32.png) [@rbme](https://discourse.julialang.org/u/rbme)
#### Post date: [January 9, 2023, 12:57am UTC](https://discourse.julialang.org/t/gtk-example-help/92655/3 "2023-01-09T00:57:38Z")

</div>

Thanks
