Skip to content

LuaAndC/luawt

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

luawt

Build Status Coverage Status License gitter

Lua bindings for Wt.

Install

Install Wt >= 3.3.0 and luarocks.

Clone the repo and do $ luarocks make

or

$ luarocks install luawt

Check

$ busted

How to use

A Web application in luawt is just a Lua program.

-- This code is executed in constructor of new application.
-- It setups widgets of a start page shown to a user.
local code = [[
    -- app is an instance of WApplication
    -- env is an instance of WEnvironment
    local app, env = ...

    -- To create new widgets, we need luawt module.
    local luawt = require 'luawt'

    -- Create widgets.
    local textarea = luawt.WTextArea(app:root())
    local button = luawt.WPushButton(app:root())
    button:setText("Click me")

    -- Setup signal handler: uppercase text in the textarea.
    button:clicked():connect(function()
        textarea:setText(textarea:text():upper())
    end)
]]

local luawt = require 'luawt'

-- Start WServer with the code above.
local server = luawt.WServer({
    code = code,
    ip = '127.0.0.1',
    port = 8080,
})
server:start()
server:waitForShutdown()

See the list of Wt classes bound to luawt.

See examples:

How to bind new class

  • new .cpp file
  • globals.hpp
  • init.cpp (note that base must be before child)
  • rockspec

There is the tool automate bindings which is used to generate most of the code. To generate code compatible with wide range of Wt versions, the tool has an option to provide a blacklist of classes and methods to omit. It has also an option to generate such a blacklist.

The tool gen docs is used to generate reference.