Skip to content

Commit

Permalink
nice message
Browse files Browse the repository at this point in the history
  • Loading branch information
ufechner7 committed Mar 28, 2024
1 parent daad721 commit 60bd044
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions mwes/mwe_03.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,32 @@ using Gtk4, Printf

struct Stats
energy::Float64
max_force::Float64
min_height::Float64
end

stats=Stats(333)
stats=Stats(333, 3900, 25)

function show_stats(stats::Stats)
win = GtkWindow("My First Gtk4.jl Program", 400, 200)
win = GtkWindow("Statistics", 400, 200)
css = """
button {
font-size: 3.0em;
label {
font-size: 2.0em;
}
"""
cssProvider = GtkCssProvider(css)
push!(Gtk4.display(win), cssProvider)

hbox = GtkBox(:h) # :h makes a horizontal layout, :v a vertical layout
push!(win, hbox)
vbox = GtkBox(:v, homogeneous=true)

label = GtkButton(" Power:")
value = GtkButton(" 22.4")
push!(hbox, label)
push!(hbox, value)
hbox.spacing = 10
hbox.homogeneous = true
hbox = GtkBox(:h, homogeneous=true) # :h makes a horizontal layout, :v a vertical layout
label = GtkLabel("Power:"); val = GtkLabel(@sprintf("%5.0f Wh", stats.energy))
push!(hbox, label, val)

push!(vbox, hbox)
push!(win, vbox)
show(win)
nothing
end


0 comments on commit 60bd044

Please sign in to comment.