QTableWidget Example using Python 2.4, QT 4.1.4, and PyQt
This is my OLD blog. I've copied this post over to my NEW blog at:
http://www.saltycrane.com/blog/2006/10/qtablewidget-example-using-python-24/
You should be redirected in 2 seconds.
QTableWidget Example using Python 2.4, QT 4.1.4, and PyQt
import sys from Qt import * lista = ['aa', 'ab', 'ac'] listb = ['ba', 'bb', 'bc'] listc = ['ca', 'cb', 'cc'] mystruct = {'A':lista, 'B':listb, 'C':listc} class MyTable(QTableWidget): def __init__(self, thestruct, *args): QTableWidget.__init__(self, *args) self.data = thestruct self.setmydata() def setmydata(self): n = 0 for key in self.data: m = 0 for item in self.data[key]: newitem = QTableWidgetItem(item) self.setItem(m, n, newitem) m += 1 n += 1 def main(args): app = QApplication(args) table = MyTable(mystruct, 5, 3) table.show() sys.exit(app.exec_()) if __name__=="__main__": main(sys.argv)
No comments:
Post a Comment