0

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

ivan_pozdeev
  • 33,874
  • 19
  • 107
  • 152

1 Answers1

1

If you want to redirect everything sent to stdout (emitted by print statements, for example) to your text control, then you can just replace sys.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.

fviktor
  • 2,861
  • 20
  • 24
  • Thankyou for the hasty reply, i've failed in my attempt to use this however it did provide useful. Many thanks – Micheal Apr 14 '11 at 00:10