123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- os.loadAPI("/lib/program")
- os.loadAPI("/lib/graphics")
-
- local prog = program.Prog()
- local gui = graphics.Gui(prog)
-
- local root = graphics.FloatingLayout()
- gui.setRoot(root)
-
- local txtHelloWorld = graphics.TextView()
- .text("hello world")
- .left("center")
- .top("center")
-
- local txtCounter = graphics.TextView()
- .text("0")
- .right("center")
- .top("center + 1")
-
- local btn1 = graphics.Button()
- .text("Button!")
- .top(2)
- .left(2)
- .on("click", function()
- txtCounter.text(tonumber(txtCounter.text()) + 1)
- end)
-
- local btn2 = graphics.Button()
- .text("Button Two")
- .top(3)
- .left(2)
- .on("click", function()
- txtCounter.text(tonumber(txtCounter.text()) - 1)
- end)
-
- local input = graphics.TextInput()
- .bottom(1)
- .left("40% - 40$ + 1")
- .width("80% + 1")
- .text("Hey")
-
- local btnExit = graphics.Button()
- .text("X")
- .right(1)
- .on("click", function() gui.exit() end)
-
- root.addChild(txtHelloWorld)
- root.addChild(btn1)
- root.addChild(btn2)
- root.addChild(txtCounter)
- root.addChild(input)
- root.addChild(btnExit)
-
- prog.init()
|