This program uses the Glade library to build a GUI from an XML file that has been created using glade-3. The "Start" button starts retrieving the URL; the response body is shown in the textarea upon completion.
The function to build the GUI is shown below. As you can see, it derives the name of the glade file from the name of the Lua file (including the path). Then, The Glade library is used to read and parse the XML file into an internal representation, from which the widget tree starting at "window1" is created.
require "gtk" require "gtk.glade" function build_gui() local fname, builder, rc, err, sw fname = arg or string.gsub(arg, "%.lua", ".ui") builder = gtk.builder_new() rc, err = builder:add_from_file(fname, nil) if rc == 0 then error(err.message) end builder:connect_signals_full(_G) -- statusbar statusbar = builder:get_object "statusbar1" statusbar_ctx = statusbar:get_context_id("progress") statusbar:push(statusbar_ctx, "idle") -- result display sw = builder:get_object "scrolledwindow1" view = output:create() sw:add(view) view:show() end