On Wed, 18 Apr 2007 22:50:14 +0000, Glen wrote: Ok, obviously, my post didn't come out the way I wanted it to. In the first example from my text file below, the dictionary pairs, constructed from sorted tuples were in straight columns. When I write them to my QTextEdit, however, the columns are no longer straight. Some of the padding inserted by my call to rightJustified() are not equal to the actual size of the text, so some rows are longer than others in the text browser. I know I've encountered this before, perhaps with Java, but I can't remember the solution. How do I get the formatting of my output to the gui to reflect the output I would get to a file using the builtin write() function? Any help is appreciated. Sorry about the confusion.
Thanks, G > Hello again, I don't blame anyone for not answering my last post, since > I obviously hadn't spent much time researching, but I've come a little > ways and have another question. > > How can I better format text output to a QTextEdit object? I'm > inserting 5 columns into each row. When I write the info to a file, it > looks like the following: > > 42: 115 26: 114 35: 112 19: 108 16: 107 45: 107 40: > 106 5: 105 41: 104 2: 103 > 9: 102 48: 102 15: 101 22: 101 27: 101 > 39: 101 43: 101 10: 100 6: 99 34: 99 32: 98 49: > 98 20: 97 30: 97 8: 96 17: 96 38: 96 12: 95 > 14: 95 37: 95 > 4: 94 13: 94 44: 94 36: 93 3: 92 > 24: 92 28: 92 31: 91 29: 89 7: 88 > 1: 87 18: 85 46: 85 33: 84 11: 83 > 23: 83 47: 82 25: 80 21: 79 50: 56 52: 39 51: > 38 53: 36 54: 25 55: 18 > > When I write the contents of the file to my TextEdit object it comes out > uneven, something like this: > 42: 115 26: 114 35: 112 19: 108 16: 107 45: 107 40: 106 > 5: 105 41: 104 2: 103 9: 102 48: 102 15: 101 22: 101 27: > 101 39: 101 43: 101 10: 100 6: 99 34: 99 32: 98 49: 98 > 20: 97 30: 97 8: 96 17: 96 38: 96 12: 95 14: 95 > 37: 95 4: 94 13: 94 44: 94 36: 93 3: 92 24: 92 28: > 92 31: 91 29: 89 7: 88 > 1: 87 18: 85 46: 85 33: 84 11: 83 > 23: 83 47: 82 25: 80 21: 79 50: 56 52: 39 51: 38 > 53: 36 54: 25 55: 18 > > What seems to be happening is that the font that pyqt is using is not > fixed width, so I did this: > qTxtFormat = QTextCharFormat() > qTxtFormat.setFontFixedPitch(True) > ui.textEdit.setCurrentCharFormat(qTxtFormat) > > Also, I tried using the pyqt formatting such as the following: > > qStr = QtCore.QString( QtCore.QString( str(tL2[i][0]) > ).rightJustified(2) + ':' + QtCore.QString( str(tL2[i][1]) > ).rightJustified(4) ) > This still gives me uneven columns. > > Any suggestions? > > Thanks, > > Glen -- http://mail.python.org/mailman/listinfo/python-list