如何在 Perl Tk 中显示来自外部命令的文本?
我必须在 Tk GUI 中显示一些打印语句(在运行 Perl 脚本时得到)。我尝试用图文并茂的方式展示一个例子,例如:
Initializing the parser ...
Running the parser ...
Enabling the codec ...
Connected to the socket ...
Sending ipv4 traffic into the code ...
事情是这样的。我不知道该怎么做。
I have to display some print statements (which I get while running a Perl script) in the Tk GUI. I tried to show an example in pictorial format, for example:
Initializing the parser ...
Running the parser ...
Enabling the codec ...
Connected to the socket ...
Sending ipv4 traffic into the code ...
It goes on like this. I don't know how to do it.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以通过
Tk::ExecuteCommand
一般来说,您需要执行某种 IPC 来运行批处理并更新 Tk GUI。因为IO句柄可以在Tk中创建事件。
Tk::ExecuteCommand
隐藏了复杂性IPC。否则,您可以设计自己的IPC方案。大概(粗略地说)管道、分叉和设置管道事件作为 IO 事件,创建只读日志的关键命令是:
You could run your perl script through
Tk::ExecuteCommand
In general, you need to do some sort of IPC to run a batch and update a Tk GUI. Because IO handles can create events in Tk.
Tk::ExecuteCommand
kind of hides the complexity of the IPC.Otherwise, you can design the IPC scheme of your own. Probably (roughly put) pipe, fork, and setup pipe events as a IO event, and the crucial commands to make a read-only log are: