(self, handler)
Attach a write handler.

        The interface is exactly as io.write(). The handler is given a
        bytes-like object to write, and should return the number of bytes
        written.
Attach a write handler.
Attach a write handler .
def on_write(self, handler):
        """Attach a write handler.

        The interface is exactly as io.write(). The handler is given a
        bytes-like object to write, and should return the number of bytes
        written.

        """

        def interface_handler(buf):
            bytes_written = handler(buf)
            # py2 will often return None for bytes_written ... replace with
            # the length of the string
            if bytes_written is None:
                bytes_written = len(buf)

            return bytes_written

        self.signal_connect("write", interface_handler)
def on_write ( self , handler ) : def interface_handler ( buf ) : bytes_written = handler ( buf ) # py2 will often return None for bytes_written ... replace with # the length of the string if bytes_written is None : bytes_written = len ( buf ) return bytes_written self . signal_connect ( "write" , interface_handler )