Search code examples
pythonpyqt4qtextedit

Is there a way to set a fixed width for the characters in HTML?


Is there a way to set a fix size for the characters in HTML? That means, say …

First row, 8th character is “Z” Second row’s 8th character is “A”

I want to print out , when printed the “Z” has to be exactly on top of “A”

*Note: I'm using the insertHtml method in QTextEdit()


Solution

  • What you're asking for is called a fixed-width font. As James Hopkin remarked, HTML text in <tt> or <pre> tags is rendered with a fixed-width font.

    However, what you describe sounds like a table. HTML has direct support for that, with <table>, <tr> (row) and <td> (data/cell). Don't bother with fixed-width fonts; just put your A and the Z in the second <td> of their rows.