def __init__(self):
super(TransactionsTable, self).__init__()
tw = self
tw.setColumnCount(5)
hedlabels = ('Status', 'Date', 'Transactions', 'Credits', 'Balance')
self.hedprops = (130, 150, 400, 100, 100)
tw.setHorizontalHeaderLabels(hedlabels)
for i, sz in enumerate(self.hedprops):
tw.horizontalHeader().resizeSection(i, sz)
tw.setSelectionBehavior(tw.SelectRows)
tw.setSelectionMode(tw.NoSelection)
tw.setFocusPolicy(Qt.NoFocus)
tw.setAlternatingRowColors(True)
tw.verticalHeader().hide()
tw.setShowGrid(False)
tw.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
#tw.setFixedSize(870, 300)
#tw.horizontalHeader().setResizeMode(QHeaderView.Stretch)
self.horizontalHeader().setStretchLastSection(True)
def resizeEvent(self, event):
selfsz = event.size().width()
totalprops = sum(self.hedprops)
newszs = [sz * selfsz / totalprops for sz in self.hedprops]
for i, sz in enumerate(newszs):
self.horizontalHeader().resizeSection(i, sz)
class TransactionsTable(QTableWidget):
def __init__(self):
super(TransactionsTable, self).__init__()
tw = self
tw.setColumnCount(5)
hedlabels = ('Status', 'Date', 'Transactions', 'Credits', 'Balance')
self.hedprops = (130, 150, 400, 100, 100)
tw.setHorizontalHeaderLabels(hedlabels)
for i, sz in enumerate(self.hedprops):
tw.horizontalHeader().resizeSection(i, sz)
tw.setSelectionBehavior(tw.SelectRows)
tw.setSelectionMode(tw.NoSelection)
tw.setFocusPolicy(Qt.NoFocus)
tw.setAlternatingRowColors(True)
tw.verticalHeader().hide()
tw.setShowGrid(False)
tw.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
#tw.setFixedSize(870, 300)
#tw.horizontalHeader().setResizeMode(QHeaderView.Stretch)
self.horizontalHeader().setStretchLastSection(True)
def resizeEvent(self, event):
selfsz = event.size().width()
totalprops = sum(self.hedprops)
newszs = [sz * selfsz / totalprops for sz in self.hedprops]
for i, sz in enumerate(newszs):
self.horizontalHeader().resizeSection(i, sz)
To copy to clipboard, switch view to plain text mode
Bookmarks