9 QAbstractTableModel.__init__(self, parent)
13 return len(self.table.rows)
16 if role!=Qt.DisplayRole
or orientation!=Qt.Horizontal:
18 return self.table.col_names[section]
21 return len(self.table.col_names)
23 def sort(self, column, order):
25 if order!=Qt.AscendingOrder:
27 self.table.Sort(by=self.table.col_names[column], order=o)
30 def data(self, index, role):
31 if not index.isValid()
or role!=Qt.DisplayRole:
33 row=self.table.rows[index.row()]
34 return QVariant(row[index.column()])
38 QTableView.__init__(self)
40 self.setFrameShape(QFrame.NoFrame)
41 self.setAttribute(Qt.WA_MacSmallSize)
42 self.setShowGrid(
False)
44 self.setContextMenuPolicy(Qt.CustomContextMenu)
45 self.setSelectionBehavior(QAbstractItemView.SelectRows)
46 self.setSizePolicy(QSizePolicy.MinimumExpanding,
47 QSizePolicy.MinimumExpanding)
48 self.setSortingEnabled(
True)