Lua people in a maemo world.

02/07/07

Permalink 10:42:00 am, by keesj, 504 words, 3924 views   English (US)
Categories: Maemo

Lua people in a maemo world.

Support for the Lua programming language was added to the mud svn.
“Lua is a powerful light-weight programming language designed for extending applications. Lua is also frequently used as a general-purpose, stand-alone language. Lua is free software.”

Together with this I added wxWidgets and the wxLua bindings to the mud svn. Why? I think many command line tools lack a simple gui interface to make them usable on the tablet. wxWidgets is a cross platform gui framework that is mostly ported to hildon (keyboard input works). Lua is simple and can be integrated with c code.

[More:]

I have used http://wxglade.sourceforge.net/ to create a simple gui and stored it in an xrc file. The xrc contains and xml definition of the the widget hierarchy. This Together with a little lua code created a “finished” gui in very little time and on a normal compter.

A little more work should go into combining a cosy-bookmarks kind of application with a lua
scripted launcher. The c based application should download and run lua scripts to help in launching applications. Settings should be stored in gconf. A simple launcher for ssh would already be great .
The launcher would help with some ssh parameters (like port forwarding) and would give the user
a list of previously used hosts. The same launcher should be used for daemon kind like programs and would manly be handy to stop the launched application.

Just to give you a feeling here are a few sample lines of the xml , the lua and the "finised" gui

<?xml version="1.0" encoding="UTF-8"?>
<!-- generated by wxGlade 0.4 on Wed Feb  7 10:12:00 2007 -->

<resource version="2.3.0.1">
    <object class="wxDialog" name="dialog_1">
        <style>wxDEFAULT_DIALOG_STYLE</style>
        <bg>#ffffff</bg>
        <title>dialog_1</title>
        <object class="wxGridSizer">
            <object class="spacer">
                <size>20, 20</size>
                <flag>wxADJUST_MINSIZE</flag>
            </object>
            <!-- more xml code here
            ...
            ...
            -->
            <object class="spacer">
                <size>20, 20</size>
                <flag>wxADJUST_MINSIZE</flag>
            </object>
        </object>
    </object>
</resource>

The lua code is just very cute

#!/usr/bin/lua
package.cpath = ";;/usr/lib/lua/5.1/?.so"
require("wx")

-- Global variables
dialog        = nil -- the wxDialog main toplevel window
xmlResource   = nil -- the XML resource handle

-- ---------------------------------------------------------------------------
-- Handle the quit button event
function OnQuit(event)
    event:Skip()
    dialog:Show(false)
    dialog:Destroy()
end

-- ---------------------------------------------------------------------------
-- The main program as a function (makes it easy to exit on error)
function main()
    -- xml style resources (if present)
    xmlResource = wx.wxXmlResourceGetDefault()
    xmlResource:InitAllHandlers()
    local xrcFilename = GetExePath().."/runner.xrc"

    xmlResource:Load(xrcFilename)
    dialog = wx.wxEmptyDialog()
    xmlResource:LoadDialogCreate(dialog, wx.wxNull, "dialog_1")
    bestSize = dialog:GetBestSize()

    dialog:Connect(wx.wxEVT_CLOSE_WINDOW, OnQuit)

    dialog:Centre()
    dialog:Show(true)

end

main()
wx.wxGetApp():MainLoop()

The result

Don't let python bite you use lua!

Pingbacks:

No Pingbacks for this post yet...

keesj

May 2012
Sun Mon Tue Wed Thu Fri Sat
 << <   > >>
    1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31    

Search

Categories

Misc

XML Feeds

What is RSS?

Who's Online?

  • Guest Users: 8

powered by
b2evolution