I'm trying to build a GUI app with LuaRT able to run an external Python script redirecting stdout to a widget. It seems working but I can not yet manage GUI events while the script is running.
What am I missing?
See the following example:
ui = require 'ui'
local sysutils = require 'sysutils'
win = ui.Window('Py Demo', 'dialog', 400, 400)
run_button = ui.Button(win, 'Run', 10, 10)
other_button = ui.Button(win, 'Other', 100, 10)
out_text = ui.Edit(win, '', 10, 40, 400-20, 300)
out_text.font = 'Consolas'
local p
function run_button:onClick()
p = sysutils.Process('python demo1.py', false, true)
out_text.text = ''
p:spawn()
function p:onRedirect(data) out_text:append(tostring(data)) end
end
function other_button:onClick() --> not executed until the process is terminated
print('OTHER CLICKED')
end
win:show()
ui.run(win):wait()