jerous86 / nimqt

Qt bindings for nim
GNU General Public License v2.0
93 stars 6 forks source link

layout grid problem? #16

Closed Martinix75 closed 1 year ago

Martinix75 commented 1 year ago

Good morning, I'm sorry to always disturb for various problems, if you can sorry. But I found another problem very similar to that of the other time. This time it concerns "Newgridlayout" (always in the hypothesis that I don't do mistakes !!). If I fill in the following test program everything is fine and the compilation is successful:

import os
import nimqt
import nimqt/qdialog
import nimqt/[qpushbutton, qlabel, qboxlayout, qgridlayout] 

nimqt.init
let app1 = newQApplication(commandLineParams())

let finestra: ptr QDialog = newQDialog() #finestra = qDialog
finestra.makelayout:
  - newQWidget():
    - newQGridLayout():
      - newQLabel(Q"ciao") as ff at (0, 0) # <-- work! :)
      - newQPushButton(Q"ppp") as p at (0,1) # <-- work! :)

finestra.show()
discard app1.exec() 

But if I change and do:

import os
import nimqt
import nimqt/qdialog
import nimqt/[qpushbutton, qlabel, qboxlayout, qgridlayout] 

nimqt.init
let app1 = newQApplication(commandLineParams())

let bottone_1 = newQPushButton(Q"Si")
let bottone_2 = newQPushButton(Q"No")
let bottone_3 = newQPushButton(Q"Forse")

let label_1 = newQlabel(Q"Label 1")
let label_2 = newQlabel(Q"Label 2")
let label_3 = newQlabel(Q"Label 3")

let finestra: ptr QDialog = newQDialog() #finestra = qDialog
finestra.makelayout:
  - newQWidget():
    - newQGridLayout():

      - use_object label_1  at (0, 0) # <-- not Work :(
      - use_object bottone_1  at (0, 1) #<-- not work :(

finestra.show()
discard app1.exec() 

It gives me the error: ......................................................................................................................................................................................................... stack trace: (most recent call last) /home/andrea/.nimble/pkgs/nimqt-0.1/nimqt.nim(634, 9) makeLayout2 /home/andrea/.nimble/pkgs/nimqt-0.1/nimqt.nim(606, 25) helper /home/andrea/.nimble/pkgs/nimqt-0.1/nimqt.nim(606, 25) helper /home/andrea/.nimble/pkgs/nimqt-0.1/nimqt.nim(582, 27) helper /home/andrea/bin/nim/lib/core/macros.nim(640, 24) expectKind /home/andrea/ownCloud/In_Sviluppo/NimQt/gui2_2_c.nim(18, 9) template/generic instantiation of makeLayout from here /home/andrea/ownCloud/In_Sviluppo/NimQt/gui2_2_c.nim(22, 29) Error: Expected a node of kind nnkIdent, got nnkCommand

As usual maybe I am wrong something? Or do you have any problems? Thanks for your patience. bye by Martin A.

p.s. This time I used '' but I don't see the formatted code !! :((

jerous86 commented 1 year ago

You have to use three backticks, instead of one for pieces of code (I modified your post). No worries about disturbing me, I'm glad you find the library useful and are testing it :)

I made a new commit that fixes your issue (I hope). You will need an additional package. You can install it by doing nimble install astpatternmatching

Martinix75 commented 1 year ago

Gui_2_2_d_semiespansa Gui2_2_d_Nonespansa Gui2_2_d_expansa

did some tests and it seems that it works perfectly! Also the installation of the "ASTPATERMATCHING" package. I would say to close the post (if in the future I observe other problems in this regard I will make a new one).