diff options
author | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
---|---|---|
committer | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
commit | 90825e2392b2d70e43c7a25b8a3752299a933894 (patch) | |
tree | e33aa27f02b74604afbfd0ea4f1cfca8833d882a /python/pykde/examples/pykde-sampler/qt_widgets/table.py | |
download | tdebindings-90825e2392b2d70e43c7a25b8a3752299a933894.tar.gz tdebindings-90825e2392b2d70e43c7a25b8a3752299a933894.zip |
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdebindings@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'python/pykde/examples/pykde-sampler/qt_widgets/table.py')
-rw-r--r-- | python/pykde/examples/pykde-sampler/qt_widgets/table.py | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/python/pykde/examples/pykde-sampler/qt_widgets/table.py b/python/pykde/examples/pykde-sampler/qt_widgets/table.py new file mode 100644 index 00000000..d6b6e3ed --- /dev/null +++ b/python/pykde/examples/pykde-sampler/qt_widgets/table.py @@ -0,0 +1,42 @@ +labelText = 'QTable' +iconName = 'inline_table' + +helpText = """From the docs: 'The QTable class provides a flexible +editable table widget.' +""" + +import csv +import os + +from qt import QFrame, QStringList, QVBoxLayout, SIGNAL +from qttable import QTable + +from kdeui import KTextEdit + +contrib = os.path.join(os.path.split(__file__)[0], 'CONTRIB') + + +class MainFrame(QFrame): + def __init__(self, parent=None): + QFrame.__init__(self, parent) + self.help = KTextEdit(helpText, '', self) + + data = csv.reader(open(contrib)) + header = data.next() + items = [item for item in data] + + self.table = table = QTable(len(items), len(header), self) + headers = QStringList() + 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]) + + layout = QVBoxLayout(self, 4) + layout.addWidget(self.help) + layout.addWidget(self.table) + layout.addStretch(1) |