Re: Beginner: Formatting text output (PyQt4) Solved
Glen wrote: > Sorry I've been away a while, figuring stuff out. It absolutely wasn't a > monospaced font that I was using. I'm still getting used to Qt Designer > and didn't see the expandable item under 'font' where I could easily > select another font. I felt pretty stupid when I saw it. My program > output the contents of my data file perfectly once I selected a fixed > pitch font. > > Thanks a lot for the replies. I didn't know how long to wait, since I'm > new around here, and I kind of gave up. I got some good info from you > guys anyway. Thanks. You'll probably be hearing from me pretty > regularly, since I'm in the process of learning Python and PyQt > simultaneously. > Welcome to c.l.py! regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC/Ltd http://www.holdenweb.com Skype: holdenweb http://del.icio.us/steve.holden Recent Ramblings http://holdenweb.blogspot.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Beginner: Formatting text output (PyQt4) Solved
Sorry I've been away a while, figuring stuff out. It absolutely wasn't a monospaced font that I was using. I'm still getting used to Qt Designer and didn't see the expandable item under 'font' where I could easily select another font. I felt pretty stupid when I saw it. My program output the contents of my data file perfectly once I selected a fixed pitch font. Thanks a lot for the replies. I didn't know how long to wait, since I'm new around here, and I kind of gave up. I got some good info from you guys anyway. Thanks. You'll probably be hearing from me pretty regularly, since I'm in the process of learning Python and PyQt simultaneously. Glen -- http://mail.python.org/mailman/listinfo/python-list
Re: Beginner: Formatting text output (PyQt4)
On Thursday 19 April 2007 00:50, Glen wrote: > 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) It may be that the font you're using isn't actually a monospaced font. The result of this is that the font used to display the text won't be a fixed pitch font. To test this, try specifying a known monospaced font and see if you get the output you expect. David -- http://mail.python.org/mailman/listinfo/python-list
Re: Beginner: Formatting text output (PyQt4)
Glen wrote: > 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) Does something like ui.textEdit.setCurrentFont(QFont('fixed')) work? It seems to work for me if you use plain text. Tabs or html/rich text formatting should be a better way to get the layout (or just use a table). Jeremy -- Jeremy Sanders http://www.jeremysanders.net/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Beginner: Formatting text output (PyQt4)
Glen wrote: >> 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: 11526: 11435: 11219: 10816: 107 45: 10740: 106 >> 5: 10541: 104 2: 103 9: 10248: 10215: 10122: 101 27: >> 101 39: 10143: 10110: 1006: 9934: 99 32: 9849: 98 >>20: 9730: 978: 96 17: 9638: 9612: 9514: 95 >> 37: 95 4: 9413: 9444: 9436: 933: 92 24: 92 28: >> 9231: 9129: 897: 88 >> 1: 8718: 8546: 8533: 8411: 83 >> 23: 8347: 8225: 8021: 7950: 56 52: 3951: 38 >> 53: 3654: 2555: 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 > Do you need to use QTextEdit for the output? Sounds like maybe you should look at for example the QTableWidget or maybe the QTreeWidget? Tina -- http://mail.python.org/mailman/listinfo/python-list
Re: Beginner: Formatting text output (PyQt4)
On Wed, 18 Apr 2007 22:50:14 +, 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: 11526: 11435: 11219: 10816: 107 45: 10740: 106 > 5: 10541: 104 2: 103 9: 10248: 10215: 10122: 101 27: > 101 39: 10143: 10110: 1006: 9934: 99 32: 9849: 98 >20: 9730: 978: 96 17: 9638: 9612: 9514: 95 > 37: 95 4: 9413: 9444: 9436: 933: 92 24: 92 28: > 9231: 9129: 897: 88 > 1: 8718: 8546: 8533: 8411: 83 > 23: 8347: 8225: 8021: 7950: 56 52: 3951: 38 > 53: 3654: 2555: 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
Beginner: Formatting text output (PyQt4)
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: 11526: 11435: 11219: 10816: 107 45: 10740: 1065: 10541: 104 2: 103 9: 10248: 10215: 10122: 10127: 101 39: 10143: 10110: 1006: 9934: 99 32: 9849: 9820: 9730: 978: 96 17: 9638: 9612: 9514: 9537: 95 4: 9413: 9444: 9436: 933: 92 24: 9228: 9231: 9129: 897: 88 1: 8718: 8546: 8533: 8411: 83 23: 8347: 8225: 8021: 7950: 56 52: 3951: 3853: 3654: 2555: 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