File: notebook.lua

package info (click to toggle)
lua-gtk 0.9%2B20100528-2
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 2,176 kB
  • ctags: 1,934
  • sloc: ansic: 9,571; sh: 373; makefile: 241
file content (30 lines) | stat: -rwxr-xr-x 643 bytes parent folder | download
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
#! /usr/bin/env lua

-- demonstrate a Notebook with two pages.

require "gtk"

function build_ui()
	local win = gtk.window_new(gtk.WINDOW_TOPLEVEL)
	win:connect('delete-event', gtk.main_quit)
	win:set_title "Notebook test"
	win:set_default_size(450, 400)

	local note = gtk.notebook_new()
	note:connect('switch-page', on_switch_page)
	win:add(note)

	note:append_page(gtk.label_new"Page 1", gtk.label_new"Page 1")
	note:append_page(gtk.label_new"Page 2", gtk.label_new"Page 2")

	win:show_all()
	return win
end

function on_switch_page(note, page, page_nr)
	print("on_switch_page", note, page, page_nr)
end

local win = build_ui()
gtk.main()