2017-08-20 28 views
0

目前,我有一個CSV文件,該文件把CSV數據到表PyQt4中

with open('MY CSV FILE ', 'r') as csv: 
       line = csv.reader(csvf, delimiter=' ', quotechar='|') 
       for row in line: 
        print ",".join(row) 
        #IF I DO print(account) it will print the accounts into the SHELL, 

我怎麼能得到各行成PyQt4中的表?以某種方式使用PyQt.QLabel?關於創建表的文檔對我來說不是很清楚。

回答

0

使用PyQT Table Widget。您可以在「表格」窗口小部件中指定該列,然後可以將該值設置爲表格窗口小部件的單元格。您可以使用.setItem函數設置值

item = QTableWidgetItem() 
item.setText("blah blah") 
self.tableWidget.setItem(n, 0, item) 

其中n i行和0是列,項是值。