Created
May 8, 2019 17:23
-
-
Save lobingera/40851a7fbc35850c00a9319444ca4e27 to your computer and use it in GitHub Desktop.
gtk update example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Gtk | |
using Cairo | |
global drawInt = 0 | |
function draw_c(widget) | |
ctx = Gtk.getgc(widget) | |
global drawInt | |
drawInt += 1 | |
rectangle(ctx, 0, 0, 20.0*drawInt, 30.0*drawInt) | |
set_source_rgb(ctx, 1, 0, 0) | |
fill(ctx) | |
end | |
win = Gtk.Window("Gtk") |> (bx = Gtk.Box(:v)) | |
canvas = Gtk.Canvas(600, 450) | |
push!(bx, canvas) | |
bt = Gtk.Button("ok") | |
push!(bx, bt) | |
function on_button_clicked(w) | |
println("The button has been clicked and replot") | |
ctx = Gtk.getgc(canvas) | |
draw(canvas) | |
println(drawInt) | |
end | |
signal_connect(on_button_clicked, bt, "clicked") | |
canvas.draw = draw_c | |
Gtk.showall(win) | |
sleep(3) | |
println("$(drawInt)") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment