Select blog: [MaemoPPL] [maddraves] [Jaffa] [jcml] [MTblog] [Piega`] [keesj] [ab] [luogni] [disq] [htpeople] [jlbrd] [mmeta] [fanoush] [lardman] [ueblis] [lwr]
Select skin: [basic] [custom] [natural_pink] [nifty_corners] [originalb2] [skinners_guide] [wpc_default] [work] [Ality] [andreas01] [basin] [bluesky] [city_in_evo] [Classic] [crystalglass] [Guadeloupe] [Helsinki] [kubrick2evo] [l33t_gray] [Melbourne] [nautica05-2col] [nautica2l] [Nescafe] [niftyblue] [niftygreen] [niftypurple] [Orange] [plain] [Platinum] [reflection] [SmoothCurrency] [Stockholm] [StockholmRemix] [TicTac] [tm-dark] [uneven] [testatom]

keesj



Lua people in a maemo world.

02/07/07

10:42:00 am Permalink Lua people in a maemo world.   English (US)

Categories: Maemo, 504 words

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!

5 feedbacks PermalinkPermalink

Pingbacks:

No Pingbacks for this post yet...


:: Archives

[Login...] [Register...]


Powered by b2evolution