-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfujisaki.cl
46 lines (39 loc) · 1.47 KB
/
fujisaki.cl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
;; Fujisaki is a small declarative (PyQt5 based) UI toolkit
(import sys)
(import PyQt5.QtGui)
(import PyQt5.QtCore)
(import PyQt5.QtWidgets)
(def Qt QtCore/Qt)
(defn vbox ()
(let (qt-app (QtWidgets/QApplication sys/argv)
window (QtWidgets/QWidget))
{:window window
:qt-app qt-app :layout (QtWidgets/QVBoxLayout window)}))
(defn label (layout text & props)
(let (qt-layout (:layout layout)
alignment (:alignment props :center)
qt-label-instance (QtWidgets/QLabel))
(.setText qt-label-instance text)
(when (= alignment :center)
(.setAlignment qt-label-instance Qt/AlignCenter))
(.addWidget qt-layout qt-label-instance)
layout))
(defn image (layout image-path & props)
(let (qt-layout (:layout layout)
alignment (:alignment props :center)
qt-label-instance (QtWidgets/QLabel))
(.setPixmap qt-label-instance (QtGui/QPixmap image-path))
(when (= alignment :center)
(.setAlignment qt-label-instance Qt/AlignCenter))
(.addWidget qt-layout qt-label-instance)
layout))
(defn window (layout config & props)
(let (width (:width config 350)
height (:height config 150)
title (:title config "FujisakiUI App Window")
window (:window layout)
application (:qt-app layout))
(.resize window width height)
(.setWindowTitle window title)
(.show window)
(.exec application)))