You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
43 lines
1.1 KiB
43 lines
1.1 KiB
13 years ago
|
labelText = 'TQTable'
|
||
14 years ago
|
iconName = 'inline_table'
|
||
|
|
||
13 years ago
|
helpText = """From the docs: 'The TQTable class provides a flexible
|
||
14 years ago
|
editable table widget.'
|
||
|
"""
|
||
|
|
||
|
import csv
|
||
|
import os
|
||
|
|
||
13 years ago
|
from qt import TQFrame, TQStringList, TQVBoxLayout, SIGNAL
|
||
|
from qttable import TQTable
|
||
14 years ago
|
|
||
13 years ago
|
from tdeui import KTextEdit
|
||
14 years ago
|
|
||
|
contrib = os.path.join(os.path.split(__file__)[0], 'CONTRIB')
|
||
|
|
||
|
|
||
13 years ago
|
class MainFrame(TQFrame):
|
||
14 years ago
|
def __init__(self, parent=None):
|
||
13 years ago
|
TQFrame.__init__(self, parent)
|
||
14 years ago
|
self.help = KTextEdit(helpText, '', self)
|
||
|
|
||
|
data = csv.reader(open(contrib))
|
||
|
header = data.next()
|
||
|
items = [item for item in data]
|
||
|
|
||
13 years ago
|
self.table = table = TQTable(len(items), len(header), self)
|
||
|
headers = TQStringList()
|
||
14 years ago
|
for headertext in header:
|
||
|
headers.append(headertext)
|
||
|
table.setColumnLabels(headers)
|
||
|
|
||
|
cols = range(len(header))
|
||
|
for row, record in enumerate(items):
|
||
|
for col in cols:
|
||
|
table.setText(row, col, record[col])
|
||
|
|
||
13 years ago
|
layout = TQVBoxLayout(self, 4)
|
||
14 years ago
|
layout.addWidget(self.help)
|
||
|
layout.addWidget(self.table)
|
||
|
layout.addStretch(1)
|