wx.OutputStream¶
wx.OutputStream is an abstract base class which may not be used directly.
It is the base class of all streams which provide a Write
function, i.e. which can be used to output data (e.g. to a file, to a socket, etc).
If you want to create your own output stream, you’ll need to derive from this class and implement the protected OnSysWrite
function only.
Class Hierarchy¶
Known Subclasses¶
CountingOutputStream , FFileOutputStream , FileOutputStream , FilterOutputStream , MemoryOutputStream , SocketOutputStream , StringOutputStream , TempFFileOutputStream , TempFileOutputStream
Methods Summary¶
Creates a dummy wx.OutputStream object. |
|
Closes the stream, returning |
|
Returns the number of bytes written during the last |
|
Puts the specified character in the output queue and increments the stream position. |
|
Changes the stream current position. |
|
Returns the current stream position. |
|
Writes up to the specified amount of bytes using the data of buffer. |
|
Writes exactly the specified number of bytes from the buffer. |
|
Class API¶
- class wx.OutputStream(StreamBase)¶
Possible constructors:
OutputStream() -> None
OutputStream is an abstract base class which may not be used directly.
Methods¶
- __init__(self)¶
Creates a dummy wx.OutputStream object.
- Return type:
None
- Close(self)¶
Closes the stream, returning
False
if an error occurs.The stream is closed implicitly in the destructor if
Close
is not called explicitly.If this stream wraps another stream or some other resource such as a file, then the underlying resource is closed too if it is owned by this stream, or left open otherwise.
- Return type:
bool
- LastWrite(self)¶
Returns the number of bytes written during the last
Write
.It may return 0 even if there is no error on the stream if it is only temporarily impossible to write to it.
- Return type:
int
- PutC(self, c)¶
Puts the specified character in the output queue and increments the stream position.
- Parameters:
c (int)
- Return type:
None
- SeekO(self, pos, mode=FromStart)¶
Changes the stream current position.
- Parameters:
pos (wx.FileOffset) – Offset to seek to.
mode (SeekMode) – One of FromStart, FromEnd, FromCurrent.
- Return type:
wx.FileOffset
- Returns:
The new stream position or
InvalidOffset
on error.
- TellO(self)¶
Returns the current stream position.
- Return type:
wx.FileOffset
- Write(self, *args, **kw)¶
-
Write (self, buffer, size)
Writes up to the specified amount of bytes using the data of buffer.
Note that not all data can always be written so you must check the number of bytes really written to the stream using
LastWrite
when this function returns.In some cases (for example a write end of a pipe which is currently full) it is even possible that there is no errors and zero bytes have been written. This function returns a reference on the current object, so the user can test any states of the stream right away.
- Parameters:
buffer
size (int)
- Return type:
Write (self, stream_in)
Reads data from the specified input stream and stores them in the current stream.
The data is read until an error is raised by one of the two streams.
- Parameters:
stream_in (wx.InputStream)
- Return type:
- WriteAll(self, buffer, size)¶
Writes exactly the specified number of bytes from the buffer.
Returns
True
if exactly size bytes were written. Otherwise, returnsFalse
andLastWrite
should be used to retrieve the exact amount of the data written if necessary.This method uses repeated calls to
Write
(which may return writing only part of the data) if necessary.- Parameters:
buffer
size (int)
- Return type:
bool
Added in version 2.9.5.
- close(self)¶
- Return type:
None
- eof(self)¶
- Return type:
bool
- flush(self)¶
- Return type:
None
- seek(self, offset, whence=0)¶
- Return type:
None
- tell(self)¶
- Return type:
wx.FileOffset
- write(self, data)¶
- Return type:
Any