File: dialog.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 (23 lines) | stat: -rwxr-xr-x 579 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
#! /usr/bin/env lua
-- Show a dialog

require "gtk"

dialog = gtk.dialog_new_with_buttons ("Message", nil,
	gtk.DIALOG_DESTROY_WITH_PARENT,
	gtk.STOCK_OK, gtk.RESPONSE_ACCEPT,
	gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
	nil)
entry = gtk.entry_new()
entry:set_alignment(0.9)

--  Add the label, and show everything we've added to the dialog.
dialog.vbox:add(entry)
dialog:set_default_response(gtk.RESPONSE_ACCEPT)
dialog:show_all()

-- Run the dialog, print the response.
rc = dialog:run()
print(rc, rc == gtk.RESPONSE_ACCEPT:tonumber() and entry:get_text() or "")
dialog:destroy()