How can I make an GUI Application in Lua
Asked Answered
D

8

19

First I'll show you an example of what I am talking about: GUI Example

I've been studying Lua for around a week now, and I'm really curious of how I would do this. Basically (for now, and learning purposes), I just want to make a GUI with 2 buttons, 1 to start the specified (.exe), and one to exit the GUI.

Is this possible? How would I go about doing this? Any information would be great!

Distraint answered 5/8, 2013 at 11:2 Comment(1)
Any feedback about all the answers you got would be reasonable. If any of these have helped you, you should at least accept it. This is what keeps SO quality high.Declivity
B
13

I believe you may want to take a look: http://lua-users.org/wiki/GraphicalUserInterfaceToolkits

If you want something well know and tested I would go to Qt, if something light: FLTK.

Burchett answered 5/8, 2013 at 12:1 Comment(2)
Qt is really comprehensive GUI tool in my opinion.Wares
But web technologies like HTML/CSS/JS are the way to go for UI development. This tool to launch web UI looks promising: sciter.com the source code is here: gitlab.com/sciter-engine/sciter-js-sdkWares
D
6

If you are an absolute beginner, i.e. you don't have any programming experience in other programming languages, I advice you to learn Lua very well without trying to mess with GUI programming, which is inherently much harder. When you will have a good understanding of Lua, then go for a GUI toolkit for Lua. I use wxLua so I can only give you some hints on that.

Since it is not a "native" Lua toolkit, but it is a "binding" to a well-known cross-platform GUI library (wxWidgets) you must study both the wxLua documentation and wxWidgets manual (at least to some degree).

wxLua binary distribution comes with everything needed to use it (you don't even need a separate Lua interpreter, it has its own) and contains a good number of example applications.

The following script is a trivial approximation of what you want to do, but (I repeat myself) you should really learn the basics of Lua before attempting GUI programming.

local wx = require 'wx'

local PATH_TO_APPLICATION = [[notepad.exe]]     -- Windows assumed for sake of exemplification

local ans = wx.wxMessageBox( "Should the application be started?", "Hi there!",
    wx.wxOK + wx.wxCANCEL + wx.wxICON_QUESTION )
if ans == wx.wxOK then
    wx.wxExecute( PATH_TO_APPLICATION )
end

To run the previous script you must be sure that wxLua is installed correctly in your interpreter search path. Otherwise you must use the wxlua.exe interpreter that comes with the distribution.

Note also that wxLua interpreter (latest wxLua stable release) runs with a version of Lua 5.1, so try not to use features of Lua 5.2 in your scripts. Basic Lua syntax and semantics is almost the same, but there are some slight differences and Lua 5.2 has a couple of added features. So be careful with your learning path.

Declivity answered 19/8, 2013 at 1:25 Comment(0)
L
4

IUP should be the easiest way to create a GUI with Lua. However you will meet a brick wall if you try to install IUP on Linux. You have to hope someone has pre-installed it or someone has pre-written an install package for your version of Linux. If you want other people to be able to run your code later it will be virtually impossible to set things up in reasonable way. That is really an error by the Lua/Iup team because I have no trouble in using Iup from the C programming language and it seems to be widely compatible with many versions of Linux. It is the opposite of the usual situation where it is very easy to set up a scripting language and difficult to set up a low level language like C.

Longfaced answered 11/5, 2014 at 23:51 Comment(0)
B
3

Have you checked wxLua ? This is the only desktop gui framework I am aware of for Lua.

Brave answered 5/8, 2013 at 11:4 Comment(0)
L
3

Another example is IUP: http://www.tecgraf.puc-rio.br/iup/

It is supported for Microsoft Windows and Unix

Lasting answered 6/8, 2013 at 6:37 Comment(0)
W
0

Web technologies

In my opinion, the web technologies like HTML/CSS/JS are the way to go for UI development.

Launch web UI on a desktop

Minimal size of deployment

There is a lightweight and capable tool with just around 8 MB in size to launch web UI on a desktop. You can download the scapp.exe executable from here: https://gitlab.com/sciter-engine/sciter-js-sdk/-/tree/main/bin/windows/x64?ref_type=heads

How to run

You can place the scapp.exe next to your HTML/CSS/JS code:

Executable next to HTML/CSS/JS code

Then just run on the command line:

scapp.exe index.html

I used this sample app: https://gitlab.com/sciter-engine/sciter-js-sdk/-/tree/main/samples/calc

The app runs just fine:

App runs fine

Wares answered 9/9, 2023 at 8:58 Comment(0)
S
0

I know it's been years. But try out Limekit, it offers a simplified Qt API, has material UI, dark snd light themes

https://limekit.readthedocs.io/en/latest/

Slosberg answered 14/1, 2024 at 17:47 Comment(0)
S
0

you may take a look at LuaRT. LuaRT is a Windows programming framework for Lua. Did not test myself, but a brief look into the documentation should tell you If you can get your app up and running.

Sepal answered 21/6, 2024 at 18:53 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.