summaryrefslogtreecommitdiffstats
path: root/examples/pykde-sampler/qt_widgets/table.py
diff options
context:
space:
mode:
authortpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2011-08-16 09:06:37 +0000
committertpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2011-08-16 09:06:37 +0000
commit39d98386f72c65826e162e3e8fd36752ec469252 (patch)
tree5cec746207c4c892d064beafca1de94568a3aeb9 /examples/pykde-sampler/qt_widgets/table.py
downloadpytde-39d98386f72c65826e162e3e8fd36752ec469252.tar.gz
pytde-39d98386f72c65826e162e3e8fd36752ec469252.zip
Move python-kde3 to the more correct python-trinity
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/libraries/python-trinity@1247483 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'examples/pykde-sampler/qt_widgets/table.py')
-rw-r--r--examples/pykde-sampler/qt_widgets/table.py42
1 files changed, 42 insertions, 0 deletions
diff --git a/examples/pykde-sampler/qt_widgets/table.py b/examples/pykde-sampler/qt_widgets/table.py
new file mode 100644
index 0000000..d6b6e3e
--- /dev/null
+++ b/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)