Mark Summerfield-4 wrote:
> 
> [snip]
> 
> Actually I meant:
> 
>     file = QFile(self.filename)
>     if file.open(QIODevice::ReadOnly):
>       ba = file.readAll() # ba is a QByteArray filled with raw bytes
>       hexbytes = []
>       for i in range(ba.count()):
>           if QChar(" ") < QChar(ba[i]) < QChar(128):
>               hexbytes.append(ba[i].toAscii())
>           else:
>               hexbytes.append(ba[i].toHex()) 
>               # the above might need to be:
>               # hexbytes.append(QByteArray(ba[i]).toHex())
>               # or even:
>               # hexbytes.append(str(QByteArray(ba[i]).toHex()))
>       self.ui.textEditAscii1.setPlainText("".join(hexbytes))
> 
> 
> Still untested though!
> 
> -- 
> Mark Summerfield, Qtrac Ltd, www.qtrac.eu
>     C++, Python, Qt, PyQt - training and consultancy
>         "Rapid GUI Programming with Python and Qt" - ISBN 0132354187
>             http://www.qtrac.eu/pyqtbook.html
> _______________________________________________
> PyQt mailing list    [email protected]
> http://www.riverbankcomputing.com/mailman/listinfo/pyqt
> 
> 

Hmm, this appending approach is very slow again :( Moreover, I need to be
able to print out also non-printable ASCII characters (0-32) and not to show
them as hex.
However thank you for you comments, I will try to think about different
solution...if you have any other idea then please let me know

T.
-- 
View this message in context: 
http://old.nabble.com/Re%3A-binary-file-viewer-with-textEdit-%28PyQt%29--correction--tp28981896p28983455.html
Sent from the PyQt mailing list archive at Nabble.com.

_______________________________________________
PyQt mailing list    [email protected]
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

Reply via email to