# Anyone used PackageCompiler to build a distributable app with an Interact/Blink GUI?

**URL:** <https://discourse.julialang.org/t/anyone-used-packagecompiler-to-build-a-distributable-app-with-an-interact-blink-gui/39761>\
**Category:** Offtopic\
**Tags:** guis, package-compiler\
**Created:** [May 19, 2020, 3:42pm UTC](https://discourse.julialang.org/t/anyone-used-packagecompiler-to-build-a-distributable-app-with-an-interact-blink-gui/39761 "2020-05-19T15:42:30Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![mthelm85](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mthelm85/32/224164_2.png) [@mthelm85](https://discourse.julialang.org/u/mthelm85)\
**Post date:** [May 19, 2020, 3:42pm UTC](https://discourse.julialang.org/t/anyone-used-packagecompiler-to-build-a-distributable-app-with-an-interact-blink-gui/39761/1 "2020-05-19T15:42:30Z")

</div>

I have some code that I run a couple of times per month and I’d like to be able to build a GUI for it, compile it as an app, and then distribute the .exe to others in my organization (non-programmers) so that they can make use of it. Normally, I would write an API for this, get that running on a server, and then build a web-based front end that calls the API. In this case, however, I’m not going to be able to do that and it will have to be something that a user can run on their desktop.

I’m wondering if anyone has built anything with Interact/Blink and successfully compiled it with PackageCompiler.jl for Windows 10? If so, is there a git repo you could share?

My needs are actually very simple, I just need a simple GUI that allows users to pick two different files from their desktop, a button that will execute the code, and maybe a space for the user to enter in the directory where they would like the output file to be saved.

---

<div class="post-metadata">

**Author:** ![fbanning](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fbanning/32/14972_2.png) [@fbanning](https://discourse.julialang.org/u/fbanning)\
**Post date:** [May 20, 2020, 10:06am UTC](https://discourse.julialang.org/t/anyone-used-packagecompiler-to-build-a-distributable-app-with-an-interact-blink-gui/39761/2 "2020-05-20T10:06:30Z")

</div>

I just had a look at the Blink.jl docs and for what you are planning to do, it does seem like a rather straightforward solution (especially given your prior knowledge in web dev). However, I couldn’t find any mention of behaviour with PackageCompiler.jl but why not just test it with a quick example app yourself (e.g. a button that runs a julia calc in the background and updates the html accordingly to its output)?

Edit: You could also use QML.jl or Gtk.jl if you want to build a native app instead of an electron app.

---

<div class="post-metadata">

**Author:** ![ffevotte](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ffevotte/32/6587_2.png) [@ffevotte](https://discourse.julialang.org/u/ffevotte)\
**Post date:** [May 20, 2020, 2:56pm UTC](https://discourse.julialang.org/t/anyone-used-packagecompiler-to-build-a-distributable-app-with-an-interact-blink-gui/39761/3 "2020-05-20T14:56:36Z")

</div>

I did this once in order to get convinced that writing such GUIs was indeed possible. This was my first and only time using Blink and Interact, and I did not really use this UI for anything useful. But here is the code in case it would be helpful for you to get started with this framework:

```julia
using Interact
using Blink
using CSSUtil
using WebIO

# Not sure how to display plain text messages without defining such custom widgets...
htmldiv(name, observable) = Widget{name}(OrderedDict(),
                                         output=map(val->dom"div"(string(val)), observable))
htmlspan(name, observable) = Widget{name}(OrderedDict(),
                                          output=map(val->dom"span"(string(val)), observable))

# Two parameters, linked to slider widgets
x = slider(1:10, label = "x", value = 1)
y = slider(1:10, label = "y", value = 1)

# A third parameter, computed by combination of the other two
param = Observable(0)

function update_xy(_=nothing)
    param[] = x[] + y[]
end
on(update_xy, x)
on(update_xy, y)
update_xy() # First manual update to display a consistent state on UI startup

# A widget allowing to choose a file path
f = filepicker(label="Choose a file..."; multiple=false, accept="*")

# A button to run the computation
b = button("Go")

# A message displayed at the bottom
message = Observable("")

# This condition will be used to notify the main task when the computation is done
done = Condition()

# Mock-up computation happening on button click
on(b) do _
    for i in 5:-1:1
        message[] = string("Performing long computation involving parameter $(param[]) ",
                            "and file $(f[]): $i")
        sleep(1)
    end
    message[] = "Computation complete!"

    # Notify the main task
    notify(done)
end

# Create the window and layout the widgets in it
w = Window()
ui = pad(1em,
         vbox(pad(1em,
                  vbox(x, y,
                       hbox(node(:span, "param : x + y = "), htmlspan(:param, param)))),
              pad(1em, f),
              pad(1em, b),
              pad(1em, htmldiv(:message, message))))
body!(w, ui)

# Wait until the computation is finished
wait(done)
sleep(1)

```

  

**Screenshot:**

 ![screenshot](https://global.discourse-cdn.com/julialang/original/3X/5/2/52ce0635b28b0b7e080c2975db349338628566f7.png)

At the time when I made this experiment, I tested this on Linux and generated a system image for it. AFAIR I did not have any problem with PackageCompiler. I’m not sure whether I actually tested this on Windows.

Again, this might very well be un-idiomatic, and I’ll probably not be able to answer any follow-up question you might have. But hopefully someone more knowledgeable will chime in and we’ll both learn something!

---

<div class="post-metadata">

**Author:** ![mthelm85](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mthelm85/32/224164_2.png) [@mthelm85](https://discourse.julialang.org/u/mthelm85)\
**Post date:** [June 20, 2020, 1:37pm UTC](https://discourse.julialang.org/t/anyone-used-packagecompiler-to-build-a-distributable-app-with-an-interact-blink-gui/39761/4 "2020-06-20T13:37:04Z")

</div>

So I finally got around to testing this out and it’s not working for me. When I launch the executable it starts to load the electron window but then aborts before loading any of the widgets (buttons, file pickers, etc.). Because what I need is so simple, I think I’m going to try to re-do this as a command line utility rather than having a GUI. I’m hoping that will be easier…
