Computercraft thingies
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

guitest.lua 1023B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. os.loadAPI("/lib/program")
  2. os.loadAPI("/lib/graphics")
  3. local prog = program.Prog()
  4. local gui = graphics.Gui(prog)
  5. local root = graphics.FloatingLayout()
  6. gui.setRoot(root)
  7. local txtHelloWorld = graphics.TextView()
  8. .text("hello world")
  9. .left("center")
  10. .top("center")
  11. local txtCounter = graphics.TextView()
  12. .text("0")
  13. .right("center")
  14. .top("center + 1")
  15. local btn1 = graphics.Button()
  16. .text("Button!")
  17. .top(2)
  18. .left(2)
  19. .on("click", function()
  20. txtCounter.text(tonumber(txtCounter.text()) + 1)
  21. end)
  22. local btn2 = graphics.Button()
  23. .text("Button Two")
  24. .top(3)
  25. .left(2)
  26. .on("click", function()
  27. txtCounter.text(tonumber(txtCounter.text()) - 1)
  28. end)
  29. local input = graphics.TextInput()
  30. .bottom(1)
  31. .left("40% - 40$ + 1")
  32. .width("80% + 1")
  33. .text("Hey")
  34. local btnExit = graphics.Button()
  35. .text("X")
  36. .right(1)
  37. .on("click", function() gui.exit() end)
  38. root.addChild(txtHelloWorld)
  39. root.addChild(btn1)
  40. root.addChild(btn2)
  41. root.addChild(txtCounter)
  42. root.addChild(input)
  43. root.addChild(btnExit)
  44. prog.init()