原创 visualfc
在LUA中进行GUI程序设计,可以选择的GUI库一般有wxLua和IupLua。wxLua具备典型的面向对象风格,功能相对强大。而IUP的LUA绑定则非常简洁易用。本文主要介绍IupLua。
IUPLUA目前稳定版本为2.7.1,最新版本为3.0beta1。
IUP项目主页为:http://sourceforge.net/projects/iup
在IupLua程序设计中,主要使用表来设计应用程序界面,表的键值则为GUI部件的属性,通过回调函数完成窗口消息的获取。下面给出一个完整的例子。
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.dialog6
{
7
iup.vbox8
{
9
iup.label{title="Location:"},10
iup.hbox11
{
12
text_location,13
btn_browse14
; 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
local dlg = iup.filedlg{dialogtype="DIR"}24
dlg:popup()25
if dlg.status == "0" then26
text_location.value = dlg.value27
end28
end29

30
dlg:show()31

32
iup.MainLoop()33

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容,请联系我们,一经查实,本站将立刻删除。
如需转载请保留出处:https://51itzy.com/kjqy/93954.html