luaengineapp/scripts/luaenginert.lea
2019-10-20 17:08:56 +02:00

60 lines
2.2 KiB
Text
Executable file

#!/usr/bin/env luaengine
--[[
******************************************************************************
* luaengine LuaEngine Runtime
* Copyright (C) 2019 Syping
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
******************************************************************************
--]]
local mainWindow
local scriptLineEdit
function main()
mainWindow = createMainWindow("LuaEngine Runtime")
local mainLayout = createLayout(VerticalLayout, mainWindow)
createLabel("<strong>LuaEngine Runtime</strong>", mainLayout)
local scriptLayout = createLayout(HorizontalLayout, mainLayout)
createLabel("Script:", scriptLayout)
scriptLineEdit = createLineEdit("", scriptLayout)
setWidgetReadOnly(scriptLineEdit)
local scriptToolButton = createToolButton("...", scriptLayout)
connect(scriptToolButton, "clicked()", "scriptButtonPressed")
createSpacerItem(SizePolicyMinimum, SizePolicyExpanding, mainLayout)
local buttonLayout = createLayout(HorizontalLayout, mainLayout)
createSpacerItem(SizePolicyExpanding, SizePolicyMinimum, buttonLayout)
local runButton = createPushButton("&Run", buttonLayout)
connect(runButton, "clicked()", "runScript")
setWidgetSize(mainWindow, 300, 0)
setWidgetFixed(mainWindow, true)
showWidget(mainWindow, ShowDefault)
return GuiExecuted
end
function scriptButtonPressed()
local filePath = showFileDialog(OpenFileDialog, "Select LuaEngine script...", "LuaEngine scripts (*.lua *.lea)", mainWindow)
if (filePath ~= nil) then
setWidgetText(scriptLineEdit, filePath)
end
end
function runScript()
executeProcess(_LuaEngineRT, getWidgetText(scriptLineEdit), true)
end