My beginner journey with Julia Lang - Inventing simple Fahrenheit Celsius converter

My beginner journey with Julia Lang - Inventing simple Fahrenheit Celsius converter

fahrenheit celsius converter running

using Pkg
Pkg.add("Gtk4")

using Gtk4
win0 = GtkWindow("Zavri Ma...")
win = GtkWindow("Celsius/Fahrenheit converter")
vbox = GtkBox(:v)
hbox = GtkBox(:h)
vbox1=GtkBox(:v,3)
vbox2=GtkBox(:v,3)
label1=GtkLabel("Stupňov Celzia: \n\n")
Gtk4.justify(label1,Gtk4.Justification_RIGHT)
entry1 = GtkEntry()
push!(vbox1,label1)
push!(vbox2,entry1)
label2=GtkLabel("Stupňov Fahrenheita: ")
Gtk4.justify(label1,Gtk4.Justification_RIGHT)
entry2 = GtkEntry()
push!(vbox1,label2)
push!(vbox2,entry2)
push!(hbox, vbox1)
push!(hbox, vbox2)
push!(vbox,hbox)
ok = GtkButton("Prepočítaj")
push!(vbox, ok)
push!(win, vbox)
id = signal_connect(ok, "clicked") do widget
    try
        numc = parse(Float64, entry1.text)
        println("OK: Zadané číslo je Celzia = $(numc)")
        println("Prepočítavam!")
        entry2.text=numc * 9/5 + 32
    catch e
        println("⚠️ Chyba: Zadaj platné číslo Celzia! $(entry1.text)")
        try
            numf = parse(Float64, entry2.text)
            println("OK: Zadané číslo je Fahrenheit = $(numf)")
            println("Prepočítavam!")
            entry1.text = (numf-32) * 5/9
        catch e
            println("⚠️ Chyba: Zadaj platné číslo Fahrenheit! $(entry2.text)")
        end
    end

end
if !isinteractive()
    c = Condition()
    signal_connect(win0, :close_request) do widget
        notify(c)
    end
    @async Gtk4.GLib.glib_main()
    wait(c)
end


Author: AarNoma

The first Slovak cyborg 1 system

Comments “My beginner journey with Julia Lang - Inventing simple Fahrenheit Celsius converter”