412 def setData(self, dataOrDevice): |
412 def setData(self, dataOrDevice): |
413 """ |
413 """ |
414 Public method to set the data to show. |
414 Public method to set the data to show. |
415 |
415 |
416 @param dataOrDevice byte array or device containing the data |
416 @param dataOrDevice byte array or device containing the data |
417 @type bytearray, QByteArray or QIODevice |
417 @type bytes, bytearray, QByteArray or QIODevice |
418 @return flag indicating success |
418 @return flag indicating success |
419 @rtype bool |
419 @rtype bool |
420 @exception TypeError raised to indicate a wrong parameter type |
420 @exception TypeError raised to indicate a wrong parameter type |
421 """ |
421 """ |
422 if not isinstance(dataOrDevice, (bytearray, QByteArray, QIODevice)): |
422 if not isinstance(dataOrDevice, (bytes, bytearray, QByteArray, |
|
423 QIODevice)): |
423 raise TypeError( |
424 raise TypeError( |
424 "setData: parameter must be bytearray, " |
425 "setData: parameter must be bytes, bytearray, " |
425 "QByteArray or QIODevice") |
426 "QByteArray or QIODevice") |
426 |
427 |
427 if isinstance(dataOrDevice, (bytearray, QByteArray)): |
428 if isinstance(dataOrDevice, (bytes, bytearray, QByteArray)): |
428 self.__data = bytearray(dataOrDevice) |
429 self.__data = bytearray(dataOrDevice) |
429 self.__bData.setData(self.__data) |
430 self.__bData.setData(self.__data) |
430 return self.__setData(self.__bData) |
431 return self.__setData(self.__bData) |
431 else: |
432 else: |
432 return self.__setData(dataOrDevice) |
433 return self.__setData(dataOrDevice) |