summaryrefslogtreecommitdiffstats
path: root/examples3/SQL/sqltable4.py
diff options
context:
space:
mode:
authoraneejit1 <aneejit1@gmail.com>2022-07-28 15:46:19 +0000
committeraneejit1 <aneejit1@gmail.com>2022-07-30 17:54:15 +0000
commite602246539fd7435aaeb440fcb7f852c92c8426b (patch)
tree35e09f5d93c67158e6c1160d6d9b27ae8a0bf966 /examples3/SQL/sqltable4.py
parentb34531364d5c0d3be7056d87011afd8bd538a0e7 (diff)
downloadpytqt-e602246539fd7435aaeb440fcb7f852c92c8426b.tar.gz
pytqt-e602246539fd7435aaeb440fcb7f852c92c8426b.zip
Remove Qt V2 support and example files
Build files for pyuic2 have been removed along with the examples for version 2 of Qt and the build/configure scripts have been amended accordingly. The "examples3" directory has been renamed to just "examples". Signed-off-by: aneejit1 <aneejit1@gmail.com>
Diffstat (limited to 'examples3/SQL/sqltable4.py')
-rwxr-xr-xexamples3/SQL/sqltable4.py118
1 files changed, 0 insertions, 118 deletions
diff --git a/examples3/SQL/sqltable4.py b/examples3/SQL/sqltable4.py
deleted file mode 100755
index a8484c5..0000000
--- a/examples3/SQL/sqltable4.py
+++ /dev/null
@@ -1,118 +0,0 @@
-#!/usr/bin/env python
-
-#****************************************************************************
-#** $Id: sqltable4.py,v 1.3 2002/07/06 13:35:41 phil Exp $
-#**
-#** Copyright (C) 1992-1998 Troll Tech AS. All rights reserved.
-#**
-#** This file is part of an example program for PyTQt. This example
-#** program may be used, distributed and modified without limitation.
-#**
-#*****************************************************************************/
-
-import sys
-from python_tqt.qt import *
-from python_tqt.qtsql import *
-
-from dbconnect import createConnection
-
-TRUE = 1
-FALSE = 0
-
-class CustomTable(TQDataTable):
- def __init__(self, cursor, autoPopulate = FALSE, parent = None, name = None):
- TQDataTable.__init__(self, cursor, autoPopulate, parent, name)
-
- def paintField(self, p, field, cr, b):
- if not field:
- return
- fn = str(field.name())
- if fn in ("salary", "monsalary"):
- v = field.value().toDouble()
- if v < 0:
- p.setPen(TQColor("red"))
- value = TQString("%.2f \u20ac" % v)
- #print unicode(value).encode("iso-8859-15")
- p.drawText(2, 2, cr.width()-6, cr.height()-4,
- TQt.AlignRight|TQt.AlignVCenter, value)
- elif fn == "statusid":
- query = TQSqlQuery("SELECT name FROM status WHERE id=%s" %
- field.value().toString())
- value = ""
- if next(query):
- value = query.value(0).toString()
- p.drawText(2, 2, cr.width()-4, cr.height()-4,
- self.fieldAlignment(field), value)
- else:
- TQDataTable.paintField(self, p, field, cr, b)
-
-
-class StatusPicker(TQComboBox):
- def __init__(self, parent = None, name = None):
- TQComboBox.__init__(self, parent, name)
- cur = TQSqlCursor("status")
- cur.select(cur.index("id"))
- while next(cur):
- self.insertItem(cur.value("name").toString(), cur.value("id").toInt())
-
-
-class CustomSqlEditorFactory(TQSqlEditorFactory):
- def __init__(self):
- TQSqlEditorFactory.__init__(self)
-
- def createEditor(self, parent, field):
- try:
- if str(field.name()) == "statusid":
- return StatusPicker(parent)
- except AttributeError:
- pass
- return TQSqlEditorFactory.createEditor(self, parent, field)
-
-
-class StaffCursor(TQSqlCursor):
- def __init__(self):
- TQSqlCursor.__init__(self, "staff")
- monSalary = TQSqlFieldInfo("monsalary", TQVariant.Double)
- self.append(monSalary)
- self.setCalculated(monSalary.name(), TRUE)
-
- def calculateField(self, name):
- if str(name) == "monsalary":
- return TQVariant(self.value("salary").toDouble() / 12)
- return TQVariant(TQString.null)
-
-
-class Table(CustomTable):
- def __init__(self):
- #self.staffCursor = TQSqlCursor("staff")
- self.staffCursor = StaffCursor()
- TQDataTable.__init__(self, self.staffCursor)
- self.propMap = TQSqlPropertyMap()
- self.editorFactory = CustomSqlEditorFactory()
- self.propMap.insert("StatusPicker", "statusid")
- self.installPropertyMap(self.propMap)
- self.installEditorFactory(self.editorFactory)
- for cn, ch in (("forename", "Forename"),
- ("surname", "Surname" ),
- ("salary", "Annual Salary"),
- ("monsalary","Monthly Salary"),
- ("statusid", "Status")):
- self.addColumn(cn, ch)
- self.order = TQStringList("surname")
- self.order.append("forename")
- self.setSort(self.order)
- self.refresh()
-
-
-if __name__=='__main__':
- app = TQApplication(sys.argv)
- #app.setFont(TQFont("Verdana", 11))
-
- if createConnection():
- t = Table()
- app.setMainWidget(t)
- t.resize(600, 250)
- t.show()
- app.exec_loop()
-
-