原创 visualfc
在LUA中进行GUI程序设计,可以选择的GUI库一般有wxLua和IupLua。wxLua具备典型的面向对象风格,功能相对强大。而IUP的LUA绑定则非常简洁易用。本文主要介绍IupLua。
IUPLUA目前稳定版本为2.7.1,最新版本为3.0beta1。
IUP项目主页为:http://sourceforge.net/projects/iup
在IupLua程序设计中,主要使用表来设计应用程序界面,表的键值则为GUI部件的属性,通过回调函数完成窗口消息的获取。下面给出一个完整的例子。
1
require "iuplua"
2
3
text_location = iup.text{expand="HORIZONTAL", id="text_location"}
4
btn_browse = iup.button{title="Browse", rastersize="x22",id="btn_browse"}
5
dlg = iup.dialog
6
{
7
iup.vbox
8
{
9
iup.label{title="Location:"},
10
iup.hbox
11
{
12
text_location,
13
btn_browse
14
; margin="0x0"
15
},
16
iup.label{title="Text:"},
17
iup.multiline{expand="YES"},
18
}
19
;title="iuplua sample", size="200x100", margin="10x10"
20
}
21
22
function btn_browse:action()
23

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23