# Using Gtk can I make a dialog pop up where I enter some text?

**URL:** <https://discourse.julialang.org/t/using-gtk-can-i-make-a-dialog-pop-up-where-i-enter-some-text/48774>\
**Category:** New to Julia\
**Created:** [October 21, 2020, 7:52pm UTC](https://discourse.julialang.org/t/using-gtk-can-i-make-a-dialog-pop-up-where-i-enter-some-text/48774 "2020-10-21T19:52:46Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ahmed\_Salih](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ahmed_salih/32/206579_2.png) [@Ahmed\_Salih](https://discourse.julialang.org/u/Ahmed_Salih)\
**Post date:** [October 21, 2020, 7:52pm UTC](https://discourse.julialang.org/t/using-gtk-can-i-make-a-dialog-pop-up-where-i-enter-some-text/48774/1 "2020-10-21T19:52:46Z")

</div>

Hi!

Basically I want a small GUI to open up where it is just possible to write a line and then save that string. Is that possible?

This is how far I am right now:

```julia
## Make small interface
win = GtkWindow("Save File",300,50)

ent = GtkEntry()
set_gtk_property!(ent,:text,"Insert Filename")

push!(win,ent)
Gtk.showall(win)

str = get_gtk_property(ent,:text,String)

```

![image](https://global.discourse-cdn.com/julialang/original/3X/3/3/3307dfcae156b30838c5925d6f26731c01b25a78.png)

Now I would like it to register my input when I press “Enter”

EDIT2:

```julia
function get_filename_gui()
    win = GtkWindow("Save File",300,50)

    ent = GtkEntry()
    set_gtk_property!(ent,:text,"Insert Filename")

    push!(win,ent)
    Gtk.showall(win)

    str = ""
    if isinteractive()
        c = Condition()
        signal_connect(win, "key-press-event") do widget, event
            if event.keyval == 65293 #Enter
                str = get_gtk_property(ent,:text,String)
                notify(c)
            end
        end
        wait(c)
    end

    Gtk.destroy(win)

    return str
end

```

The code above does the trick, “using Gtk”

Kind regards

---

<div class="post-metadata">

**Author:** ![Iulian.Cioarca](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/iulian.cioarca/32/30166_2.png) [@Iulian.Cioarca](https://discourse.julialang.org/u/Iulian.Cioarca)\
**Post date:** [October 21, 2020, 8:14pm UTC](https://discourse.julialang.org/t/using-gtk-can-i-make-a-dialog-pop-up-where-i-enter-some-text/48774/2 "2020-10-21T20:14:17Z")

</div>

Have a look at GtkReactive:  
[https://juliagizmos.github.io/GtkReactive.jl/stable/reference.html#Input-widgets-1](https://juliagizmos.github.io/GtkReactive.jl/stable/reference.html#Input-widgets-1)

---

<div class="post-metadata">

**Author:** ![jonathanBieler](https://avatars.discourse-cdn.com/v4/letter/j/82dd89/32.png) [@jonathanBieler](https://discourse.julialang.org/u/jonathanBieler)\
**Post date:** [October 22, 2020, 7:31am UTC](https://discourse.julialang.org/t/using-gtk-can-i-make-a-dialog-pop-up-where-i-enter-some-text/48774/3 "2020-10-22T07:31:19Z")

</div>

There’s also an input\_dialog function in Gtk.jl that does pretty much that :

[https://github.com/JuliaGraphics/Gtk.jl/blob/17bfda1ea78a511cd39d58de56c09cadd93262fb/src/windows.jl#L96](https://github.com/JuliaGraphics/Gtk.jl/blob/17bfda1ea78a511cd39d58de56c09cadd93262fb/src/windows.jl#L96)

See also :

[https://juliagraphics.github.io/Gtk.jl/latest/manual/filedialogs/](https://juliagraphics.github.io/Gtk.jl/latest/manual/filedialogs/)

---

<div class="post-metadata">

**Author:** ![tobias.knopp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tobias.knopp/32/7551_2.png) [@tobias.knopp](https://discourse.julialang.org/u/tobias.knopp)\
**Post date:** [October 22, 2020, 7:41am UTC](https://discourse.julialang.org/t/using-gtk-can-i-make-a-dialog-pop-up-where-i-enter-some-text/48774/4 "2020-10-22T07:41:49Z")

</div>

I want to second what Jonathon suggested. I have not used `input_dialog` myself but I am using `info_dialog` and `ask_dialog` quite a bit, the later allows for getting true/false decisions. You can also design a custom dialog, as is basically shown in the implementation of the `input_dialog`. The important bit is that you are using `GtkMessageDialog` or `GtkDialog` as the the basis since this will give you the most important behaviors the you were missing in your first example.

---

<div class="post-metadata">

**Author:** ![Ahmed\_Salih](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ahmed_salih/32/206579_2.png) [@Ahmed\_Salih](https://discourse.julialang.org/u/Ahmed_Salih)\
**Post date:** [October 22, 2020, 8:30am UTC](https://discourse.julialang.org/t/using-gtk-can-i-make-a-dialog-pop-up-where-i-enter-some-text/48774/5 "2020-10-22T08:30:22Z")

</div>

Thanks @jonathanBieler and @tobias.knopp!

I will look into this when I need to do it more “correctly”. I am quite happy I atleast got it to work on my own, even if the code is not optimal.

Kind regards
