如何使用 Lua 和 IUP 显示进度条
我构建了一个长时间运行的脚本,其中添加了一个进度条,代码如下:
function StartProgressBar()
gaugeProgress = iup.gaugeProgress{}
gaugeProgress.show_text = "YES"
gaugeProgress.expand = "HORIZONTAL"
dlgProgress = iup.dialog{gaugeProgress; title = "Note Replacement in Progress"}
dlgProgress.size = "QUARTERxEIGHTH"
dlgProgress.menubox = "NO" -- Remove Windows close button and menu.
dlgProgress:showxy(iup.CENTER, iup.CENTER) -- Put up Progress Display
return dlgProgress
end
这是在循环之前调用的,进度条在循环期间更新(我没有调用 MainLoop)。在该过程结束时,我调用 dlgProgress.destroy 来清除它。
只要我不从进度条上获取焦点,它就可以正常工作,但是如果焦点丢失,程序就会崩溃,所以我确信我这样做的方式是错误的。谁能告诉我正确的方法。详细的google没有给我找到任何iup、lua进度条的例子。
先感谢您。
I have built a long running script to which I have added a progress bar with the following code:
function StartProgressBar()
gaugeProgress = iup.gaugeProgress{}
gaugeProgress.show_text = "YES"
gaugeProgress.expand = "HORIZONTAL"
dlgProgress = iup.dialog{gaugeProgress; title = "Note Replacement in Progress"}
dlgProgress.size = "QUARTERxEIGHTH"
dlgProgress.menubox = "NO" -- Remove Windows close button and menu.
dlgProgress:showxy(iup.CENTER, iup.CENTER) -- Put up Progress Display
return dlgProgress
end
This is called before the loop and the progress bar updated during the loop (I am not calling MainLoop). At the end of the process I call dlgProgress.destroy to clear it.
As long as I don't take focus from the progress bar it works fine, but if focus is lost the program crashes, so I am sure I am doing this the wrong way. Can any one tell me the correct way. A detailed google did not find me any examples for iup, lua progress bars.
Thank you in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是一个工作示例。
我在这里使用了 IUP 3.0 及其标准 Lua 绑定。仪表控件在 IUP 3.0 中被命名为
iup.progressbar
,在早期版本中被命名为iup.gauge
。在早期版本中,它也可能位于扩展控件库中。我已经在 Windows 上对此进行了测试。人们认为它在其他平台上也有类似的行为,但你的里程可能会有所不同。
Here is a working sample.
I've used IUP 3.0, and its standard Lua binding here. The gauge control is named
iup.progressbar
in IUP 3.0, and was namediup.gauge
in earlier versions. In earlier versions it may have been in the extended controls library as well.I've tested this on Windows. One assumes it has similar behavior on other platforms, but your mileage may vary.