You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to build a GTK application in glade, I know it's possible to push!(widget, container) and can access object made in Glade with dict-like accessors i.e.,
But once I'm here, how can I use GtkObservables.jl to link a Plots.jl (or any other backend) plot to a GtkCanvas or similar widget, and insert it into my GUI? I'm starting with something simple here:
using Gtk, Plots, GtkObservables
gladefile =GtkBuilder(filename=joinpath(@__DIR__, "testfile.glade"))
win = gladefile["main_window"]
button1 = gladefile["button1"]
plot_frame = gladefile["plot_frame"]
canv =GtkCanvas()
showall(win)
functionbutton_clicked_callback(widget)
println(get_gtk_property(widget, :name, String), " was clicked!")
h = Gtk.height(plot_frame)
w = Gtk.width(plot_frame)
x =randn(1000)
y =randn(1000)
# myplot = scatter(x, y)# push!(plot_frame, myplot) # unsafe_convert doesn't know how to deal with thisendsignal_connect(button_clicked_callback, button1, "clicked")
The text was updated successfully, but these errors were encountered:
What I ended up doing was to generate the plot normally, save it, and then reload and copy the image into the Canvas. I needed it saved anyway, but if you don't, maybe this isn't the right path. But I was also having trouble with the rendering.
using ImageCore, ImageIO
imgcanvas = canvas(UserUnit, 500, 500)
selectedimg = Observable{Union{Nothing, Matrix{RGB{N0f8}}}}(nothing)
function draw_canvas(c, img)
img !== nothing || return
copy!(c, img)
end
draw(draw_canvas, imgcanvas, selectedimg)
From what I was looking at for more direct rendering, you might need to try GR directly instead of using Plots, and you'll need to set some environment variables for GR to render correctly. Though there also may be some cross-platform issues with that right now.
Originally I was hesitant to do this based on speed requirements, but I bit the bulled and actually found that Plots.jl is surprisingly fast in creating saved images, but when your plots reach 10000+ data points (at least using scatter) things start to slow down a tad. I'm sure there's a workaround/set of trick to optimize for this, but for now this is a viable solution. Thanks!
I'm trying to build a GTK application in glade, I know it's possible to
push!(widget, container)
and can access object made in Glade with dict-like accessors i.e.,But once I'm here, how can I use GtkObservables.jl to link a Plots.jl (or any other backend) plot to a GtkCanvas or similar widget, and insert it into my GUI? I'm starting with something simple here:
The text was updated successfully, but these errors were encountered: