How to get to debugMsg to prompt them in Tkinker window
WojciechowskiMarek opened this issue · comments
Good morning.
I'm working with Your delicious library pyprofibus.
I trying to make Tkiner window, by now I've made start and stop transmision from Tkinker.
Next step I would like to provide all prints from classies not to console but to Tkinker window.
I have problem with for example:
def sendData(self, telegramData, srd):
if self.__discardTimeout is not None:
return
try:
if self.debug:
self._debugMsg("TX %s" % bytesToHex(telegramData))
self.__serial.write(telegramData)
except serial.SerialException as e:
raise PhyError("PHY-serial: Failed to transmit "
"telegram:\n" + str(e))
TX message is returned in console.
self._debugMsg("TX %s" % bytesToHex(telegramData))
How can I get get to this _debugMsg to forward it to tkinker window ?
My code here: https://github.com/WojciechowskiMarek/pyprofibus2
Your sincerely
Marek Wojciechowski
Hi,
thanks for your question.
There's no direct support in pyprofibus for redirecting these messages.
But I guess you could monkey-patch the sys.stdout and sys.stderr objects that are used for printing to the console.