Skip to content

osch/lua-lwtk

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
February 23, 2020 21:25
February 5, 2020 10:51
February 5, 2020 10:51

lwtk - Lua Widget Toolkit

Licence build status Install

This toolkit provides a foundation for building cross platform GUI widgets in pure Lua on top of LPugl or within the LÖVE 2D game engine. For LPugl only the cairo drawing backend is supported. Further Backend abstraction and support for other backends could be possible in the future.

This project is work in progress. First aim is to provide a basic infrastructure for creating and customizing widgets. Second aim is to implement a reasonable set of standard widgets. So far only very simple standard widgets are provided, e.g. lwtk.TextInput and lwtk.PushButton.

Supported platforms:

  • Linux (X11)
  • Windows
  • Mac OS X
  • LÖVE 2D game engine

Further reading:

First Example

  • The first example demonstrates a simple dialog using the lwtk.TextInput widget. The appearance of the widgets is configured in lwtk.DefaultStyle. The key bindings are configured in lwtk.DefaultKeyBinding.

    Screenshot example01

    local lwtk = require("lwtk")
    
    local Application    = lwtk.Application
    local Column         = lwtk.Column
    local Row            = lwtk.Row
    local PushButton     = lwtk.PushButton
    local TextInput      = lwtk.TextInput
    local TitleText      = lwtk.TitleText
    local Space          = lwtk.Space
    
    local app = Application("example01.lua")
    
    local function quit()
        app:close()
    end
    
    local win = app:newWindow {
        title = "example01",
        Column {
            id = "c1",
            TitleText { text = "What's your name?" },
            TextInput { id = "i1", focus = true, style = { Columns = 40 } },
            Row {
                Space {},
                PushButton { id = "b1", text = "&OK",   disabled = true, 
                                                        default  = true },
    
                PushButton { id = "b2", text = "&Quit", onClicked = quit },
                Space {}
            }
        },
        Column {
            id = "c2",
            visible = false,
            Space {},
            TitleText { id = "t2", style = { TextAlign = "center" } },
            Space {},
            Row {
                Space {},
                PushButton { id = "b3", text = "&Again" },
    
                PushButton { id = "b4", text = "&Quit", default = true,
                                                        onClicked = quit },
                Space {}
            }
        }
    }
    
    win:childById("c1"):setOnInputChanged(function(widget, input)
        widget:childById("b1"):setDisabled(input.text == "")
    end)
    
    win:childById("b1"):setOnClicked(function(widget)
        win:childById("t2"):setText("Hello "..win:childById("i1").text.."!") 
        win:childById("c1"):setVisible(false)
        win:childById("c2"):setVisible(true)
    end)
    
    win:childById("b3"):setOnClicked(function(widget)
        win:childById("i1"):setText("")
        win:childById("i1"):setFocus()
        win:childById("c1"):setVisible(true)
        win:childById("c2"):setVisible(false)
    end)
    
    win:show()
    
    app:runEventLoop()

About

Lua Widget Toolkit: implement cross platform GUI widgets in pure Lua on top of LPugl or LÖVE 2D game engine

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published