K
K
Kurum2017-03-02 16:20:56
Python
Kurum, 2017-03-02 16:20:56

How to convert multidimensional list to html table for QTextEdit?

Python 3. PyQt4
There are multidimensional lists like:

d = 

I want to translate such a thing into the form of an html table for insertion into a PyQt4 text field. So far I have written such a function, but it doesn’t make a fuss:
def on_click_7(self):
        def aps(i):
            i = ''.join(map(str, i))
            data.append(str(i))
        data = []
        self.pole_vivod.clear() # очистка поля вывода
        aps(['<table>'])
        for i in range(len(d)):
            for j in range(len(d[i])):
                j = '<td>'+str(j)+'<\td>'
            i = '<tr>'+str(i)+'<\tr>'

        aps([d])    
        aps(['</table>'])
        print('<hr>')
        for i in data:
            self.pole_vivod.append(str(i))

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Elvis, 2017-03-02
@Pyrym

try changing the for based on this:

for i in d:
  print('<tr>')
  for j in i:
    print('<td>'+str(j)+'</td>')
  print('</tr>')

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question