demo-buttonboxes.lua 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. return function(parent, dir)
  2. local lgi = require 'lgi'
  3. local Gtk = lgi.Gtk
  4. local function create_bbox(orientation, title, spacing, layout)
  5. return Gtk.Frame {
  6. label = title,
  7. Gtk.ButtonBox {
  8. orientation = orientation,
  9. border_width = 5,
  10. layout_style = layout,
  11. spacing = spacing,
  12. Gtk.Button { use_stock = true, label = Gtk.STOCK_OK },
  13. Gtk.Button { use_stock = true, label = Gtk.STOCK_CANCEL },
  14. Gtk.Button { use_stock = true, label = Gtk.STOCK_HELP }
  15. },
  16. }
  17. end
  18. local window = Gtk.Window {
  19. title = "Button Boxes",
  20. border_width = 10,
  21. Gtk.Box {
  22. orientation = 'VERTICAL',
  23. Gtk.Frame {
  24. label = "Horizontal Button Boxes",
  25. Gtk.Box {
  26. orientation = 'VERTICAL',
  27. border_width = 10,
  28. create_bbox('HORIZONTAL', "Spread", 40, 'SPREAD'),
  29. create_bbox('HORIZONTAL', "Edge", 40, 'EDGE'),
  30. create_bbox('HORIZONTAL', "Start", 40, 'START'),
  31. create_bbox('HORIZONTAL', "End", 40, 'END')
  32. },
  33. },
  34. Gtk.Frame {
  35. label = "Vertical Button Boxes",
  36. Gtk.Box {
  37. orientation = 'HORIZONTAL',
  38. border_width = 10,
  39. create_bbox('VERTICAL', "Spread", 30, 'SPREAD'),
  40. create_bbox('VERTICAL', "Edge", 30, 'EDGE'),
  41. create_bbox('VERTICAL', "Start", 30, 'START'),
  42. create_bbox('VERTICAL', "End", 30, 'END')
  43. },
  44. },
  45. }
  46. }
  47. window:show_all()
  48. return window
  49. end,
  50. "Button Boxes",
  51. "The Button Box widgets are used to arrange buttons with padding."