File: goocanvas.lua

package info (click to toggle)
lua-lgi 0.9.2-7
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,388 kB
  • sloc: ansic: 5,082; makefile: 169; sh: 31
file content (49 lines) | stat: -rw-r--r-- 954 bytes parent folder | download | duplicates (4)
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
47
48
49
local lgi = require 'lgi'
local Gtk = lgi.Gtk
local Goo = lgi.GooCanvas

local window = Gtk.Window {
   on_delete_event = Gtk.main_quit,
   Gtk.ScrolledWindow {
      shadow_type = 'IN',
      Goo.Canvas {
	 id = 'canvas',
	 width = 600, height = 450,
      }
   },
}

window:set_default_size(640, 600)
window:show_all()

window.child.canvas:set_bounds(0, 0, 1000, 1000)
local root = window.child.canvas.root_item

local rect_item = Goo.CanvasRect {
    parent = root,
    x = 100, y = 100,
    width = 400, height = 400,

    line_width = 10,
    stroke_color = 'yellow',
    fill_color = 'red',
    radius_x = 20,
    radius_y = 10,

    on_button_press_event = function ()
       print("rect item received button press event")
    end    
}

local text_item = Goo.CanvasText {
    parent = root,
    x = 300, y = 300,
    width = -1,

    text = "Hello World",
    anchor = 'CENTER',
    font = 'Sans 24',
}
text_item:rotate(45, 300, 300)

Gtk.main()