diff options
author | aneejit1 <aneejit1@gmail.com> | 2022-04-19 13:21:52 +0000 |
---|---|---|
committer | Slávek Banko <slavek.banko@axis.cz> | 2022-07-27 18:08:53 +0200 |
commit | 6be046642290c28c17949022fb66ae02ac21d544 (patch) | |
tree | e7b38b35a42b27569b26736afc4e472a2a5d672d /examples3/SQL | |
parent | 63fe0b82b47e7ee31f91374d96022a3ae77a86c3 (diff) | |
download | pytqt-6be046642290c28c17949022fb66ae02ac21d544.tar.gz pytqt-6be046642290c28c17949022fb66ae02ac21d544.zip |
Updates to support Python version 3
Amendments to the sip source and configuration/build scripts to allow
for support under Python version 3. The examples have been updated
using "2to3" along with some manual changes to sort out intentation
and casting to integer from float.
Signed-off-by: aneejit1 <aneejit1@gmail.com>
Signed-off-by: Slávek Banko <slavek.banko@axis.cz>
Diffstat (limited to 'examples3/SQL')
-rwxr-xr-x | examples3/SQL/dbconnect.py | 10 | ||||
-rwxr-xr-x | examples3/SQL/sqlsubclass5.py | 12 | ||||
-rwxr-xr-x | examples3/SQL/sqltable4.py | 6 |
3 files changed, 14 insertions, 14 deletions
diff --git a/examples3/SQL/dbconnect.py b/examples3/SQL/dbconnect.py index db922de..d1c1baf 100755 --- a/examples3/SQL/dbconnect.py +++ b/examples3/SQL/dbconnect.py @@ -14,7 +14,7 @@ def createConnection(): driver = DB_DRIVER # all qt examples use TQSqlDatabase::addDatabase, but # this never returns NULL in my experience - drivers = map(str, TQSqlDatabase.drivers()) + drivers = list(map(str, TQSqlDatabase.drivers())) if driver in drivers: dlg = dbConnect(driver) #TODO: make connection parameters accessible @@ -40,8 +40,8 @@ class dbConnect(frmConnect): self.txtName.setText(self.username) self.txtPasswd.setText(self.password) - map(self.cmbServer.insertItem, self.hostnames) - map(self.cmbDatabase.insertItem, self.databases) + list(map(self.cmbServer.insertItem, self.hostnames)) + list(map(self.cmbDatabase.insertItem, self.databases)) self.connect(self.buttonHelp, SIGNAL("clicked()"), self.buttonHelp_clicked) @@ -77,6 +77,6 @@ class dbConnect(frmConnect): if __name__ == "__main__": app = TQApplication(sys.argv) if createConnection(): - print "ok" + print("ok") else: - print "cancel" + print("cancel") diff --git a/examples3/SQL/sqlsubclass5.py b/examples3/SQL/sqlsubclass5.py index 56f747e..0fdc78c 100755 --- a/examples3/SQL/sqlsubclass5.py +++ b/examples3/SQL/sqlsubclass5.py @@ -31,7 +31,7 @@ class CustomTable(TQDataTable): query = TQSqlQuery("SELECT name FROM prices WHERE id=%s" % field.value().toString()) value = "" - if query.next(): + if next(query): value = query.value(0).toString() p.drawText(2, 2, cr.width()-4, cr.height()-4, self.fieldAlignment(field), value) @@ -42,7 +42,7 @@ class CustomTable(TQDataTable): v = field.value().toDouble() if v < 0: p.setPen(TQColor("red")) - value = TQString(u"%.2f \u20ac" % v) + value = TQString("%.2f \u20ac" % v) p.drawText(2, 2, cr.width()-6, cr.height()-4, TQt.AlignRight|TQt.AlignVCenter, value) elif fn == "paiddate": @@ -74,17 +74,17 @@ class InvoiceItemCursor(TQSqlCursor): if fn == "productname": query = TQSqlQuery("SELECT name FROM prices WHERE id=%d;" % (self.field("pricesid").value().toInt())) - if query.next(): + if next(query): return query.value(0) elif fn == "price": query = TQSqlQuery("SELECT price FROM prices WHERE id=%d;" % (self.field("pricesid").value().toInt())) - if query.next(): + if next(query): return query.value(0) elif fn == "cost": query = TQSqlQuery("SELECT price FROM prices WHERE id=%d;" % (self.field("pricesid").value().toInt())) - if query.next(): + if next(query): return TQVariant(query.value(0).toDouble() * self.value("quantity").toDouble()) return TQVariant(TQString.null) @@ -102,7 +102,7 @@ class ProductPicker(TQComboBox): TQComboBox.__init__(self, parent, name) cur = TQSqlCursor("prices") cur.select(cur.index("id")) - while cur.next(): + while next(cur): self.insertItem(cur.value("name").toString(), cur.value("id").toInt()) diff --git a/examples3/SQL/sqltable4.py b/examples3/SQL/sqltable4.py index 599f093..a8484c5 100755 --- a/examples3/SQL/sqltable4.py +++ b/examples3/SQL/sqltable4.py @@ -31,7 +31,7 @@ class CustomTable(TQDataTable): v = field.value().toDouble() if v < 0: p.setPen(TQColor("red")) - value = TQString(u"%.2f \u20ac" % v) + 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) @@ -39,7 +39,7 @@ class CustomTable(TQDataTable): query = TQSqlQuery("SELECT name FROM status WHERE id=%s" % field.value().toString()) value = "" - if query.next(): + if next(query): value = query.value(0).toString() p.drawText(2, 2, cr.width()-4, cr.height()-4, self.fieldAlignment(field), value) @@ -52,7 +52,7 @@ class StatusPicker(TQComboBox): TQComboBox.__init__(self, parent, name) cur = TQSqlCursor("status") cur.select(cur.index("id")) - while cur.next(): + while next(cur): self.insertItem(cur.value("name").toString(), cur.value("id").toInt()) |