simonkrauter/NiGui

Canvas doesn't load while on windows

0x4c756e61 opened this issue · 3 comments

I don't know why but when I compile my code on a linux machine, the canvas load correctly, but when I compile the same code on a windows machine and try to run it, the canvas doen't load! I tryed to use wine but same problem here.

Is it just me having this issue ?

Can you please provide an example program? Or did you try example_10_drawing.nim?

I base my code on the exemple 10

import nigui, nigui/msgbox, browsers
app.init()

var w = newWindow("Happy Birthday!!!!!")
w.width = 512.scaleToDpi
w.height = 550.scaleToDpi

w.iconPath = "logo.png"

let image = newImage()
image.loadFromFile("kdo.png")
var ctrl = newControl()
w.add(ctrl)
let label = "Click to open"
ctrl.onDraw = proc (event: DrawEvent) = 

    let c = event.control.canvas
    c.drawImage(image)
    c.textColor = rgb(255, 77, 255)
    c.fontSize = 30
    c.drawText(label, 128, 512)

ctrl.onMouseButtonDown = proc (event: MouseEvent) = 
    
    let res = w.msgBox("Is your brother there ?", "???????????", "YES", "NOPE!")
    if $res == "1":
       
        openDefaultBrowser("https://youtu.be/dQw4w9WgXcQ")
        app.quit()
            
    else:
        discard

w.show()
app.run()

EDIT: Traduced fr to en

@0x454d505459 The problem in your example is, that you don't set size for the control ctrl.

Add this code:

ctrl.widthMode = WidthMode_Fill
ctrl.heightMode = HeightMode_Fill