显示实时输出到 wx.TextCtrl
我目前正在 Ubuntu 中使用 wxPython、Pcapy 和 impacket 模块构建一个 wi-fi 数据包捕获实用程序。我已经在 wxPython 中创建了 GUI 并引用了其他模块的捕获代码,但是事实证明将两者结合起来很困难。尽管这听起来很愚蠢,但我发现很难让 wx.txtctrl 在 GUI 上显示捕获的数据包,而是继续使用命令行。
是否有全局定义 textctrl 或允许显示其上的代码的函数?
如果有人能阐明这个问题,我们将不胜感激,
非常感谢
I'm currently in the process of building a wi-fi packet capture utility in Ubuntu using the modules wxPython, Pcapy and impacket. I have created the GUI in wxPython and the capture code referencing the other modules, however combining the two is proving difficult. As idiotic as this sounds, i'm finding it difficult to get the wx.txtctrl to display the captured packets on the GUI, they keep going to the command line instead.
Is there anyway of either globally defining the textctrl or a function that allows the code on it to be displayed?
If someone could shed any light on the problem it would be much appreciated
Many thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您想将发送到 stdout 的所有内容(例如,由 print 语句发出)重定向到文本控件,那么您可以将 sys.stdout 替换为您自己的模拟对象一个文件对象。
您可以只使用 StringIO 类,然后发送其累积值定期(使用计时器)到您的文本控件。您还可以子类 StringIO,覆盖其 write 方法并发送收到每个文本片段后立即将新内容添加到文本控件。
这不是一个很好的解决方案,但是感觉就像猴子修补一样。
If you want to redirect everything sent to
stdout
(emitted by print statements, for example) to your text control, then you can just replacesys.stdout
with your own object simulating a file object.You can just use the StringIO class, then send its accumulated value to your text control periodically (using a timer). You can also subclass StringIO, override its write method and send the new contents to the text control immediately after every single text fragment received.
It is not a nice solution, feels like monkey patching, however.