summaryrefslogtreecommitdiffstats
path: root/examples/pytde-sampler/qt_widgets/table.py
diff options
context:
space:
mode:
authorTimothy Pearson <[email protected]>2011-12-05 00:17:19 -0600
committerTimothy Pearson <[email protected]>2011-12-05 00:17:19 -0600
commitd070aee4c277d331e54b81ac2881977a8d8cb7c0 (patch)
tree81fc5f857e6f4eafafd48f2ae70a787e02d10c5d /examples/pytde-sampler/qt_widgets/table.py
parent01bd7e2ffdc3caa95228e03ad501d778b05270a9 (diff)
downloadpytde-d070aee4c277d331e54b81ac2881977a8d8cb7c0.tar.gz
pytde-d070aee4c277d331e54b81ac2881977a8d8cb7c0.zip
Finish pykde to pytde rename
Diffstat (limited to 'examples/pytde-sampler/qt_widgets/table.py')
-rw-r--r--examples/pytde-sampler/qt_widgets/table.py42
1 files changed, 42 insertions, 0 deletions
diff --git a/examples/pytde-sampler/qt_widgets/table.py b/examples/pytde-sampler/qt_widgets/table.py
new file mode 100644
index 0000000..4a689d2
--- /dev/null
+++ b/examples/pytde-sampler/qt_widgets/table.py
@@ -0,0 +1,42 @@
+labelText = 'TQTable'
+iconName = 'inline_table'
+
+helpText = """From the docs: 'The TQTable class provides a flexible
+editable table widget.'
+"""
+
+import csv
+import os
+
+from qt import TQFrame, TQStringList, TQVBoxLayout, SIGNAL
+from qttable import TQTable
+
+from tdeui import KTextEdit
+
+contrib = os.path.join(os.path.split(__file__)[0], 'CONTRIB')
+
+
+class MainFrame(TQFrame):
+ def __init__(self, parent=None):
+ TQFrame.__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 = TQTable(len(items), len(header), self)
+ headers = TQStringList()
+ 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 = TQVBoxLayout(self, 4)
+ layout.addWidget(self.help)
+ layout.addWidget(self.table)
+ layout.addStretch(1)