Plots.jl plot window launched from a signal within Gtk.jl does not open—how to fix?

Hi, I’m new here (and to the Julia programming language in general), and hopefully this is the right category. Anyway, I’m attempting to make a GUI to facilitate some visualisation that I’m doing. What I want is to click a button in my Gtk GUI and have a separate visualisation window open. In the example I’m providing, the plotly backend does not work, but I have tested this example with other backends (such as pyplot, which I also use sometimes as each backend has its own strengths and weaknesses).

Just to make sure this isn’t an OS issue, I have tested this on both Linux and OS X and both of them have the same issue. I’m thinking this issue is caused because plot cannot be run in a thread.

Example:

using Gtk, Plots
plotly()

b = GtkButton("open plot")
signal_connect(b, "clicked") do w
  plot(1:5)
end

wi = GtkWindow(b, "Plots.jl failure demonstration")
showall(wi)

I’m thinking that I can use multiprocessing or a subprocess somehow to display my visualisations, but I find that solution to be quite a bit unwieldy and I’d like to avoid it if I can. Is there a better way to do what I want?

Also, I explicitly do not want to embed these graphs in Gtk for now, so that would not be a solution.

Well, I figured it out myself. You have to call gui() after you run plot. Not sure why that works, though.

1 Like