summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoraneejit1 <aneejit1@gmail.com>2022-04-19 13:21:52 +0000
committerSlávek Banko <slavek.banko@axis.cz>2022-07-27 18:08:53 +0200
commit6be046642290c28c17949022fb66ae02ac21d544 (patch)
treee7b38b35a42b27569b26736afc4e472a2a5d672d
parent63fe0b82b47e7ee31f91374d96022a3ae77a86c3 (diff)
downloadpytqt-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>
-rw-r--r--build.py39
-rw-r--r--configure.py49
-rwxr-xr-xexamples2/aclock.py2
-rwxr-xr-xexamples2/addressbook.py2
-rwxr-xr-xexamples2/application.py2
-rwxr-xr-xexamples2/buttongroups.py2
-rwxr-xr-xexamples2/dclock.py2
-rwxr-xr-xexamples2/desktop.py16
-rwxr-xr-xexamples2/dirview.py2
-rw-r--r--examples2/dropsite.py6
-rwxr-xr-xexamples2/gears.py2
-rwxr-xr-xexamples2/menu.py2
-rw-r--r--examples2/secret.py2
-rwxr-xr-xexamples2/semaphore.py8
-rwxr-xr-xexamples2/splitter.py14
-rwxr-xr-xexamples2/table.py22
-rwxr-xr-xexamples2/tut10.py2
-rwxr-xr-xexamples2/tut11.py4
-rwxr-xr-xexamples2/tut12.py4
-rwxr-xr-xexamples2/tut13.py4
-rwxr-xr-xexamples2/tut14.py4
-rwxr-xr-xexamples2/tut8.py2
-rwxr-xr-xexamples2/tut9.py2
-rwxr-xr-xexamples2/widgets.py32
-rwxr-xr-xexamples3/SQL/dbconnect.py10
-rwxr-xr-xexamples3/SQL/sqlsubclass5.py12
-rwxr-xr-xexamples3/SQL/sqltable4.py6
-rwxr-xr-xexamples3/aclock.py2
-rwxr-xr-xexamples3/addressbook.py2
-rwxr-xr-xexamples3/application.py2
-rwxr-xr-xexamples3/biff.py2
-rwxr-xr-xexamples3/buttongroups.py2
-rwxr-xr-xexamples3/checklists.py32
-rwxr-xr-xexamples3/cursor.py44
-rwxr-xr-xexamples3/dclock.py2
-rwxr-xr-xexamples3/desktop.py4
-rwxr-xr-xexamples3/fontdisplayer.py14
-rwxr-xr-xexamples3/fonts.py6
-rwxr-xr-xexamples3/gears.py2
-rwxr-xr-xexamples3/i18n/i18n.py2
-rwxr-xr-xexamples3/mdi.py208
-rwxr-xr-xexamples3/progress.py2
-rwxr-xr-xexamples3/qdir.py21
-rwxr-xr-xexamples3/rangecontrols.py2
-rwxr-xr-xexamples3/richtext.py4
-rwxr-xr-xexamples3/semaphore.py4
-rwxr-xr-xexamples3/splitter.py4
-rwxr-xr-xexamples3/tablestatistics.py10
-rwxr-xr-xexamples3/tooltip.py2
-rwxr-xr-xexamples3/tut10.py2
-rwxr-xr-xexamples3/tut11.py4
-rwxr-xr-xexamples3/tut12.py4
-rwxr-xr-xexamples3/tut13.py4
-rwxr-xr-xexamples3/tut14.py4
-rwxr-xr-xexamples3/tut8.py2
-rwxr-xr-xexamples3/tut9.py2
-rw-r--r--examples3/webbrowser/mainwindow.py18
-rwxr-xr-xexamples3/widgets.py14
-rw-r--r--module-init.py2
-rw-r--r--sip/qt/qapplication.sip143
-rw-r--r--sip/qt/qarray.sip4
-rw-r--r--sip/qt/qbuttongroup.sip1
-rw-r--r--sip/qt/qbytearray.sip115
-rw-r--r--sip/qt/qcstring.sip8
-rw-r--r--sip/qt/qdragobject.sip1
-rw-r--r--sip/qt/qfile.sip8
-rw-r--r--sip/qt/qfontmetrics.sip2
-rw-r--r--sip/qt/qimage.sip9
-rw-r--r--sip/qt/qiodevice.sip32
-rw-r--r--sip/qt/qkeysequence.sip4
-rw-r--r--sip/qt/qlabel.sip1
-rw-r--r--sip/qt/qlcdnumber.sip1
-rw-r--r--sip/qt/qlistview.sip279
-rw-r--r--sip/qt/qmainwindow.sip1
-rw-r--r--sip/qt/qmemarray.sip4
-rw-r--r--sip/qt/qobject.sip169
-rw-r--r--sip/qt/qpainter.sip10
-rw-r--r--sip/qt/qpair.sip8
-rw-r--r--sip/qt/qpointarray.sip2
-rw-r--r--sip/qt/qpushbutton.sip1
-rw-r--r--sip/qt/qstring.sip525
-rw-r--r--sip/qt/qstringlist.sip2
-rw-r--r--sip/qt/qstrlist.sip10
-rw-r--r--sip/qt/qvaluelist.sip4
-rw-r--r--sip/qtnetwork/qftp.sip2
-rw-r--r--sip/qtnetwork/qhttp.sip2
-rw-r--r--sip/qtnetwork/qsocket.sip8
-rw-r--r--sip/qtnetwork/qsocketdevice.sip4
-rw-r--r--sip/qtpe/qpeapplication.sip2
89 files changed, 852 insertions, 1193 deletions
diff --git a/build.py b/build.py
index fa63bfc..890acad 100644
--- a/build.py
+++ b/build.py
@@ -37,8 +37,8 @@ import string
try:
import sip_tqt_config
except:
- print "Unable to import the sip_tqt_config module. Please make sure you have"
- print "SIP-TQt v3.9 or later installed."
+ print("Unable to import the sip_tqt_config module. Please make sure you have")
+ print("SIP-TQt v3.9 or later installed.")
sys.exit(1)
config = sip_tqt_config.SIPConfig("PyTQt 3.18.1")
@@ -67,20 +67,20 @@ def usage(rcode = 2):
rcode is the return code passed back to the calling process.
"""
- print "Usage:"
- print " %s [-h] [-a version] [-b dir] [-c] [-d dir] [-g] [-j #] [-n dir] [-o dir] [-r] [-v dir]" % sip_tqt_config.script()
- print "where:"
- print " -h display this help message"
- print " -a tag explicitly enable the qtpe module"
- print " -b dir where pyuic and pylupdate will be installed [default %s]" % config.default_bin_dir
- print " -c concatenate each module's C++ source files"
- print " -d dir where the PyTQt modules will be installed [default %s]" % config.default_mod_dir
- print " -g always release the GIL (SIP-TQt v3.x behaviour)"
- print " -j # split the concatenated C++ source files into # pieces [default 1]"
- print " -n dir the directory containing the TQScintilla header files [default %s]" % config.qt_inc_dir
- print " -o dir the directory containing the TQScintilla library [default %s]" % config.qt_lib_dir
- print " -r generate code with tracing enabled [default disabled]"
- print " -v dir where the PyTQt .sip files will be installed [default %s]" % config.default_sip_dir
+ print("Usage:")
+ print(" %s [-h] [-a version] [-b dir] [-c] [-d dir] [-g] [-j #] [-n dir] [-o dir] [-r] [-v dir]" % sip_tqt_config.script())
+ print("where:")
+ print(" -h display this help message")
+ print(" -a tag explicitly enable the qtpe module")
+ print(" -b dir where pyuic and pylupdate will be installed [default %s]" % config.default_bin_dir)
+ print(" -c concatenate each module's C++ source files")
+ print(" -d dir where the PyTQt modules will be installed [default %s]" % config.default_mod_dir)
+ print(" -g always release the GIL (SIP-TQt v3.x behaviour)")
+ print(" -j # split the concatenated C++ source files into # pieces [default 1]")
+ print(" -n dir the directory containing the TQScintilla header files [default %s]" % config.qt_inc_dir)
+ print(" -o dir the directory containing the TQScintilla library [default %s]" % config.qt_lib_dir)
+ print(" -r generate code with tracing enabled [default disabled]")
+ print(" -v dir where the PyTQt .sip files will be installed [default %s]" % config.default_sip_dir)
sys.exit(rcode)
@@ -439,7 +439,7 @@ def versionToTag(vers, tags, desc):
"""
tag = None
- vl = tags.keys()
+ vl = list(tags.keys())
vl.sort()
# For a snapshot use the latest tag.
@@ -723,8 +723,7 @@ if __name__ == "__main__":
except SystemExit:
raise
except:
- print \
-"""An internal error occured. Please report all the output from the program,
+ print("""An internal error occured. Please report all the output from the program,
including the following traceback, to support@riverbankcomputing.co.uk.
-"""
+""")
raise
diff --git a/configure.py b/configure.py
index a34b71d..b5c4221 100644
--- a/configure.py
+++ b/configure.py
@@ -85,6 +85,7 @@ opt_split = 1
opt_tracing = 0
opt_verbose = 0
opt_keepfeatures = 0
+opt_accept_license = 0
opt_vendorcheck = 0
opt_vendincdir = sipcfg.py_inc_dir
@@ -126,6 +127,7 @@ def usage(rcode = 2):
sys.stdout.write(" -v dir where the PyTQt .sip files will be installed [default %s]\n" % opt_pyqtsipdir)
sys.stdout.write(" -w don't suppress compiler output during configuration\n")
sys.stdout.write(" -y lib explicitly specify the type of TQt library, either qt, qt-mt, qte, qte-mt, qtmt, tqt, tqt-mt, tqte, tqte-mt or tqtmt\n")
+ sys.stdout.write(" -z accept the license terms without prompting\n")
sys.exit(rcode)
@@ -391,10 +393,10 @@ def inform_user():
sip_tqt_config.inform("TQt v%s %sis being used." % (sip_tqt_config.version_to_string(qt_version), edstr))
sip_tqt_config.inform("SIP-TQt %s is being used." % sipcfg.sip_version_str)
- sip_tqt_config.inform("These PyTQt modules will be built: %s." % string.join(pyqt_modules))
+ sip_tqt_config.inform("These PyTQt modules will be built: %s." % ' '.join(pyqt_modules))
if disabled_classes:
- sip_tqt_config.inform("Support for these TQt classes has been disabled: %s." % string.join(disabled_classes))
+ sip_tqt_config.inform("Support for these TQt classes has been disabled: %s." % ' '.join(disabled_classes))
sip_tqt_config.inform("The PyTQt modules will be installed in %s." % opt_pyqtmoddir)
sip_tqt_config.inform("The PyTQt .sip files will be installed in %s." % opt_pyqtsipdir)
@@ -579,7 +581,7 @@ def check_qscintilla():
# If we find a snapshot then set a negative version number as a
# special case.
- if string.find(sciversstr, "snapshot") >= 0:
+ if sciversstr.find("snapshot") >= 0:
qsci_version = -1
else:
sip_tqt_config.inform("The TQScintilla library could not be found in %s and so the qtext module will not be built. If TQScintilla is installed then use the -o argument to explicitly specify the correct directory." % opt_qscilibdir)
@@ -801,7 +803,7 @@ def get_feature_flags():
line = ff.readline()
while line:
- flags.extend(string.split(line))
+ flags.extend(line.split())
line = ff.readline()
if sipcfg.sip_version >= 0x040702:
@@ -929,9 +931,9 @@ def generate_code(mname, extra_cflags=None, extra_cxxflags=None, extra_define=No
argv.append(os.path.join(src_dir, "sip"))
# SIP-TQt assumes POSIX style path separators.
- argv.append(string.join([src_dir, "sip", mname, mname + "mod.sip"], "/"))
+ argv.append('/'.join([src_dir, "sip", mname, mname + "mod.sip"]))
- os.system(string.join(argv))
+ os.system(' '.join(argv))
# Check the result.
if not os.access(buildfile, os.F_OK):
@@ -1005,7 +1007,7 @@ def check_license():
lname = "GNU General Public License"
lfile = None
- sip_tqt_config.inform("This is the %s version of PyTQt %s (licensed under the %s) for Python %s on %s." % (ltype, pyqt_version_str, lname, string.split(sys.version)[0], sys.platform))
+ sip_tqt_config.inform("This is the %s version of PyTQt %s (licensed under the %s) for Python %s on %s." % (ltype, pyqt_version_str, lname, sys.version[0].split(), sys.platform))
# Common checks.
if ltype == "GPL" and sys.platform == "win32":
@@ -1029,12 +1031,17 @@ Type 'no' to decline the terms of the license.
""")
while 1:
+ sys.stdout.write("Do you accept the terms of the license? ")
+ sys.stdout.flush()
+
try:
- resp = raw_input("Do you accept the terms of the license? ")
+ resp = sys.stdin.readline()
+ except KeyboardInterrupt:
+ raise SystemExit
except:
resp = ""
- resp = string.lower(string.strip(resp))
+ resp = resp.strip().lower()
if resp == "yes":
break
@@ -1060,7 +1067,7 @@ def get_build_macros(overrides):
overrides is a list of macros overrides from the user.
"""
# Get the name of the qmake configuration file to take the macros from.
- if "QMAKESPEC" in os.environ.keys():
+ if "QMAKESPEC" in list(os.environ.keys()):
fname = os.path.join(qt_dir, "mkspecs", os.environ["QMAKESPEC"], "qmake.conf")
else:
fname = os.path.join(qt_dir, "mkspecs", "default", "qmake.conf")
@@ -1069,7 +1076,7 @@ def get_build_macros(overrides):
sip_tqt_config.error("Unable to find the default configuration file %s. You can use the QMAKESPEC environment variable to specify the correct platform instead of \"default\"." % fname)
# Add the TQt specific macros to the default.
- names = sipcfg.build_macros().keys()
+ names = list(sipcfg.build_macros().keys())
names.append("INCDIR_TQT")
names.append("LIBDIR_TQT")
names.append("MOC")
@@ -1163,7 +1170,7 @@ def check_qt_installation(macros):
l = f.readline()
while l:
- wl = string.split(l)
+ wl = l.split()
if len(wl) == 3 and wl[0] == "#define" and wl[1] == "QT_PRODUCT_LICENSE":
qt_edition = wl[2][4:-1]
break
@@ -1193,7 +1200,7 @@ def check_qt_installation(macros):
cfg = f.readline()
f.close()
- val = string.find(cfg, "=")
+ val = cfg.find("=")
if val >= 0:
qt_winconfig = string.strip(cfg[val + 1:])
@@ -1292,7 +1299,7 @@ def resolve_qt3_library(generator):
sip_tqt_config.error("No TQt libraries could be found in %s." % qt_libdir)
if len(names) > 1:
- sip_tqt_config.error("These TQt libraries were found: %s. Use the -y argument to explicitly specify which you want to use." % string.join(names))
+ sip_tqt_config.error("These TQt libraries were found: %s. Use the -y argument to explicitly specify which you want to use." % ' '.join(names))
def is_qt_library(generator, lib):
@@ -1320,10 +1327,6 @@ def main(argv):
argv is the list of command line arguments.
"""
- # Check Python isn't too new.
- if sipcfg.py_version >= 0x030000:
- sip_tqt_config.error("PyTQt v3.x does not support Python v3.x")
-
# Check SIP-TQt is new enough.
if sipcfg.sip_version_str[:8] != "snapshot":
if sipcfg.sip_version < sip_min_version:
@@ -1331,7 +1334,7 @@ def main(argv):
# Parse the command line.
try:
- optlist, args = getopt.getopt(argv[1:], "ha:b:cd:e:fg:ij:kl:m:n:o:q:rsuv:wy:")
+ optlist, args = getopt.getopt(argv[1:], "ha:b:cd:e:fg:ij:kl:m:n:o:q:rsuv:wy:z")
except getopt.GetoptError:
usage()
@@ -1342,6 +1345,7 @@ def main(argv):
global opt_qsciincdir, opt_qscilibdir, qsci_define
global opt_vendorcheck, opt_vendincdir, opt_vendlibdir
global opt_libpython
+ global opt_accept_license
opt_libpython = None
@@ -1396,6 +1400,8 @@ def main(argv):
opt_tqtlib = arg
else:
usage()
+ elif opt == "-z":
+ opt_accept_license = 1
# Check that we know the name of the TQt root directory.
if not qt_dir:
@@ -1418,7 +1424,10 @@ def main(argv):
check_qt_installation(macros)
# Check the licenses are compatible.
- check_license()
+ if opt_accept_license == 1:
+ print("License accepted by command line option.")
+ else:
+ check_license()
# Check for TQScintilla.
check_qscintilla()
diff --git a/examples2/aclock.py b/examples2/aclock.py
index 3c04e20..66283ef 100755
--- a/examples2/aclock.py
+++ b/examples2/aclock.py
@@ -8,7 +8,7 @@ def TQMIN(x, y):
return x
class AnalogClock(TQWidget):
def __init__(self, *args):
- apply(TQWidget.__init__,(self,) + args)
+ TQWidget.__init__(*(self,) + args)
self.time = TQTime.currentTime()
internalTimer = TQTimer(self)
self.connect(internalTimer, SIGNAL("timeout()"), self.timeout)
diff --git a/examples2/addressbook.py b/examples2/addressbook.py
index 96746c0..14b5679 100755
--- a/examples2/addressbook.py
+++ b/examples2/addressbook.py
@@ -78,7 +78,7 @@ fileprint = [
class ABCentralWidget( TQWidget ):
def __init__( self, *args ):
- apply( TQWidget.__init__, (self, ) + args )
+ TQWidget.__init__(*(self, ) + args)
self.mainGrid = TQGridLayout( self, 2, 1, 5, 5 )
self.setupTabWidget()
diff --git a/examples2/application.py b/examples2/application.py
index 291231e..38a6cf5 100755
--- a/examples2/application.py
+++ b/examples2/application.py
@@ -179,7 +179,7 @@ class ApplicationWindow(TQMainWindow):
return
for l in f.readlines():
- self.e.append(string.rstrip(l))
+ self.e.append(l.rstrip())
f.close()
diff --git a/examples2/buttongroups.py b/examples2/buttongroups.py
index 88836c6..d3e0aaf 100755
--- a/examples2/buttongroups.py
+++ b/examples2/buttongroups.py
@@ -21,7 +21,7 @@ FALSE = 0
class ButtonsGroups( TQWidget ):
def __init__( self, *args ):
- apply( TQWidget.__init__, (self,) + args )
+ TQWidget.__init__(*(self,) + args)
# Create Widgets which allow easy layouting
self.vbox = TQVBoxLayout( self )
diff --git a/examples2/dclock.py b/examples2/dclock.py
index eb4e990..302d454 100755
--- a/examples2/dclock.py
+++ b/examples2/dclock.py
@@ -47,7 +47,7 @@ class DigitalClock(TQLCDNumber):
s[2] = ' '
if s[0] == '0':
s[0] = ' '
- s = string.join(s,'')
+ s = ''.join(s)
self.display(s)
a = TQApplication(sys.argv)
diff --git a/examples2/desktop.py b/examples2/desktop.py
index 049f39d..7f48159 100755
--- a/examples2/desktop.py
+++ b/examples2/desktop.py
@@ -26,7 +26,7 @@ maxcurves = 8
def poly():
d = TQApplication.desktop()
- d.setBackgroundColor(white)
+ d.setPaletteBackgroundColor(white)
xvel = [ 0 ] * 8
yvel = [ 0 ] * 8
head = 0
@@ -65,16 +65,16 @@ def poly():
y = y + yvel[i]
if x >= maxx:
x = maxx - (x - maxx + 1)
- xvel[i] = -velocity(i)
+ xvel[i] = -velocity(i)
if x <= minx:
x = minx + (minx - x + 1)
- xvel[i] = velocity(i)
+ xvel[i] = velocity(i)
if y >= maxy:
y = maxy - (y - maxy + 1)
- yvel[i] = -velocity(i)
+ yvel[i] = -velocity(i)
if y <= miny:
y = miny + (miny - y + 1)
- yvel[i] = velocity(i)
+ yvel[i] = velocity(i)
a[head].setPoint(i, x, y)
paint.end()
@@ -98,7 +98,7 @@ def rotate():
m = TQWMatrix()
m.rotate(i)
rpm = pm.xForm(m)
- d.setBackgroundPixmap(rpm)
+ d.setPaletteBackgroundPixmap(rpm)
d.update()
def generateStone(pm, c1, c2, c3):
@@ -142,7 +142,7 @@ class DesktopWidget(TQWidget):
if not self.pm:
self.pm = TQPixmap(64, 64)
generateStone(self.pm, c1, c2, c3)
- self.setBackgroundPixmap(self.pm)
+ self.setPaletteBackgroundPixmap(self.pm)
self.update()
br = self.fontMetrics().boundingRect(self.text)
offscreen = TQPixmap(br.width(), br.height())
@@ -186,7 +186,7 @@ def desktopText(s='Troll Tech'):
drawShadeText(p, -r.x()+border, -r.y()+border, s, c2, c3)
p.end()
- tqApp.desktop().setBackgroundPixmap(pm)
+ tqApp.desktop().setPaletteBackgroundPixmap(pm)
a = TQApplication(sys.argv)
if len(sys.argv) > 1:
diff --git a/examples2/dirview.py b/examples2/dirview.py
index 11e7eed..ef8bcd7 100755
--- a/examples2/dirview.py
+++ b/examples2/dirview.py
@@ -5,7 +5,7 @@ from python_tqt.qt import *
class Directory(TQListViewItem):
def __init__(self, parent, name=None):
- apply(TQListViewItem.__init__,(self,parent))
+ TQListViewItem.__init__(*(self,parent))
if isinstance(parent, TQListView):
self.p = None
self.f = '/'
diff --git a/examples2/dropsite.py b/examples2/dropsite.py
index 94b7e57..461b44e 100644
--- a/examples2/dropsite.py
+++ b/examples2/dropsite.py
@@ -49,15 +49,15 @@ class DropSite(TQLabel):
t += str(e.format( i ))
i += 1
self.emit(PYSIGNAL('message(TQString &)'), (TQString(t),))
- self.setBackgroundColor(TQt.white)
+ self.setPaletteBackgroundColor(TQt.white)
def dragLeaveEvent( self, TQDragLeaveEvent ):
# Give the user some feedback...
self.emit(PYSIGNAL('message(TQString &)'), (TQString(''),))
- self.setBackgroundColor(TQt.lightGray)
+ self.setPaletteBackgroundColor(TQt.lightGray)
def dropEvent( self, e ):
- self.setBackgroundColor(TQt.lightGray)
+ self.setPaletteBackgroundColor(TQt.lightGray)
# Try to decode to the data you understand...
str = TQString()
if ( TQTextDrag.decode( e, str ) ) :
diff --git a/examples2/gears.py b/examples2/gears.py
index 60f313c..54734cc 100755
--- a/examples2/gears.py
+++ b/examples2/gears.py
@@ -227,7 +227,7 @@ if __name__=='__main__':
app=TQApplication(sys.argv)
if not TQGLFormat.hasOpenGL():
- raise 'No TQt OpenGL support.'
+ raise Exception('No TQt OpenGL support.')
widget=GearWidget()
app.setMainWidget(widget)
diff --git a/examples2/menu.py b/examples2/menu.py
index 4b67156..28e5a88 100755
--- a/examples2/menu.py
+++ b/examples2/menu.py
@@ -133,7 +133,7 @@ p4_xpm = [
class MenuExample( TQWidget ):
def __init__( self, parent=None, name=None ):
- apply( TQWidget.__init__,(self, parent, name) )
+ TQWidget.__init__(*(self, parent, name))
self.p1 = TQIconSet( TQPixmap ( p1_xpm ) )
self.p2 = TQIconSet( TQPixmap ( p2_xpm ) )
self.p3 = TQIconSet( TQPixmap ( p3_xpm ) )
diff --git a/examples2/secret.py b/examples2/secret.py
index 8c8de85..d68bd1b 100644
--- a/examples2/secret.py
+++ b/examples2/secret.py
@@ -52,7 +52,7 @@ picture_xpm = [
class SecretSource(TQLabel):
def __init__(self, secret, parent=None, name=None):
TQLabel.__init__(self, "Secret", parent, name)
- self.setBackgroundColor( TQt.blue.light() )
+ self.setPaletteBackgroundColor( TQt.blue.light() )
self.setFrameStyle( TQLabel.Box | TQLabel.Sunken )
self.setMinimumHeight( self.sizeHint().height()*2 )
self.setAlignment( TQLabel.AlignCenter )
diff --git a/examples2/semaphore.py b/examples2/semaphore.py
index 6a16347..f1a2b7a 100755
--- a/examples2/semaphore.py
+++ b/examples2/semaphore.py
@@ -9,7 +9,7 @@ import sys
try:
from python_tqt.qt import TQThread
except:
- print "Thread support not enabled"
+ print("Thread support not enabled")
sys.exit(1)
from python_tqt.qt import *
@@ -176,9 +176,9 @@ class SemaphoreExample(TQWidget):
self.mlineedit.append(s)
if s.latin1() == "Green!":
- self.label.setBackgroundColor(TQt.green)
+ self.label.setPaletteBackgroundColor(TQt.green)
else:
- self.label.setBackgroundColor(TQt.yellow)
+ self.label.setPaletteBackgroundColor(TQt.yellow)
self.label.setText(s)
@@ -192,7 +192,7 @@ class SemaphoreExample(TQWidget):
del s
else:
- print "Unknown custom event type:", event.type()
+ print("Unknown custom event type:", event.type())
app = TQApplication(sys.argv)
diff --git a/examples2/splitter.py b/examples2/splitter.py
index 36a7556..3d7450c 100755
--- a/examples2/splitter.py
+++ b/examples2/splitter.py
@@ -16,13 +16,13 @@ class Test(TQWidget):
y1 = 0
y2 = self.height() - 1
- x = (x1+x2)/2
+ x = int((x1+x2)/2)
p.drawLine(x, y1, x+d, y1+d)
p.drawLine(x, y1, x-d, y1+d)
p.drawLine(x, y2, x+d, y2-d)
p.drawLine(x, y2, x-d, y2-d)
- y = (y1+y2)/2
+ y = int((y1+y2)/2)
p.drawLine(x1, y, x1+d, y+d)
p.drawLine(x1, y, x1+d, y-d)
p.drawLine(x2, y, x2-d, y+d)
@@ -36,25 +36,25 @@ if __name__=="__main__":
s2 = TQSplitter(TQt.Horizontal, s1, "top")
t1 = Test(s2)
- t1.setBackgroundColor(TQt.blue.light(180))
+ t1.setPaletteBackgroundColor(TQt.blue.light(180))
t1.setMinimumSize(50,0)
t2 = Test(s2)
- t2.setBackgroundColor(TQt.green.light(180))
+ t2.setPaletteBackgroundColor(TQt.green.light(180))
s2.setResizeMode(t2, TQSplitter.KeepSize)
s2.moveToFirst(t2)
s3 = TQSplitter(TQt.Horizontal, s1, "bottom")
t3 = Test(s3)
- t3.setBackgroundColor(TQt.red)
+ t3.setPaletteBackgroundColor(TQt.red)
t4 = Test(s3)
- t4.setBackgroundColor(TQt.white)
+ t4.setPaletteBackgroundColor(TQt.white)
t5 = Test(s3)
t5.setMaximumHeight(250)
t5.setMinimumSize(80,50)
- t5.setBackgroundColor(TQt.yellow)
+ t5.setPaletteBackgroundColor(TQt.yellow)
s1.setOpaqueResize(1)
s2.setOpaqueResize(1)
diff --git a/examples2/table.py b/examples2/table.py
index 36e2cf9..f9db886 100755
--- a/examples2/table.py
+++ b/examples2/table.py
@@ -14,8 +14,8 @@ class Table(TQTableView):
self.setCellWidth(100)
self.setCellHeight(30)
self.setTableFlags(Tbl_vScrollBar |
- Tbl_hScrollBar |
- Tbl_clipCellPainting)
+ Tbl_hScrollBar |
+ Tbl_clipCellPainting)
self.resize(400,200)
self.contents = [''] * (numRows * numCols)
@@ -64,27 +64,27 @@ class Table(TQTableView):
if key == Key_Left:
if self.curCol > 0:
self.curCol = self.curCol - 1
- edge = self.leftCell()
+ edge = self.leftCell()
if self.curCol < edge:
- self.setLeftCell(edge-1)
+ self.setLeftCell(edge-1)
elif key == Key_Right:
if self.curCol < self.numCols()-1:
self.curCol = self.curCol + 1
- edge = self.lastColVisible()
+ edge = self.lastColVisible()
if self.curCol >= edge:
- self.setLeftCell(self.leftCell()+1)
+ self.setLeftCell(self.leftCell()+1)
elif key == Key_Up:
if self.curRow > 0:
self.curRow = self.curRow - 1
- edge = self.topCell()
+ edge = self.topCell()
if self.curRow < edge:
- self.setTopCell(edge-1)
+ self.setTopCell(edge-1)
elif key == Key_Down:
if self.curRow < self.numRows()-1:
self.curRow = self.curRow + 1
- edge = self.lastRowVisible()
- if self.curRow >= edge:
- self.setTopCell(self.topCell()+1)
+ edge = self.lastRowVisible()
+ if self.curRow >= edge:
+ self.setTopCell(self.topCell()+1)
else:
ke.ignore()
return
diff --git a/examples2/tut10.py b/examples2/tut10.py
index b6213a5..a19ba9c 100755
--- a/examples2/tut10.py
+++ b/examples2/tut10.py
@@ -27,7 +27,7 @@ class LCDRange(TQVBox):
def setRange(self,minVal,maxVal):
if minVal < 0 or maxVal > 99 or minVal > maxVal:
- raise ValueError, 'LCDRange.setRange(): invalid range'
+ raise ValueError('LCDRange.setRange(): invalid range')
self.slider.setRange(minVal,maxVal)
diff --git a/examples2/tut11.py b/examples2/tut11.py
index 0f60d72..7979d3d 100755
--- a/examples2/tut11.py
+++ b/examples2/tut11.py
@@ -28,7 +28,7 @@ class LCDRange(TQVBox):
def setRange(self,minVal,maxVal):
if minVal < 0 or maxVal > 99 or minVal > maxVal:
- raise ValueError, 'LCDRange.setRange(): invalid range'
+ raise ValueError('LCDRange.setRange(): invalid range')
self.slider.setRange(minVal,maxVal)
@@ -149,7 +149,7 @@ class CannonField(TQWidget):
y = y0 + vely * time - 0.5 * gravity * time * time
r = TQRect(0,0,6,6)
- r.moveCenter(TQPoint(x,self.height() - 1 - y))
+ r.moveCenter(TQPoint(int(x),int(self.height() - 1 - y))))
return r
def sizePolicy(self):
diff --git a/examples2/tut12.py b/examples2/tut12.py
index 95f90b1..8b2a700 100755
--- a/examples2/tut12.py
+++ b/examples2/tut12.py
@@ -36,7 +36,7 @@ class LCDRange(TQVBox):
def setRange(self,minVal,maxVal):
if minVal < 0 or maxVal > 99 or minVal > maxVal:
- raise ValueError, 'LCDRange.setRange(): invalid range'
+ raise ValueError('LCDRange.setRange(): invalid range')
self.slider.setRange(minVal,maxVal)
def text(self):
@@ -183,7 +183,7 @@ class CannonField(TQWidget):
y = y0 + vely * time - 0.5 * gravity * time * time
r = TQRect(0,0,6,6)
- r.moveCenter(TQPoint(x,self.height() - 1 - y))
+ r.moveCenter(TQPoint(int(x),int(self.height() - 1 - y)))
return r
def targetRect(self):
diff --git a/examples2/tut13.py b/examples2/tut13.py
index 1584443..f33c683 100755
--- a/examples2/tut13.py
+++ b/examples2/tut13.py
@@ -41,7 +41,7 @@ class LCDRange(TQWidget):
def setRange(self,minVal,maxVal):
if minVal < 0 or maxVal > 99 or minVal > maxVal:
- raise ValueError, 'LCDRange.setRange(): invalid range'
+ raise ValueError('LCDRange.setRange(): invalid range')
self.slider.setRange(minVal,maxVal)
def text(self):
@@ -215,7 +215,7 @@ class CannonField(TQWidget):
y = y0 + vely * time - 0.5 * gravity * time * time
r = TQRect(0,0,6,6)
- r.moveCenter(TQPoint(x,self.height() - 1 - y))
+ r.moveCenter(TQPoint(int(x),int(self.height() - 1 - y)))
return r
def targetRect(self):
diff --git a/examples2/tut14.py b/examples2/tut14.py
index 1ee3a5c..998f26f 100755
--- a/examples2/tut14.py
+++ b/examples2/tut14.py
@@ -41,7 +41,7 @@ class LCDRange(TQWidget):
def setRange(self,minVal,maxVal):
if minVal < 0 or maxVal > 99 or minVal > maxVal:
- raise ValueError, 'LCDRange.setRange(): invalid range'
+ raise ValueError('LCDRange.setRange(): invalid range')
self.slider.setRange(minVal,maxVal)
def text(self):
@@ -245,7 +245,7 @@ class CannonField(TQWidget):
y = y0 + vely * time - 0.5 * gravity * time * time
r = TQRect(0,0,6,6)
- r.moveCenter(TQPoint(x,self.height() - 1 - y))
+ r.moveCenter(TQPoint(int(x),int(self.height() - 1 - y)))
return r
def targetRect(self):
diff --git a/examples2/tut8.py b/examples2/tut8.py
index d252e55..3266a89 100755
--- a/examples2/tut8.py
+++ b/examples2/tut8.py
@@ -27,7 +27,7 @@ class LCDRange(TQVBox):
def setRange(self,minVal,maxVal):
if minVal < 0 or maxVal > 99 or minVal > maxVal:
- raise ValueError, 'LCDRange.setRange(): invalid range'
+ raise ValueError('LCDRange.setRange(): invalid range')
self.slider.setRange(minVal,maxVal)
diff --git a/examples2/tut9.py b/examples2/tut9.py
index 5bad8d8..c413e00 100755
--- a/examples2/tut9.py
+++ b/examples2/tut9.py
@@ -27,7 +27,7 @@ class LCDRange(TQVBox):
def setRange(self,minVal,maxVal):
if minVal < 0 or maxVal > 99 or minVal > maxVal:
- raise ValueError, 'LCDRange.setRange(): invalid range'
+ raise ValueError('LCDRange.setRange(): invalid range')
self.slider.setRange(minVal,maxVal)
diff --git a/examples2/widgets.py b/examples2/widgets.py
index fc36e7a..cf235a8 100755
--- a/examples2/widgets.py
+++ b/examples2/widgets.py
@@ -18,7 +18,7 @@ def TQMIN( x, y ):
class AnalogClock( TQWidget ):
def __init__( self, *args ):
- apply( TQWidget.__init__, (self,) + args )
+ TQWidget.__init__(*(self,) + args)
self.time = TQTime.currentTime() # get current time
internalTimer = TQTimer( self ) # create internal timer
self.connect( internalTimer, SIGNAL("timeout()"), self.timeout )
@@ -74,7 +74,7 @@ class AnalogClock( TQWidget ):
class DigitalClock( TQLCDNumber ):
def __init__( self, *args ):
- apply( TQLCDNumber.__init__,(self,) + args )
+ TQLCDNumber.__init__(*(self,) + args)
self.showingColon = 0
self.setFrameStyle(TQFrame.Panel | TQFrame.Raised)
self.setLineWidth( 2 )
@@ -112,7 +112,7 @@ class DigitalClock( TQLCDNumber ):
s[2] = ' '
if s[0] == '0':
s[0] = ' '
- s = string.join(s,'')
+ s = ''.join(s)
self.display( s )
def TQMIN( x, y ):
@@ -130,7 +130,7 @@ MOVIEFILENAME = "trolltech.gif"
class WidgetView ( TQWidget ):
def __init__( self, *args ):
- apply( TQWidget.__init__, (self,) + args )
+ TQWidget.__init__(*(self,) + args)
# Set the window caption/title
self.setCaption( "TQt Widgets Demo Application" )
@@ -186,14 +186,14 @@ class WidgetView ( TQWidget ):
TQToolTip.add( self.dclock, "custom widget: digital clock" )
# Create a push button.
- self.pb = TQPushButton( self, "button1" ) # create button 1
+ self.pb = TQPushButton( self, "button1" ) # create button 1
self.pb.setText( "Push button 1" )
self.pb.setFixedHeight( self.pb.sizeHint().height() )
self.grid.addWidget( self.pb, 0, 0, TQt.AlignVCenter )
self.connect( self.pb, SIGNAL("clicked()"), self.button1Clicked )
TQToolTip.add( self.pb, "push button 1" )
self.pm = TQPixmap()
- self.pix = self.pm.load( "qt.png" ) # load pixmap for button 2
+ self.pix = self.pm.load( "qt.png" ) # load pixmap for button 2
if not self.pix:
TQMessageBox.information( None, "TQt Widgets Example",
"Could not load the file \"qt.png\", which\n"
@@ -224,7 +224,7 @@ class WidgetView ( TQWidget ):
self.vbox.addSpacing( self.bg.fontMetrics().height() )
- self.cb = range(3)
+ self.cb = list(range(3))
self.cb[0] = TQCheckBox( self.bg )
self.cb[0].setText( "Read" )
self.vbox.addWidget( self.cb[0] )
@@ -466,20 +466,20 @@ class WidgetView ( TQWidget ):
self.msg.setText( txt )
if index == 0:
TQApplication.setWinStyleHighlightColor( TQt.darkBlue )
- elif index == 1:
+ elif index == 1:
TQApplication.setWinStyleHighlightColor( TQt.darkRed )
- elif index == 2:
+ elif index == 2:
TQApplication.setWinStyleHighlightColor( TQt.darkGreen )
- elif index == 3:
+ elif index == 3:
TQApplication.setWinStyleHighlightColor( TQt.blue )
- elif index == 4:
+ elif index == 4:
TQApplication.setWinStyleHighlightColor( TQt.red )
def lineEditTextChanged( self, newText ):
- self.msg.setText("Line edit text: " + unicode(newText))
+ self.msg.setText("Line edit text: " + str(newText))
def spinBoxValueChanged( self, valueText ):
- self.msg.setText("Spin box value: " + unicode(valueText))
+ self.msg.setText("Spin box value: " + str(valueText))
# All application events are passed throught this event filter.
# We're using it to display some information about a clicked
@@ -496,10 +496,10 @@ class WidgetView ( TQWidget ):
# txt = txt + TQObject.name()
# else:
# txt = txt + "<no name>"
- # identify_now = FALSE # don't do it in message box
+ # identify_now = FALSE # don't do it in message box
# TQMessageBox.message( "Identify Widget", txt, 0, TQObject )
- # identify_now = TRUE; # allow it again
- # return FALSE # don't eat event
+ # identify_now = TRUE; # allow it again
+ # return FALSE # don't eat event
################################################################################################
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())
diff --git a/examples3/aclock.py b/examples3/aclock.py
index 3c04e20..66283ef 100755
--- a/examples3/aclock.py
+++ b/examples3/aclock.py
@@ -8,7 +8,7 @@ def TQMIN(x, y):
return x
class AnalogClock(TQWidget):
def __init__(self, *args):
- apply(TQWidget.__init__,(self,) + args)
+ TQWidget.__init__(*(self,) + args)
self.time = TQTime.currentTime()
internalTimer = TQTimer(self)
self.connect(internalTimer, SIGNAL("timeout()"), self.timeout)
diff --git a/examples3/addressbook.py b/examples3/addressbook.py
index 96746c0..14b5679 100755
--- a/examples3/addressbook.py
+++ b/examples3/addressbook.py
@@ -78,7 +78,7 @@ fileprint = [
class ABCentralWidget( TQWidget ):
def __init__( self, *args ):
- apply( TQWidget.__init__, (self, ) + args )
+ TQWidget.__init__(*(self, ) + args)
self.mainGrid = TQGridLayout( self, 2, 1, 5, 5 )
self.setupTabWidget()
diff --git a/examples3/application.py b/examples3/application.py
index 2c9731c..056e895 100755
--- a/examples3/application.py
+++ b/examples3/application.py
@@ -179,7 +179,7 @@ class ApplicationWindow(TQMainWindow):
return
for l in f.readlines():
- self.e.append(string.rstrip(l))
+ self.e.append(l.rstrip())
f.close()
diff --git a/examples3/biff.py b/examples3/biff.py
index 9397a0e..abee0cf 100755
--- a/examples3/biff.py
+++ b/examples3/biff.py
@@ -5,7 +5,7 @@ from python_tqt.qt import *
if TQT_VERSION < 0x030100:
- print "This example requires TQt v3.1.0 or later."
+ print("This example requires TQt v3.1.0 or later.")
sys.exit(1)
diff --git a/examples3/buttongroups.py b/examples3/buttongroups.py
index 7f9e079..3d6883e 100755
--- a/examples3/buttongroups.py
+++ b/examples3/buttongroups.py
@@ -21,7 +21,7 @@ FALSE = 0
class ButtonsGroups( TQWidget ):
def __init__( self, *args ):
- apply( TQWidget.__init__, (self,) + args )
+ TQWidget.__init__(*(self,) + args)
# Create Widgets which allow easy layouting
self.vbox = TQVBoxLayout( self, 11, 6 )
diff --git a/examples3/checklists.py b/examples3/checklists.py
index 44bc09f..61734ba 100755
--- a/examples3/checklists.py
+++ b/examples3/checklists.py
@@ -9,27 +9,27 @@ TRUE = 1
FALSE = 0
class CheckLists(TQWidget):
- def __init__(self, *args):
- apply( TQWidget.__init__, (self, ) + args )
+ def __init__(self, *args):
+ TQWidget.__init__(* (self, ) + args )
- lay = TQHBoxLayout(self)
- lay.setMargin(5)
+ lay = TQHBoxLayout(self)
+ lay.setMargin(5)
- vbox1 = TQVBoxLayout(lay)
- vbox1.setMargin(5)
+ vbox1 = TQVBoxLayout(lay)
+ vbox1.setMargin(5)
- # First child: a Label
- vbox1.addWidget(TQLabel("Check some items!", self))
+ # First child: a Label
+ vbox1.addWidget(TQLabel("Check some items!", self))
- # Second child: the ListView
- self.lv1 = TQListView(self)
- vbox1.addWidget(self.lv1)
- self.lv1.addColumn("Items")
- self.lv1.setRootIsDecorated(TRUE)
+ # Second child: the ListView
+ self.lv1 = TQListView(self)
+ vbox1.addWidget(self.lv1)
+ self.lv1.addColumn("Items")
+ self.lv1.setRootIsDecorated(TRUE)
- # create a list with 4 ListViewItems which will be parent items of other ListViewItems
+ # create a list with 4 ListViewItems which will be parent items of other ListViewItems
- parentList = []
+ parentList = []
parentList.append( TQListViewItem( self.lv1, "Parent Item 1" ) )
parentList.append( TQListViewItem( self.lv1, "Parent Item 2" ) )
@@ -91,7 +91,7 @@ class CheckLists(TQWidget):
self.label = TQLabel( "No Item yet...", self )
tmp3.addWidget( self.label )
- def copy1to2(self):
+ def copy1to2(self):
self.lv2.clear()
# Insert first a controller Item into the second ListView. Always if Radio-ListViewItems
diff --git a/examples3/cursor.py b/examples3/cursor.py
index ab87c32..da9db7b 100755
--- a/examples3/cursor.py
+++ b/examples3/cursor.py
@@ -18,33 +18,33 @@ cb_width = 32
cb_height = 32
# cursor bitmap
-cb_bits = "\x00\x00\x00\x00\x00\x00\x00\x00\x00\xf8\x0f\x00" \
- "\x00\x06\x30\x00\x80\x01\xc0\x00\x40\x00\x00\x01" \
- "\x20\x00\x00\x02\x10\x00\x00\x04\x08\x3e\x3e\x08" \
- "\x08\x03\xe0\x08\xc4\x00\x00\x11\x04\x1e\x78\x10" \
- "\x02\x0c\x30\x20\x02\x40\x00\x20\x02\x40\x00\x20" \
- "\x02\x40\x00\x20\x02\x20\x04\x20\x02\x20\x04\x20" \
- "\x02\x10\x08\x20\x02\x08\x08\x20\x02\xf0\x07\x20" \
- "\x04\x00\x00\x10\x04\x00\x00\x10\x08\x00\xc0\x08" \
- "\x08\x3c\x30\x08\x10\xe6\x19\x04\x20\x00\x0f\x02" \
- "\x40\x00\x00\x01\x80\x01\xc0\x00\x00\x06\x30\x00" \
- "\x00\xf8\x0f\x00\x00\x00\x00\x00"
+cb_bits = b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\xf8\x0f\x00" \
+ b"\x00\x06\x30\x00\x80\x01\xc0\x00\x40\x00\x00\x01" \
+ b"\x20\x00\x00\x02\x10\x00\x00\x04\x08\x3e\x3e\x08" \
+ b"\x08\x03\xe0\x08\xc4\x00\x00\x11\x04\x1e\x78\x10" \
+ b"\x02\x0c\x30\x20\x02\x40\x00\x20\x02\x40\x00\x20" \
+ b"\x02\x40\x00\x20\x02\x20\x04\x20\x02\x20\x04\x20" \
+ b"\x02\x10\x08\x20\x02\x08\x08\x20\x02\xf0\x07\x20" \
+ b"\x04\x00\x00\x10\x04\x00\x00\x10\x08\x00\xc0\x08" \
+ b"\x08\x3c\x30\x08\x10\xe6\x19\x04\x20\x00\x0f\x02" \
+ b"\x40\x00\x00\x01\x80\x01\xc0\x00\x00\x06\x30\x00" \
+ b"\x00\xf8\x0f\x00\x00\x00\x00\x00"
cm_width = 32
cm_height = 32
# cursor bitmap mask
-cm_bits = "\x00\x00\x00\x00\x00\xf8\x1f\x00\x00\xfe\x3f\x00" \
- "\x80\x07\xf0\x00\xc0\x01\xc0\x01\x60\x00\x00\x03" \
- "\x30\x00\x00\x06\x18\x00\x00\x0c\x0c\x3e\x3e\x18" \
- "\x0e\x03\xe0\x18\xc6\x00\x00\x31\x07\x1e\x78\x30" \
- "\x03\x0c\x30\x60\x03\x40\x00\x60\x03\x40\x00\x60" \
- "\x03\x40\x00\x60\x03\x20\x04\x60\x03\x20\x04\x60" \
- "\x03\x10\x08\x60\x03\x08\x08\x60\x03\xf0\x07\x60" \
- "\x06\x00\x00\x30\x06\x00\x00\x30\x0c\x00\xc0\x18" \
- "\x0c\x3c\x30\x18\x18\xe6\x19\x0c\x30\x00\x0f\x06" \
- "\x60\x00\x00\x03\xc0\x01\xc0\x01\x80\x07\xf0\x00" \
- "\x00\xfe\x3f\x00\x00\xf8\x0f\x00"
+cm_bits = b"\x00\x00\x00\x00\x00\xf8\x1f\x00\x00\xfe\x3f\x00" \
+ b"\x80\x07\xf0\x00\xc0\x01\xc0\x01\x60\x00\x00\x03" \
+ b"\x30\x00\x00\x06\x18\x00\x00\x0c\x0c\x3e\x3e\x18" \
+ b"\x0e\x03\xe0\x18\xc6\x00\x00\x31\x07\x1e\x78\x30" \
+ b"\x03\x0c\x30\x60\x03\x40\x00\x60\x03\x40\x00\x60" \
+ b"\x03\x40\x00\x60\x03\x20\x04\x60\x03\x20\x04\x60" \
+ b"\x03\x10\x08\x60\x03\x08\x08\x60\x03\xf0\x07\x60" \
+ b"\x06\x00\x00\x30\x06\x00\x00\x30\x0c\x00\xc0\x18" \
+ b"\x0c\x3c\x30\x18\x18\xe6\x19\x0c\x30\x00\x0f\x06" \
+ b"\x60\x00\x00\x03\xc0\x01\xc0\x01\x80\x07\xf0\x00" \
+ b"\x00\xfe\x3f\x00\x00\xf8\x0f\x00"
# The CursorView contains many labels with different cursors.
class CursorView( TQWidget ): # cursor view
diff --git a/examples3/dclock.py b/examples3/dclock.py
index eb4e990..302d454 100755
--- a/examples3/dclock.py
+++ b/examples3/dclock.py
@@ -47,7 +47,7 @@ class DigitalClock(TQLCDNumber):
s[2] = ' '
if s[0] == '0':
s[0] = ' '
- s = string.join(s,'')
+ s = ''.join(s)
self.display(s)
a = TQApplication(sys.argv)
diff --git a/examples3/desktop.py b/examples3/desktop.py
index 7ed96cd..154b632 100755
--- a/examples3/desktop.py
+++ b/examples3/desktop.py
@@ -220,11 +220,11 @@ if len(sys.argv) == 3:
validOptions = 0
if not validOptions:
- print """Usage:
+ print("""Usage:
\tdesktop -poly
\tdesktop -rotate
\tdesktop -troll
\tdesktop -trollwidget
\tdesktop -shadetext <text>
-\tdesktop -shadewidget <text>"""
+\tdesktop -shadewidget <text>""")
rotate()
diff --git a/examples3/fontdisplayer.py b/examples3/fontdisplayer.py
index 7e66572..1f616bf 100755
--- a/examples3/fontdisplayer.py
+++ b/examples3/fontdisplayer.py
@@ -41,15 +41,15 @@ class FontRowTable( TQFrame ):
fm = self.fontMetrics()
ml = self.frameWidth() + self.margin() + 1 + max(0,-fm.minLeftBearing())
mt = self.frameWidth() + self.margin()
- cell = TQSize((self.width()-15-ml)/16,(self.height()-15-mt)/16)
+ cell = TQSize(int((self.width()-15-ml)/16),int((self.height()-15-mt)/16))
if not cell.width() or not cell.height() :
return
- mini = r.left() / cell.width()
- maxi = (r.right()+cell.width()-1) / cell.width()
- minj = r.top() / cell.height()
- maxj = (r.bottom()+cell.height()-1) / cell.height()
+ mini = int(r.left() / cell.width())
+ maxi = int((r.right()+cell.width()-1) / cell.width())
+ minj = int(r.top() / cell.height())
+ maxj = int((r.bottom()+cell.height()-1) / cell.height())
h = fm.height()
@@ -83,13 +83,13 @@ class FontRowTable( TQFrame ):
else: sign = positive
if l > 0: lsign = 0
else: lsign = 1
- p.fillRect(x+lsign, y-h/2, abs(l),-h/2, TQBrush(sign))
+ p.fillRect(x+lsign, int(y-h/2), abs(l),int(-h/2), TQBrush(sign))
if r :
if r < 0: sign = rnegative
else: sign = rpositive
if r > 0: rsign = r
else: rsign = 0
- p.fillRect(x+w-rsign,y+2, abs(r),-h/2, TQBrush(sign))
+ p.fillRect(int(x+w-rsign),y+2, abs(r),int(-h/2), TQBrush(sign))
s = TQString( ch )
p.setPen(TQPen(TQt.black))
p.drawText(x,y,s)
diff --git a/examples3/fonts.py b/examples3/fonts.py
index 68f0b54..145b815 100755
--- a/examples3/fonts.py
+++ b/examples3/fonts.py
@@ -19,10 +19,8 @@ class Viewer( TQWidget ):
self.setFontSubstitutions()
- #greeting_heb = TQString.fromUtf8( "\327\251\327\234\327\225\327\235" )
- greeting_heb = unicode( '\327\251\327\234\327\225\327\235','utf8' )
- #greeting_ru = TQString.fromUtf8( "\320\227\320\264\321\200\320\260\320\262\321\201\321\202\320\262\321\203\320\271\321\202\320\265" )
- greeting_ru = unicode('\320\227\320\264\321\200\320\260\320\262\321\201\321\202\320\262\321\203\320\271\321\202\320\265','utf8' )
+ greeting_heb = TQString.fromUtf8( b"\327\251\327\234\327\225\327\235" )
+ greeting_ru = TQString.fromUtf8( b"\320\227\320\264\321\200\320\260\320\262\321\201\321\202\320\262\321\203\320\271\321\202\320\265" )
greeting_en = "Hello"
self.greetings = TQTextView( self, "textview" )
diff --git a/examples3/gears.py b/examples3/gears.py
index 05f0469..e98df55 100755
--- a/examples3/gears.py
+++ b/examples3/gears.py
@@ -227,7 +227,7 @@ if __name__=='__main__':
app=TQApplication(sys.argv)
if not TQGLFormat.hasOpenGL():
- raise 'No TQt OpenGL support.'
+ raise Exception('No TQt OpenGL support.')
widget=GearWidget()
app.setMainWidget(widget)
diff --git a/examples3/i18n/i18n.py b/examples3/i18n/i18n.py
index 74f3422..b4dc42a 100755
--- a/examples3/i18n/i18n.py
+++ b/examples3/i18n/i18n.py
@@ -80,7 +80,7 @@ def showLang(lang):
translator.load(language,".")
tqApp.installTranslator(translator)
m = MyWidget()
- m.setCaption("PyTQt Example - i18n - " + unicode(m.caption()))
+ m.setCaption("PyTQt Example - i18n - " + str(m.caption()))
wlist.append(m)
return m
diff --git a/examples3/mdi.py b/examples3/mdi.py
index 8f1cf93..ca3d33b 100755
--- a/examples3/mdi.py
+++ b/examples3/mdi.py
@@ -77,12 +77,12 @@ fileprint = [
document = [
"12 16 6 1",
-" c #040404",
-". c None",
-"X c white",
-"o c #808304",
-"O c black",
-"+ c #f3f7f3",
+" c #040404",
+". c None",
+"X c white",
+"o c #808304",
+"O c black",
+"+ c #f3f7f3",
" .....",
" XXXXX ....",
" XXXXX X ...",
@@ -115,8 +115,8 @@ filePrintText = \
'''Click this button to print the file you are editing.<br><br>
You can also select the <b>Print</b> command from the <b>File</b> menu.'''
-True=1
-False=0
+#True=1
+#False=0
class ApplicationWindow(TQMainWindow):
def __init__(self):
@@ -132,7 +132,7 @@ class ApplicationWindow(TQMainWindow):
saveIcon = TQPixmap(filesave)
self.fileSave = TQToolButton(TQIconSet(saveIcon),'Save File',TQString.null,self.save,self.fileTools,'save file')
- printIcon = TQPixmap(fileprint)
+ printIcon = TQPixmap(fileprint)
self.filePrint = TQToolButton(TQIconSet(printIcon),'Print File',TQString.null,self.printDoc,self.fileTools,'print file')
TQWhatsThis.whatsThisButton(self.fileTools)
@@ -168,10 +168,10 @@ class ApplicationWindow(TQMainWindow):
self.menuBar().insertSeparator()
self.windows = TQPopupMenu( self )
- self.windows.setCheckable( True )
- self.connect( self.windows, SIGNAL( "aboutToShow()" ),
- self.windowsMenuAboutToShow )
- self.menuBar().insertItem( "&Windows", self.windows )
+ self.windows.setCheckable( True )
+ self.connect( self.windows, SIGNAL( "aboutToShow()" ),
+ self.windowsMenuAboutToShow )
+ self.menuBar().insertItem( "&Windows", self.windows )
self.help = TQPopupMenu(self)
self.menuBar().insertSeparator()
@@ -180,15 +180,15 @@ class ApplicationWindow(TQMainWindow):
self.help.insertItem('&About',self.about,TQt.Key_F1)
self.help.insertItem('About &TQt',self.aboutTQt)
self.help.insertSeparator()
- self.help.insertItem( "What's &This", self, SLOT("whatsThis()"), TQt.SHIFT+TQt.Key_F1)
+ self.help.insertItem( "What's &This", self, SLOT("whatsThis()"), TQt.SHIFT+TQt.Key_F1)
- self.menuBar().insertSeparator()
+ self.menuBar().insertSeparator()
- self.vb = TQVBox( self )
- self.vb.setFrameStyle( TQFrame.StyledPanel | TQFrame.Sunken )
- self.ws = TQWorkspace( self.vb )
- self.ws.setScrollBarsEnabled( True )
- self.setCentralWidget( self.vb )
+ self.vb = TQVBox( self )
+ self.vb.setFrameStyle( TQFrame.StyledPanel | TQFrame.Sunken )
+ self.ws = TQWorkspace( self.vb )
+ self.ws.setScrollBarsEnabled( True )
+ self.setCentralWidget( self.vb )
self.statusBar().message('Ready',2000)
#self.resize(450,600)
@@ -265,90 +265,90 @@ class ApplicationWindow(TQMainWindow):
class MDIWindow( TQMainWindow):
- def __init__(self,parent, name, wflags ):
- TQMainWindow.__init__(self,parent, name, wflags )
- self.mmovie = 0
- self.medit = TQMultiLineEdit( self )
- self.setFocusProxy( self.medit )
- self.setCentralWidget( self.medit );
-
-
- def load(self, fn ):
- self.filename = fn
- self.f=TQFile( self.filename )
- if not self.f.open( IO_ReadOnly ):
- return
-
- if fn.contains(".gif"):
- tmp=TQWidget(self)
- self.setFocusProxy(tmp)
- self.setCentralWidget(tmp)
- self.medit.hide()
- del self.medit
- qm=TQMovie(fn)
- #ifdef Q_WS_QWS // temporary speed-test hack
- #qm->setDisplayWidget(tmp);
- #endif
- tmp.setBackgroundMode(TQWidget.NoBackground)
- tmp.show()
- self.mmovie=qm
- else :
- self.mmovie = 0
- t=TQTextStream(self.f)
- s = t.read()
- self.medit.setText( s )
- self.f.close()
- self.setCaption( self.filename )
- self.emit(PYSIGNAL( "message"),(TQString("Loaded document %1").arg(self.filename),2000 ))
-
- def save(self):
- if self.filename.isEmpty():
- self.saveAs()
- return
- text = self.medit.text()
- output=open(str(self.filename),'w')
- output.write(str(text))
- #emit message( TQString("Could not write to %1").arg(filename), 2000 );
- #return
- output.close()
- self.setCaption(self.filename)
- self.emit(PYSIGNAL( "message"),(TQString("File %1 saved").arg(self.filename),2000 ))
-
- def saveAs(self):
- fn = TQFileDialog.getSaveFileName( self.filename, TQString.null, self )
- if not fn.isEmpty():
- self.filename = fn
- self.save()
- else :
- self.emit(PYSIGNAL( "message"),(TQString("Saving aborted"),2000 ))
-
- def printDoc(self,printer):
- Margin = 10
- pageNo = 1
-
- if printer.setup(self):
- self.emit(PYSIGNAL( "message"),(TQString("Printing..."),2000 ))
- p = TQPainter()
- p.begin(printer)
- p.setFont(self.medit.font())
- yPos = 0
- fm = p.fontMetrics()
- metrics = TQPaintDeviceMetrics(printer)
-
- for i in range(self.medit.numLines()):
- if Margin + yPos > metrics.height() - Margin:
- pageNo = pageNo + 1
- self.emit(PYSIGNAL( "message"),(TQString("Printing (page %1) ...").arg(pageNo),2000 ))
- printer.newPage()
- yPos = 0
-
- p.drawText(Margin,Margin + yPos,metrics.width(),fm.lineSpacing(),TQt.ExpandTabs | TQt.DontClip,self.medit.textLine(i))
- yPos = yPos + fm.lineSpacing()
-
- p.end()
- self.emit(PYSIGNAL( "message"),(TQString("Printing completed"),2000 ))
- else:
- self.emit(PYSIGNAL( "message"),(TQString("Printing aborted"),2000 ))
+ def __init__(self,parent, name, wflags ):
+ TQMainWindow.__init__(self,parent, name, wflags )
+ self.mmovie = 0
+ self.medit = TQMultiLineEdit( self )
+ self.setFocusProxy( self.medit )
+ self.setCentralWidget( self.medit );
+
+
+ def load(self, fn ):
+ self.filename = fn
+ self.f=TQFile( self.filename )
+ if not self.f.open( IO_ReadOnly ):
+ return
+
+ if fn.contains(".gif"):
+ tmp=TQWidget(self)
+ self.setFocusProxy(tmp)
+ self.setCentralWidget(tmp)
+ self.medit.hide()
+ del self.medit
+ qm=TQMovie(fn)
+ #ifdef Q_WS_QWS // temporary speed-test hack
+ #qm->setDisplayWidget(tmp);
+ #endif
+ tmp.setBackgroundMode(TQWidget.NoBackground)
+ tmp.show()
+ self.mmovie=qm
+ else :
+ self.mmovie = 0
+ t=TQTextStream(self.f)
+ s = t.read()
+ self.medit.setText( s )
+ self.f.close()
+ self.setCaption( self.filename )
+ self.emit(PYSIGNAL( "message"),(TQString("Loaded document %1").arg(self.filename),2000 ))
+
+ def save(self):
+ if self.filename.isEmpty():
+ self.saveAs()
+ return
+ text = self.medit.text()
+ output=open(str(self.filename),'w')
+ output.write(str(text))
+ #emit message( TQString("Could not write to %1").arg(filename), 2000 );
+ #return
+ output.close()
+ self.setCaption(self.filename)
+ self.emit(PYSIGNAL( "message"),(TQString("File %1 saved").arg(self.filename),2000 ))
+
+ def saveAs(self):
+ fn = TQFileDialog.getSaveFileName( self.filename, TQString.null, self )
+ if not fn.isEmpty():
+ self.filename = fn
+ self.save()
+ else :
+ self.emit(PYSIGNAL( "message"),(TQString("Saving aborted"),2000 ))
+
+ def printDoc(self,printer):
+ Margin = 10
+ pageNo = 1
+
+ if printer.setup(self):
+ self.emit(PYSIGNAL( "message"),(TQString("Printing..."),2000 ))
+ p = TQPainter()
+ p.begin(printer)
+ p.setFont(self.medit.font())
+ yPos = 0
+ fm = p.fontMetrics()
+ metrics = TQPaintDeviceMetrics(printer)
+
+ for i in range(self.medit.numLines()):
+ if Margin + yPos > metrics.height() - Margin:
+ pageNo = pageNo + 1
+ self.emit(PYSIGNAL( "message"),(TQString("Printing (page %1) ...").arg(pageNo),2000 ))
+ printer.newPage()
+ yPos = 0
+
+ p.drawText(Margin,Margin + yPos,metrics.width(),fm.lineSpacing(),TQt.ExpandTabs | TQt.DontClip,self.medit.textLine(i))
+ yPos = yPos + fm.lineSpacing()
+
+ p.end()
+ self.emit(PYSIGNAL( "message"),(TQString("Printing completed"),2000 ))
+ else:
+ self.emit(PYSIGNAL( "message"),(TQString("Printing aborted"),2000 ))
if __name__=='__main__':
diff --git a/examples3/progress.py b/examples3/progress.py
index eb5a832..3ebdd12 100755
--- a/examples3/progress.py
+++ b/examples3/progress.py
@@ -87,7 +87,7 @@ class AnimatedThingy(TQLabel):
def _drawqix(self, p, pn, step):
# rainbow effect
- pn.setColor(TQColor((step * 255)/self.nqix, 255, 255, TQColor.Hsv))
+ pn.setColor(TQColor(int((step * 255)/self.nqix), 255, 255, TQColor.Hsv))
p.setPen(pn)
p.drawLine(self.ox[step][0], self.oy[step][0],
self.ox[step][1], self.oy[step][1])
diff --git a/examples3/qdir.py b/examples3/qdir.py
index 62d452e..358c796 100755
--- a/examples3/qdir.py
+++ b/examples3/qdir.py
@@ -2,6 +2,7 @@
#
# 2005-02-12 initial version hp
+from __future__ import print_function
import os
import pickle
from python_tqt.qt import *
@@ -97,7 +98,7 @@ class Preview(TQWidgetStack):
err = False
try:
text = open(path.latin1(), "r").read()
- except IOError, msg:
+ except IOError as msg:
text = TQString(str(msg))
err = True
if not err and fi.extension().lower().contains("htm"):
@@ -159,8 +160,8 @@ class CustomFileDialog(TQFileDialog):
if os.path.exists(self.bookmarkFile):
try:
self.bookmarkList = pickle.loads(open(self.bookmarkFile, "rb").read())
- except IOError, msg:
- print msg
+ except IOError as msg:
+ print(msg)
self.setDir("/")
self.dirView = DirectoryView(self, None, True)
self.dirView.addColumn("")
@@ -209,8 +210,8 @@ class CustomFileDialog(TQFileDialog):
if self.bookmarkList:
try:
open(self.bookmarkFile, "wb").write(pickle.dumps(self.bookmarkList))
- except IOError, msg:
- print msg
+ except IOError as msg:
+ print(msg)
return TQFileDialog.done(self, r)
def showEvent(self, e):
@@ -245,8 +246,8 @@ if __name__ == '__main__':
def usage(msg = None):
if msg:
- print >> sys.stderr, msg
- print >> sys.stderr, """\
+ print(msg, file=sys.stderr)
+ print("""\
usage: qdir [--any | --dir | --custom] [--preview] [--default f] {--filter f} [caption ...]
--any Get any filename, need not exist.
--dir Return a directory rather than a file.
@@ -256,7 +257,7 @@ usage: qdir [--any | --dir | --custom] [--preview] [--default f] {--filter f} [c
--default f Start from directory/file f.
--filter f eg. '*.gif' '*.bmp'
caption ... Caption for dialog.
-"""
+""", file=sys.stderr)
sys.exit(1)
def main():
@@ -270,7 +271,7 @@ usage: qdir [--any | --dir | --custom] [--preview] [--default f] {--filter f} [c
try:
optlist, args = getopt.getopt(sys.argv[1:], "h", options)
- except getopt.error, msg:
+ except getopt.error as msg:
usage(msg)
for opt, par in optlist:
@@ -311,7 +312,7 @@ usage: qdir [--any | --dir | --custom] [--preview] [--default f] {--filter f} [c
fd.setCaption(caption)
fd.setSelection(start)
if fd.exec_loop() == TQDialog.Accepted:
- print "%s\n" % fd.selectedFile().latin1()
+ print("%s\n" % fd.selectedFile().latin1())
return 0
else:
return 1
diff --git a/examples3/rangecontrols.py b/examples3/rangecontrols.py
index a56eff3..14588c8 100755
--- a/examples3/rangecontrols.py
+++ b/examples3/rangecontrols.py
@@ -13,7 +13,7 @@
import sys
from python_tqt.qt import *
-INT_MAX = sys.maxint
+INT_MAX = sys.maxsize
class RangeControls( TQVBox ):
def __init__( self, parent=None, name=None ):
diff --git a/examples3/richtext.py b/examples3/richtext.py
index 78c0db7..2e6abac 100755
--- a/examples3/richtext.py
+++ b/examples3/richtext.py
@@ -99,7 +99,7 @@ class MyRichText( TQVBox ):
self.connect( self.bClose, SIGNAL("clicked()"), tqApp, SLOT("quit()") )
self.connect( self.bPrev, SIGNAL("clicked()"), self.prev )
- self.connect( self.bNext, SIGNAL("clicked()"), self.next )
+ self.connect( self.bNext, SIGNAL("clicked()"), self.__next__ )
self.num = 0
@@ -112,7 +112,7 @@ class MyRichText( TQVBox ):
self.bPrev.setEnabled( False )
self.bNext.setEnabled( True )
- def next( self ):
+ def __next__( self ):
self.num += 1
if not sayings[self.num]:
return
diff --git a/examples3/semaphore.py b/examples3/semaphore.py
index 46cdace..79affb2 100755
--- a/examples3/semaphore.py
+++ b/examples3/semaphore.py
@@ -9,7 +9,7 @@ import sys
try:
from python_tqt.qt import TQThread
except:
- print "Thread support not enabled"
+ print("Thread support not enabled")
sys.exit(1)
from python_tqt.qt import *
@@ -192,7 +192,7 @@ class SemaphoreExample(TQWidget):
del s
else:
- print "Unknown custom event type:", event.type()
+ print("Unknown custom event type:", event.type())
app = TQApplication(sys.argv)
diff --git a/examples3/splitter.py b/examples3/splitter.py
index 709e960..a220d08 100755
--- a/examples3/splitter.py
+++ b/examples3/splitter.py
@@ -16,13 +16,13 @@ class Test(TQWidget):
y1 = 0
y2 = self.height() - 1
- x = (x1+x2)/2
+ x = int((x1+x2)/2)
p.drawLine(x, y1, x+d, y1+d)
p.drawLine(x, y1, x-d, y1+d)
p.drawLine(x, y2, x+d, y2-d)
p.drawLine(x, y2, x-d, y2-d)
- y = (y1+y2)/2
+ y = int((y1+y2)/2)
p.drawLine(x1, y, x1+d, y+d)
p.drawLine(x1, y, x1+d, y-d)
p.drawLine(x2, y, x2-d, y+d)
diff --git a/examples3/tablestatistics.py b/examples3/tablestatistics.py
index e0835bb..d6b6b2e 100755
--- a/examples3/tablestatistics.py
+++ b/examples3/tablestatistics.py
@@ -53,6 +53,8 @@ class Table(TQTable):
# read all the TQt source and header files into a list
all = []
qtdir = os.getenv("TQTDIR")
+ if qtdir is None:
+ raise Exception("The TQTDIR environment variable has not been set.")
for i in dirs:
dir = TQDir(os.path.join(qtdir, "src", i))
lst = TQStringList(dir.entryList("*.cpp; *.h"))
@@ -65,7 +67,7 @@ class Table(TQTable):
self.setNumRows(len(all) + 1)
i = 0
- sum = 0L
+ sum = 0
# insert the data into the table
for it in all:
self.setText(i, TB_FILE, it)
@@ -82,11 +84,11 @@ class Table(TQTable):
if col < TB_SIZE or col > TB_FLAG:
return
- sum = 0L
+ sum = 0
for i in range(self.numRows()-1):
if str(self.text(i, TB_FLAG)) == "No":
continue
- sum += long(str(self.text(i, TB_SIZE)))
+ sum += int(str(self.text(i, TB_SIZE)))
self.displaySum(sum)
def displaySum(self, sum):
@@ -108,7 +110,7 @@ class Table(TQTable):
class TableItem(TQTableItem):
def __init__(self, *args):
- apply(TQTableItem.__init__, (self,) + args)
+ TQTableItem.__init__(*(self,) + args)
def paint(self, p, cg, cr, selected):
g = TQColorGroup(cg)
diff --git a/examples3/tooltip.py b/examples3/tooltip.py
index 03bcd4f..13025e3 100755
--- a/examples3/tooltip.py
+++ b/examples3/tooltip.py
@@ -76,7 +76,7 @@ class TellMe( TQWidget ):
self.r2 = self.randomRect()
def randomRect( self ):
- return TQRect( random() * (self.width() - 20), random() * (self.height() - 20), 20, 20 )
+ return TQRect( int(random() * (self.width() - 20)), int(random() * (self.height() - 20)), 20, 20 )
def tip( self, p ):
diff --git a/examples3/tut10.py b/examples3/tut10.py
index 310f000..b16804e 100755
--- a/examples3/tut10.py
+++ b/examples3/tut10.py
@@ -27,7 +27,7 @@ class LCDRange(qt.TQVBox):
def setRange(self, minVal, maxVal):
if minVal < 0 or maxVal > 99 or minVal > maxVal:
- raise ValueError, "LCDRange.setRange(): invalid range"
+ raise ValueError("LCDRange.setRange(): invalid range")
self.slider.setRange(minVal, maxVal)
diff --git a/examples3/tut11.py b/examples3/tut11.py
index ca070fd..cb6444b 100755
--- a/examples3/tut11.py
+++ b/examples3/tut11.py
@@ -28,7 +28,7 @@ class LCDRange(qt.TQVBox):
def setRange(self, minVal, maxVal):
if minVal < 0 or maxVal > 99 or minVal > maxVal:
- raise ValueError, "LCDRange.setRange(): invalid range"
+ raise ValueError("LCDRange.setRange(): invalid range")
self.slider.setRange(minVal, maxVal)
@@ -149,7 +149,7 @@ class CannonField(qt.TQWidget):
y = y0 + vely * time - 0.5 * gravity * time * time
r = qt.TQRect(0, 0, 6, 6)
- r.moveCenter(qt.TQPoint(x, self.height() - 1 - y))
+ r.moveCenter(qt.TQPoint(int(x), int(self.height() - 1 - y)))
return r
def sizePolicy(self):
diff --git a/examples3/tut12.py b/examples3/tut12.py
index 7b13271..452d1ac 100755
--- a/examples3/tut12.py
+++ b/examples3/tut12.py
@@ -36,7 +36,7 @@ class LCDRange(qt.TQVBox):
def setRange(self, minVal, maxVal):
if minVal < 0 or maxVal > 99 or minVal > maxVal:
- raise ValueError, "LCDRange.setRange(): invalid range"
+ raise ValueError("LCDRange.setRange(): invalid range")
self.slider.setRange(minVal, maxVal)
@@ -184,7 +184,7 @@ class CannonField(qt.TQWidget):
y = y0 + vely * time - 0.5 * gravity * time * time
r = qt.TQRect(0, 0, 6, 6)
- r.moveCenter(qt.TQPoint(x, self.height() - 1 - y))
+ r.moveCenter(qt.TQPoint(int(x), int(self.height() - 1 - y)))
return r
def targetRect(self):
diff --git a/examples3/tut13.py b/examples3/tut13.py
index daa5a9d..c43d67b 100755
--- a/examples3/tut13.py
+++ b/examples3/tut13.py
@@ -41,7 +41,7 @@ class LCDRange(qt.TQWidget):
def setRange(self, minVal, maxVal):
if minVal < 0 or maxVal > 99 or minVal > maxVal:
- raise ValueError, "LCDRange.setRange(): invalid range"
+ raise ValueError("LCDRange.setRange(): invalid range")
self.slider.setRange(minVal, maxVal)
@@ -216,7 +216,7 @@ class CannonField(qt.TQWidget):
y = y0 + vely * time - 0.5 * gravity * time * time
r = qt.TQRect(0, 0, 6, 6)
- r.moveCenter(qt.TQPoint(x, self.height() - 1 - y))
+ r.moveCenter(qt.TQPoint(int(x), int(self.height() - 1 - y)))
return r
def targetRect(self):
diff --git a/examples3/tut14.py b/examples3/tut14.py
index 9f89a9b..8f7404c 100755
--- a/examples3/tut14.py
+++ b/examples3/tut14.py
@@ -41,7 +41,7 @@ class LCDRange(qt.TQWidget):
def setRange(self, minVal, maxVal):
if minVal < 0 or maxVal > 99 or minVal > maxVal:
- raise ValueError, "LCDRange.setRange(): invalid range"
+ raise ValueError("LCDRange.setRange(): invalid range")
self.slider.setRange(minVal, maxVal)
@@ -246,7 +246,7 @@ class CannonField(qt.TQWidget):
y = y0 + vely * time - 0.5 * gravity * time * time
r = qt.TQRect(0, 0, 6, 6)
- r.moveCenter(qt.TQPoint(x, self.height() - 1 - y))
+ r.moveCenter(qt.TQPoint(int(x), int(self.height() - 1 - y)))
return r
def targetRect(self):
diff --git a/examples3/tut8.py b/examples3/tut8.py
index b884093..2e81a94 100755
--- a/examples3/tut8.py
+++ b/examples3/tut8.py
@@ -27,7 +27,7 @@ class LCDRange(qt.TQVBox):
def setRange(self, minVal, maxVal):
if minVal < 0 or maxVal > 99 or minVal > maxVal:
- raise ValueError, "LCDRange.setRange(): invalid range"
+ raise ValueError("LCDRange.setRange(): invalid range")
self.slider.setRange(minVal, maxVal)
diff --git a/examples3/tut9.py b/examples3/tut9.py
index 024f921..3eafed7 100755
--- a/examples3/tut9.py
+++ b/examples3/tut9.py
@@ -27,7 +27,7 @@ class LCDRange(qt.TQVBox):
def setRange(self, minVal, maxVal):
if minVal < 0 or maxVal > 99 or minVal > maxVal:
- raise ValueError, "LCDRange.setRange(): invalid range"
+ raise ValueError("LCDRange.setRange(): invalid range")
self.slider.setRange(minVal, maxVal)
diff --git a/examples3/webbrowser/mainwindow.py b/examples3/webbrowser/mainwindow.py
index 31b11f1..14929de 100644
--- a/examples3/webbrowser/mainwindow.py
+++ b/examples3/webbrowser/mainwindow.py
@@ -1064,34 +1064,34 @@ class MainWindow(TQMainWindow):
def go(self):
- print "MainWindow.go(): Not implemented yet"
+ print("MainWindow.go(): Not implemented yet")
def newWindow(self):
- print "MainWindow.newWindow(): Not implemented yet"
+ print("MainWindow.newWindow(): Not implemented yet")
def setProgress(self,a0,a1):
- print "MainWindow.setProgress(int,int): Not implemented yet"
+ print("MainWindow.setProgress(int,int): Not implemented yet")
def init(self):
pass
def setTitle(self,a0):
- print "MainWindow.setTitle(const TQString&): Not implemented yet"
+ print("MainWindow.setTitle(const TQString&): Not implemented yet")
def setCommandState(self,a0,a1):
- print "MainWindow.setCommandState(int,bool): Not implemented yet"
+ print("MainWindow.setCommandState(int,bool): Not implemented yet")
def navigateComplete(self):
- print "MainWindow.navigateComplete(): Not implemented yet"
+ print("MainWindow.navigateComplete(): Not implemented yet")
def navigateBegin(self):
- print "MainWindow.navigateBegin(): Not implemented yet"
+ print("MainWindow.navigateBegin(): Not implemented yet")
def aboutSlot(self):
- print "MainWindow.aboutSlot(): Not implemented yet"
+ print("MainWindow.aboutSlot(): Not implemented yet")
def aboutTQtSlot(self):
- print "MainWindow.aboutTQtSlot(): Not implemented yet"
+ print("MainWindow.aboutTQtSlot(): Not implemented yet")
def __tr(self,s,c = None):
return tqApp.translate("MainWindow",s,c)
diff --git a/examples3/widgets.py b/examples3/widgets.py
index 0d3ce3a..fe36049 100755
--- a/examples3/widgets.py
+++ b/examples3/widgets.py
@@ -18,7 +18,7 @@ def TQMIN( x, y ):
class AnalogClock( TQWidget ):
def __init__( self, *args ):
- apply( TQWidget.__init__, (self,) + args )
+ TQWidget.__init__(*(self,) + args)
self.time = TQTime.currentTime() # get current time
internalTimer = TQTimer( self ) # create internal timer
self.connect( internalTimer, SIGNAL("timeout()"), self.timeout )
@@ -74,7 +74,7 @@ class AnalogClock( TQWidget ):
class DigitalClock( TQLCDNumber ):
def __init__( self, *args ):
- apply( TQLCDNumber.__init__,(self,) + args )
+ TQLCDNumber.__init__(*(self,) + args)
self.showingColon = 0
self.setFrameStyle(TQFrame.Panel | TQFrame.Raised)
self.setLineWidth( 2 )
@@ -112,7 +112,7 @@ class DigitalClock( TQLCDNumber ):
s[2] = ' '
if s[0] == '0':
s[0] = ' '
- s = string.join(s,'')
+ s = ''.join(s)
self.display( s )
def TQMIN( x, y ):
@@ -130,7 +130,7 @@ MOVIEFILENAME = "trolltech.gif"
class WidgetView ( TQWidget ):
def __init__( self, *args ):
- apply( TQWidget.__init__, (self,) + args )
+ TQWidget.__init__(*(self,) + args)
# Set the window caption/title
self.setCaption( "TQt Widgets Demo Application" )
@@ -223,7 +223,7 @@ class WidgetView ( TQWidget ):
self.vbox.addSpacing( self.bg.fontMetrics().height() )
- self.cb = range(3)
+ self.cb = list(range(3))
self.cb[0] = TQCheckBox( self.bg )
self.cb[0].setText( "Read" )
self.vbox.addWidget( self.cb[0] )
@@ -464,10 +464,10 @@ class WidgetView ( TQWidget ):
TQApplication.setPalette( p, TRUE )
def lineEditTextChanged( self, newText ):
- self.msg.setText("Line edit text: " + unicode(newText))
+ self.msg.setText("Line edit text: " + str(newText))
def spinBoxValueChanged( self, valueText ):
- self.msg.setText("Spin box value: " + unicode(valueText))
+ self.msg.setText("Spin box value: " + str(valueText))
# All application events are passed throught this event filter.
# We're using it to display some information about a clicked
diff --git a/module-init.py b/module-init.py
index 929a166..bc5f31b 100644
--- a/module-init.py
+++ b/module-init.py
@@ -17,8 +17,8 @@ __all__ = [
'qt',
'qtcanvas',
'qtnetwork',
- 'qtsql',
'qttable',
+ 'qtsql',
'qtui',
'qtxml',
]
diff --git a/sip/qt/qapplication.sip b/sip/qt/qapplication.sip
index 367ac2c..dcf333d 100644
--- a/sip/qt/qapplication.sip
+++ b/sip/qt/qapplication.sip
@@ -64,6 +64,9 @@ This has been renamed to <Literal>exec_loop</Literal> in Python.
</Sect2>
%End
+%ModuleHeaderCode
+#include <tqapplication.h>
+%End
TQApplication *tqApp;
@@ -128,7 +131,6 @@ public:
}
%End
-%If (TQt_2_2_0 -)
enum Type {
Tty,
GuiClient,
@@ -160,7 +162,6 @@ public:
updatePyArgv(a0,argc,argv);
}
%End
-%End
~TQApplication();
%MethodCode
@@ -209,7 +210,7 @@ public:
sipIsErr = 1;
else
for (int a = 0; a < argc; ++a)
- if (PyList_SetItem(sipRes,a,PyString_FromString(sipCpp -> argv()[a])) < 0)
+ if (PyList_SetItem(sipRes,a,SIPBytes_FromString(sipCpp -> argv()[a])) < 0)
{
Py_DECREF(sipRes);
sipIsErr = 1;
@@ -217,39 +218,17 @@ public:
}
%End
-%If (TQt_2_3_0 -)
Type type() const;
-%End
-%If (- TQt_2_00)
- static GUIStyle style();
- static void setStyle(GUIStyle);
-%End
-%If (TQt_2_00 -)
static TQStyle &style();
static void setStyle(TQStyle * /Transfer/);
-%End
-%If (TQt_3_0_0 -)
static TQStyle *setStyle(const TQString &);
-%End
-%If (- TQt_2_00)
- enum ColorSpec
- {
- NormalColor = 0,
- CustomColor = 1,
- PrivateColor = 4,
- ManyColor = 4,
- TrueColor = 4
- };
-%End
-%If (TQt_2_00 -)
enum ColorSpec
{
NormalColor = 0,
CustomColor = 1,
ManyColor = 2
};
-%End
static int colorSpec();
static void setColorSpec(int);
@@ -258,51 +237,26 @@ public:
static void restoreOverrideCursor();
static bool hasGlobalMouseTracking();
static void setGlobalMouseTracking(bool);
-%If (- TQt_2_00)
- static TQPalette *palette();
- static void setPalette(TQPalette &,bool = 0);
- static TQFont *font();
- static void setFont(const TQFont &,bool = 0);
-%End
-%If (TQt_2_00 -)
static TQPalette palette(const TQWidget * = 0);
static void setPalette(TQPalette &,bool = 0,const char * = 0);
static TQFont font(const TQWidget * = 0);
static void setFont(const TQFont &,bool = 0,const char * = 0);
-%End
static TQFontMetrics fontMetrics();
TQWidget *mainWidget() const;
-%If (- TQt_2_00)
- // We may not need the /Transfer/ now that the TQApplication dtor is
- // instrumented, but we'll leave it in so as not to break old programs
- // needlessly.
- void setMainWidget(TQWidget * /Transfer/);
-%End
-%If (TQt_2_00 -)
virtual void setMainWidget(TQWidget *);
virtual void polish(TQWidget *);
-%End
static TQWidgetList *allWidgets();
static TQWidgetList *topLevelWidgets();
-%If (- TQt_3_0_0)
- static TQWidget *desktop();
-%End
-%If (TQt_3_0_0 -)
static TQDesktopWidget *desktop();
-%End
static TQWidget *activePopupWidget();
static TQWidget *activeModalWidget();
static TQClipboard *clipboard();
TQWidget *focusWidget() const;
-%If (TQt_2_00 -)
TQWidget *activeWindow() const;
-%End
static TQWidget *widgetAt(int,int,bool = 0);
static TQWidget *widgetAt(const TQPoint &,bool = 0);
-%If (TQt_3_1_0 -)
static TQEventLoop *eventLoop();
-%End
int exec() /PyName=exec_loop, ReleaseGIL,
PreHook=__pyTQtPreEventLoopHook__,
@@ -310,44 +264,27 @@ public:
void processEvents() /ReleaseGIL/;
void processEvents(int) /ReleaseGIL/;
void processOneEvent() /ReleaseGIL/;
-%If (TQt_3_0_0 -)
bool hasPendingEvents();
-%End
int enter_loop() /ReleaseGIL/;
void exit_loop();
-%If (TQt_2_00 -)
int loopLevel() const;
-%End
static void exit(int = 0);
static bool sendEvent(TQObject *,TQEvent *) /ReleaseGIL/;
static void postEvent(TQObject *,TQEvent * /Transfer/) /ReleaseGIL/;
static void sendPostedEvents(TQObject *,int) /ReleaseGIL/;
-%If (TQt_2_00 -)
static void sendPostedEvents() /ReleaseGIL/;
static void removePostedEvents(TQObject *);
-%End
virtual bool notify(TQObject *,TQEvent *) /ReleaseGIL/;
static bool startingUp();
static bool closingDown();
static void flushX();
-%If (TQt_3_0_0 -)
static void flush();
-%End
static void syncX();
static void beep();
-%If (TQt_2_00 -)
void setDefaultCodec(TQTextCodec *);
TQTextCodec *defaultCodec() const;
void installTranslator(TQTranslator *);
void removeTranslator(TQTranslator *);
-%End
-%If (TQt_2_00 - TQt_3_0_0)
- TQString translate(const char *,const char *) const;
-%End
-%If (TQt_2_2_0 - TQt_3_0_0)
- TQString translate(const char *,const char *,const char *) const;
-%End
-%If (TQt_3_0_0 -)
enum Encoding {
DefaultCodec,
UnicodeUTF8
@@ -355,98 +292,59 @@ public:
TQString translate(const char *,const char *,const char * = 0,
Encoding = DefaultCodec) const;
-%End
-%If (TQt_3_2_0 -)
TQString applicationDirPath();
TQString applicationFilePath();
-%End
-%If (- TQt_3_0_0)
- static void setWinStyleHighlightColor(const TQColor &);
- static const TQColor &winStyleHighlightColor();
-%End
-%If (TQt_2_00 -)
static void setDesktopSettingsAware(bool);
static bool desktopSettingsAware();
static void setCursorFlashTime(int);
static int cursorFlashTime();
-%End
static void setDoubleClickInterval(int);
static int doubleClickInterval();
-%If (TQt_2_1_0 -)
static void setWheelScrollLines(int);
static int wheelScrollLines();
-%If (TQt_2_2_0 -)
static void setGlobalStrut(const TQSize &);
static TQSize globalStrut();
-%End
-%If (TQt_3_0_0 -)
static void setLibraryPaths(const TQStringList &);
static TQStringList libraryPaths();
static void addLibraryPath(const TQString &);
static void removeLibraryPath(const TQString &);
-%End
static void setStartDragTime(int);
static int startDragTime();
static void setStartDragDistance(int);
static int startDragDistance();
-%If (TQt_3_0_0 -)
static void setReverseLayout(bool);
static bool reverseLayout();
static int horizontalAlignment(int);
-%End
-%If (TQt_2_2_0 -)
static bool isEffectEnabled(TQt::UIEffect);
static void setEffectEnabled(TQt::UIEffect,bool = 1);
-%End
-%End
-%If (TQt_2_00 -)
bool isSessionRestored() const;
TQString sessionId() const;
-%If (TQt_3_1_0 -)
TQString sessionKey() const;
-%End
virtual void commitData(TQSessionManager &);
virtual void saveState(TQSessionManager &);
-%End
-%If (TQt_2_1_0 -)
void wakeUpGuiThread();
-%End
%If (TQt_THREAD_SUPPORT)
-%If (TQt_2_2_0 -)
void lock() /ReleaseGIL/;
void unlock(bool = 1);
bool locked();
-%End
-%If (TQt_3_0_0 -)
bool tryLock();
%End
-%End
signals:
void lastWindowClosed();
-%If (TQt_2_00 -)
void aboutToQuit();
-%End
-%If (TQt_2_1_0 -)
void guiThreadAwake();
-%End
public slots:
void quit();
-%If (TQt_2_00 -)
void closeAllWindows();
-%End
-%If (TQt_3_2_0 -)
void aboutTQt();
-%End
protected:
-%If (TQt_3_1_0 -)
bool event(TQEvent *);
-%End
private:
TQApplication(const TQApplication &);
@@ -471,19 +369,26 @@ static char **pyArgvToC(PyObject *argvlist,int &argc)
// Convert the list.
for (int a = 0; a < argc; ++a)
{
+ PyObject *argObject = PyList_GET_ITEM(argvlist, a);
char *arg;
- // Get the argument and allocate memory for it.
- if ((arg = PyString_AsString(PyList_GetItem(argvlist,a))) == NULL ||
- (argv[a] = (char *)sipMalloc(strlen(arg) + 1)) == NULL)
+ if (PyUnicode_Check(argObject))
+ {
+ arg = tqstrdup(sipString_AsLatin1String(&argObject));
+ }
+ else if (SIPBytes_Check(argObject))
+ {
+ arg = tqstrdup(SIPBytes_AS_STRING(argObject));
+ }
+ else
+ {
return NULL;
+ }
- // Copy the argument and save a pointer to it.
- strcpy(argv[a],arg);
- argv[a + argc + 1] = argv[a];
+ argv[a] = argv[a + argc + 1] = arg;
}
- argv[argc + argc + 1] = argv[argc] = NULL;
+ argv[argc] = argv[argc + argc + 1] = NULL;
return argv;
}
@@ -544,19 +449,7 @@ static void pyqtMsgHandler(TQtMsgType type, const char *msg)
SIP_BLOCK_THREADS
-#if SIP_VERSION >= 0x040200
res = sipCallMethod(0, pyqtPyMsgHandler, "Es", type, sipEnum_TQtMsgType, msg);
-#elif SIP_VERSION >= 0x040000
- res = sipCallMethod(0, pyqtPyMsgHandler, "es", type, msg);
-#else
- PyObject *args = Py_BuildValue("is", type, msg);
-
- if (args != NULL)
- {
- res = PyEval_CallObject(pyqtPyMsgHandler, args);
- Py_DECREF(args);
- }
-#endif
Py_XDECREF(res);
diff --git a/sip/qt/qarray.sip b/sip/qt/qarray.sip
index a7c34b8..6ce411e 100644
--- a/sip/qt/qarray.sip
+++ b/sip/qt/qarray.sip
@@ -52,7 +52,7 @@ converted to and from Python lists of the type.
// Get it.
for (uint i = 0; i < sipCpp -> count(); ++i)
- if (PyList_SetItem(l,i,PyInt_FromLong((long)(sipCpp -> at(i)))) < 0)
+ if (PyList_SetItem(l,i,PyLong_FromLong((long)(sipCpp -> at(i)))) < 0)
{
Py_DECREF(l);
@@ -74,7 +74,7 @@ converted to and from Python lists of the type.
for (int i = 0; i < PyList_GET_SIZE(sipPy); ++i)
{
- qa[i] = (int)PyInt_AsLong(PyList_GET_ITEM(sipPy,i));
+ qa[i] = PyLong_AsLong(PyList_GET_ITEM(sipPy,i));
if (PyErr_Occurred() != NULL)
{
diff --git a/sip/qt/qbuttongroup.sip b/sip/qt/qbuttongroup.sip
index 72d4009..e593e28 100644
--- a/sip/qt/qbuttongroup.sip
+++ b/sip/qt/qbuttongroup.sip
@@ -19,6 +19,7 @@
// PyTQt; see the file LICENSE. If not, write to the Free Software Foundation,
// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+%DefaultEncoding "UTF-8"
%ExportedDoc
<Sect2><Title>TQButtonGroup</Title>
diff --git a/sip/qt/qbytearray.sip b/sip/qt/qbytearray.sip
index db5d266..d975472 100644
--- a/sip/qt/qbytearray.sip
+++ b/sip/qt/qbytearray.sip
@@ -98,6 +98,36 @@ class TQByteArray
#include <tqstring.h>
%End
+%TypeCode
+// Convert a TQByteArray to a Python string or Py_None if there's
+// no data
+static PyObject* TQByteArray_To_String(TQByteArray *ba)
+{
+ // TQByteArrays aren't '\0' terminated so set the size
+ // explicitly.
+ char *data;
+ uint len;
+
+ Py_BEGIN_ALLOW_THREADS
+ data = ba->data();
+ len = ba->size();
+ Py_END_ALLOW_THREADS
+
+ if (data)
+ {
+#if PY_MAJOR_VERSION >= 3
+ return PyUnicode_FromStringAndSize(data, len);
+#else
+ return SIPBytes_FromStringAndSize(data, len);
+#endif
+ }
+ else
+ {
+ return Py_None;
+ }
+}
+%End
+
public:
TQByteArray();
TQByteArray(int);
@@ -105,27 +135,20 @@ public:
SIP_PYOBJECT data() const;
%MethodCode
- // TQByteArrays aren't '\0' terminated so set the size
- // explicitly.
-
- char *res;
- uint len;
-
- Py_BEGIN_ALLOW_THREADS
- res = sipCpp -> data();
- len = sipCpp -> size();
- Py_END_ALLOW_THREADS
+ PyObject* res = TQByteArray_To_String(sipCpp);
- if (res)
+ if (res == Py_None)
{
- if ((sipRes = PyString_FromStringAndSize(res,len)) == NULL)
- sipIsErr = 1;
+ Py_INCREF(Py_None);
}
- else
+ else if (res == NULL)
{
- Py_INCREF(Py_None);
- sipRes = Py_None;
+ sipIsErr = 1;
}
+ else
+ {
+ sipRes = res;
+ }
%End
// These are actually in TQMemArray, which isn't implemented so pretend
@@ -151,36 +174,62 @@ public:
SIP_PYOBJECT __str__();
%MethodCode
- // TQByteArrays aren't '\0' terminated so set the size
- // explicitly.
+ PyObject* res = TQByteArray_To_String(sipCpp);
- char *data;
- uint len;
-
- Py_BEGIN_ALLOW_THREADS
- data = sipCpp -> data();
- len = sipCpp -> size();
- Py_END_ALLOW_THREADS
-
- if (data == NULL)
- sipRes = PyString_FromString("");
+ if (res == Py_None)
+ {
+ sipRes = SIPBytes_FromString("");
+ }
else
- sipRes = PyString_FromStringAndSize(data,len);
+ {
+ sipRes = res;
+ }
%End
+
%ConvertToTypeCode
// Allow a Python string whenever a TQByteArray is expected.
if (sipIsErr == NULL)
- return (PyString_Check(sipPy) ||
+ return (SIPBytes_Check(sipPy) ||
+ PyUnicode_Check(sipPy) ||
sipCanConvertToInstance(sipPy,sipClass_TQByteArray,SIP_NO_CONVERTORS));
- if (PyString_Check(sipPy))
+ if (PyUnicode_Check(sipPy))
+ {
+ Py_BEGIN_ALLOW_THREADS
+ TQByteArray *ba = new TQByteArray();
+
+#if PY_VERSION_HEX >= 0x03030000
+ ba -> duplicate((char *)PyUnicode_1BYTE_DATA(sipPy),PyUnicode_GET_SIZE(sipPy));
+#else
+ ba -> duplicate((char *)PyUnicode_AS_DATA(sipPy),PyUnicode_GET_SIZE(sipPy));
+#endif
+ *sipCppPtr = ba;
+ Py_END_ALLOW_THREADS
+
+ return sipGetState(sipTransferObj);
+ }
+#if PY_VERSION_HEX >= 0x02060000
+ else if (PyByteArray_Check(sipPy))
{
Py_BEGIN_ALLOW_THREADS
TQByteArray *ba = new TQByteArray();
- ba -> duplicate(PyString_AS_STRING(sipPy),PyString_GET_SIZE(sipPy));
+ ba -> duplicate(PyByteArray_AS_STRING(sipPy),PyByteArray_GET_SIZE(sipPy));
+
+ *sipCppPtr = ba;
+ Py_END_ALLOW_THREADS
+
+ return sipGetState(sipTransferObj);
+ }
+#endif
+ else if (SIPBytes_Check(sipPy))
+ {
+ Py_BEGIN_ALLOW_THREADS
+ TQByteArray *ba = new TQByteArray();
+
+ ba -> duplicate(SIPBytes_AS_STRING(sipPy),SIPBytes_GET_SIZE(sipPy));
*sipCppPtr = ba;
Py_END_ALLOW_THREADS
@@ -195,9 +244,7 @@ public:
};
-%If (TQt_3_1_0 -)
TQByteArray tqCompress(const uchar * /Array/,int /ArraySize/);
TQByteArray tqCompress(const TQByteArray &);
TQByteArray tqUncompress(const uchar * /Array/,int /ArraySize/);
TQByteArray tqUncompress(const TQByteArray &);
-%End
diff --git a/sip/qt/qcstring.sip b/sip/qt/qcstring.sip
index 5e877e6..9f076b6 100644
--- a/sip/qt/qcstring.sip
+++ b/sip/qt/qcstring.sip
@@ -197,19 +197,19 @@ public:
if (s == NULL)
s = "";
- sipRes = PyString_FromString(s);
+ sipRes = SIPBytes_FromString(s);
%End
%ConvertToTypeCode
// Allow a Python string whenever a TQCString is expected.
if (sipIsErr == NULL)
- return (PyString_Check(sipPy) ||
+ return (SIPBytes_Check(sipPy) ||
sipCanConvertToInstance(sipPy,sipClass_TQCString,SIP_NO_CONVERTORS));
- if (PyString_Check(sipPy))
+ if (SIPBytes_Check(sipPy))
{
- *sipCppPtr = new TQCString(PyString_AS_STRING(sipPy));
+ *sipCppPtr = new TQCString(SIPBytes_AS_STRING(sipPy));
return sipGetState(sipTransferObj);
}
diff --git a/sip/qt/qdragobject.sip b/sip/qt/qdragobject.sip
index f258596..fbd5e29 100644
--- a/sip/qt/qdragobject.sip
+++ b/sip/qt/qdragobject.sip
@@ -20,6 +20,7 @@
// PyTQt; see the file LICENSE. If not, write to the Free Software Foundation,
// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+%DefaultEncoding "UTF-8"
%ExportedDoc
<Sect2><Title>TQColorDrag (TQt v2.1+)</Title>
diff --git a/sip/qt/qfile.sip b/sip/qt/qfile.sip
index f11da7f..38d91c3 100644
--- a/sip/qt/qfile.sip
+++ b/sip/qt/qfile.sip
@@ -167,7 +167,7 @@ public:
Py_INCREF(Py_None);
sipRes = Py_None;
}
- else if ((sipRes = PyString_FromStringAndSize(buf,actlen)) == NULL)
+ else if ((sipRes = SIPBytes_FromStringAndSize(buf,actlen)) == NULL)
sipIsErr = 1;
sipFree((void *)buf);
@@ -196,7 +196,7 @@ public:
Py_INCREF(Py_None);
sipRes = Py_None;
}
- else if ((sipRes = PyString_FromStringAndSize(buf,actlen)) == NULL)
+ else if ((sipRes = SIPBytes_FromStringAndSize(buf,actlen)) == NULL)
sipIsErr = 1;
sipFree((void *)buf);
@@ -238,7 +238,7 @@ public:
}
else
{
- sipRes = PyString_FromStringAndSize(buf,actlen);
+ sipRes = SIPBytes_FromStringAndSize(buf,actlen);
sipFree((void *)buf);
@@ -272,7 +272,7 @@ public:
}
else
{
- sipRes = PyString_FromStringAndSize(buf,actlen);
+ sipRes = SIPBytes_FromStringAndSize(buf,actlen);
sipFree((void *)buf);
diff --git a/sip/qt/qfontmetrics.sip b/sip/qt/qfontmetrics.sip
index 294aedb..9ab3d89 100644
--- a/sip/qt/qfontmetrics.sip
+++ b/sip/qt/qfontmetrics.sip
@@ -201,7 +201,7 @@ static int intListToArray(PyObject *pl,int **ap)
for (i = 0; i < nint; ++i)
{
- *ip++ = PyInt_AsLong(PyList_GetItem(pl,i));
+ *ip++ = PyLong_AsLong(PyList_GetItem(pl,i));
if (PyErr_Occurred())
{
diff --git a/sip/qt/qimage.sip b/sip/qt/qimage.sip
index dc2c85a..47f44a0 100644
--- a/sip/qt/qimage.sip
+++ b/sip/qt/qimage.sip
@@ -515,7 +515,7 @@ const char **PyTQt_qt_ListToArray(PyObject *lst);
// TQPixmap.
const char **PyTQt_qt_ListToArray(PyObject *lst)
{
- int nstr;
+ SIP_SSIZE_T nstr;
const char **str, **sp;
nstr = PyList_Size(lst);
@@ -528,15 +528,16 @@ const char **PyTQt_qt_ListToArray(PyObject *lst)
for (int i = 0; i < nstr; ++i)
{
- char *s;
+ PyObject *item = PyList_GetItem(lst, i);
+ const char *item_ascii = sipString_AsASCIIString(&item);
- if ((s = PyString_AsString(PyList_GetItem(lst,i))) == NULL)
+ if (item_ascii == NULL)
{
sipFree((void *)str);
return NULL;
}
- *sp++ = s;
+ *sp++ = item_ascii;
}
return str;
diff --git a/sip/qt/qiodevice.sip b/sip/qt/qiodevice.sip
index 2f1f491..4fbbb05 100644
--- a/sip/qt/qiodevice.sip
+++ b/sip/qt/qiodevice.sip
@@ -151,7 +151,7 @@ public:
}
else
{
- sipRes = PyString_FromStringAndSize(buf,actlen);
+ sipRes = SIPBytes_FromStringAndSize(buf,actlen);
sipFree((void *)buf);
@@ -171,15 +171,15 @@ public:
if (buf == Py_None)
sipRes = -1;
- else if (!PyString_Check(buf))
+ else if (!SIPBytes_Check(buf))
{
sipBadCatcherResult(sipMethod);
sipIsErr = 1;
}
else
{
- memcpy(a0,PyString_AS_STRING(buf),PyString_GET_SIZE(buf));
- sipRes = PyString_GET_SIZE(buf);
+ memcpy(a0,SIPBytes_AS_STRING(buf),SIPBytes_GET_SIZE(buf));
+ sipRes = SIPBytes_GET_SIZE(buf);
}
Py_DECREF(buf);
@@ -211,7 +211,7 @@ public:
}
else
{
- sipRes = PyString_FromStringAndSize(buf,actlen);
+ sipRes = SIPBytes_FromStringAndSize(buf,actlen);
sipFree((void *)buf);
@@ -231,15 +231,15 @@ public:
if (buf == Py_None)
sipRes = -1L;
- else if (!PyString_Check(buf))
+ else if (!SIPBytes_Check(buf))
{
sipBadCatcherResult(sipMethod);
sipIsErr = 1;
}
else
{
- memcpy(a0,PyString_AS_STRING(buf),PyString_GET_SIZE(buf));
- sipRes = PyString_GET_SIZE(buf);
+ memcpy(a0,SIPBytes_AS_STRING(buf),SIPBytes_GET_SIZE(buf));
+ sipRes = SIPBytes_GET_SIZE(buf);
}
Py_DECREF(buf);
@@ -281,7 +281,7 @@ public:
}
else
{
- sipRes = PyString_FromStringAndSize(buf,actlen);
+ sipRes = SIPBytes_FromStringAndSize(buf,actlen);
sipFree((void *)buf);
@@ -301,15 +301,15 @@ public:
if (buf == Py_None)
sipRes = -1;
- else if (!PyString_Check(buf))
+ else if (!SIPBytes_Check(buf))
{
sipBadCatcherResult(sipMethod);
sipIsErr = 1;
}
else
{
- memcpy(a0,PyString_AS_STRING(buf),PyString_GET_SIZE(buf));
- sipRes = PyString_GET_SIZE(buf);
+ memcpy(a0,SIPBytes_AS_STRING(buf),SIPBytes_GET_SIZE(buf));
+ sipRes = SIPBytes_GET_SIZE(buf);
}
Py_DECREF(buf);
@@ -341,7 +341,7 @@ public:
}
else
{
- sipRes = PyString_FromStringAndSize(buf,actlen);
+ sipRes = SIPBytes_FromStringAndSize(buf,actlen);
sipFree((void *)buf);
@@ -361,15 +361,15 @@ public:
if (buf == Py_None)
sipRes = -1L;
- else if (!PyString_Check(buf))
+ else if (!SIPBytes_Check(buf))
{
sipBadCatcherResult(sipMethod);
sipIsErr = 1;
}
else
{
- memcpy(a0,PyString_AS_STRING(buf),PyString_GET_SIZE(buf));
- sipRes = PyString_GET_SIZE(buf);
+ memcpy(a0,SIPBytes_AS_STRING(buf),SIPBytes_GET_SIZE(buf));
+ sipRes = SIPBytes_GET_SIZE(buf);
}
Py_DECREF(buf);
diff --git a/sip/qt/qkeysequence.sip b/sip/qt/qkeysequence.sip
index 8d8e32e..9293ffe 100644
--- a/sip/qt/qkeysequence.sip
+++ b/sip/qt/qkeysequence.sip
@@ -71,7 +71,7 @@ public:
PyErr_Clear();
- PyInt_AsLong(sipPy);
+ PyLong_AsLong(sipPy);
return !PyErr_Occurred();
}
@@ -106,7 +106,7 @@ public:
return sipGetState(sipTransferObj);
}
- int key = PyInt_AsLong(sipPy);
+ int key = (int)PyLong_AsLong(sipPy);
Py_BEGIN_ALLOW_THREADS
*sipCppPtr = new TQKeySequence(key);
diff --git a/sip/qt/qlabel.sip b/sip/qt/qlabel.sip
index 99ac8ac..a19541e 100644
--- a/sip/qt/qlabel.sip
+++ b/sip/qt/qlabel.sip
@@ -19,6 +19,7 @@
// PyTQt; see the file LICENSE. If not, write to the Free Software Foundation,
// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+%DefaultEncoding "UTF-8"
%ExportedDoc
<Sect2><Title>TQLabel</Title>
diff --git a/sip/qt/qlcdnumber.sip b/sip/qt/qlcdnumber.sip
index c071f50..2127210 100644
--- a/sip/qt/qlcdnumber.sip
+++ b/sip/qt/qlcdnumber.sip
@@ -19,6 +19,7 @@
// PyTQt; see the file LICENSE. If not, write to the Free Software Foundation,
// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+%DefaultEncoding "UTF-8"
%ExportedDoc
<Sect2><Title>TQLCDNumber</Title>
diff --git a/sip/qt/qlistview.sip b/sip/qt/qlistview.sip
index d7ef8a1..fa2a5ab 100644
--- a/sip/qt/qlistview.sip
+++ b/sip/qt/qlistview.sip
@@ -56,91 +56,6 @@ call <Literal>takeItem()</Literal> and then <Literal>del()</Literal>.
%End
-%If (- TQt_2_00)
-
-class TQListViewItem
-{
-%TypeHeaderCode
-#include <tqlistview.h>
-%End
-
-public:
- TQListViewItem(TQListView * /TransferThis/);
- TQListViewItem(TQListViewItem * /TransferThis/);
- TQListViewItem(TQListView * /TransferThis/,TQListViewItem *);
- TQListViewItem(TQListViewItem * /TransferThis/,TQListViewItem *);
-
- TQListViewItem(TQListView * /TransferThis/,
- const char *,const char * = 0,
- const char * = 0,const char * = 0,
- const char * = 0,const char * = 0,
- const char * = 0,const char * = 0);
-
- TQListViewItem(TQListViewItem * /TransferThis/,
- const char *,const char * = 0,
- const char * = 0,const char * = 0,
- const char * = 0,const char * = 0,
- const char * = 0,const char * = 0);
-
- TQListViewItem(TQListView * /TransferThis/,TQListViewItem *,
- const char *,const char * = 0,
- const char * = 0,const char * = 0,
- const char * = 0,const char * = 0,
- const char * = 0,const char * = 0);
-
- TQListViewItem(TQListViewItem * /TransferThis/,TQListViewItem *,
- const char *,const char * = 0,
- const char * = 0,const char * = 0,
- const char * = 0,const char * = 0,
- const char * = 0,const char * = 0);
-
- virtual void insertItem(TQListViewItem * /Transfer/);
- virtual void removeItem(TQListViewItem * /TransferBack/);
- int height() const;
- virtual void invalidateHeight();
- int totalHeight() const;
- virtual int width(const TQFontMetrics &,const TQListView *,int) const;
- void widthChanged(int = -1) const;
- int depth() const;
- virtual void setText(int,const char *);
- virtual const char *text(int) const;
- virtual void setPixmap(int,const TQPixmap &);
- virtual const TQPixmap *pixmap(int) const;
- virtual const char *key(int,bool) const;
- virtual void sortChildItems(int,bool);
- int childCount() const;
- bool isOpen() const;
- virtual void setOpen(bool);
- virtual void setup();
- virtual void setSelected(bool);
- bool isSelected() const;
- virtual void paintCell(TQPainter *,const TQColorGroup &,int,int,int);
- virtual void paintBranches(TQPainter *,const TQColorGroup &,int,int,int,
- GUIStyle);
- virtual void paintFocus(TQPainter *,const TQColorGroup &,const TQRect &);
- TQListViewItem *firstChild() const;
- TQListViewItem *nextSibling() const;
- TQListViewItem *parent() const;
- TQListViewItem *itemAbove();
- TQListViewItem *itemBelow();
- int itemPos() const;
- TQListView *listView() const;
- virtual void setSelectable(bool);
- bool isSelectable() const;
- virtual void setExpandable(bool);
- bool isExpandable();
- void repaint() const;
-
-protected:
- virtual void enforceSortOrder() const;
- virtual void setHeight(int);
- virtual void activate();
-};
-
-%End
-
-%If (TQt_2_00 -)
-
class TQListViewItem : TQt
{
%TypeHeaderCode
@@ -194,9 +109,7 @@ public:
virtual const TQPixmap *pixmap(int) const;
virtual TQString key(int,bool) const;
-%If (TQt_3_0_0 -)
virtual int compare(TQListViewItem *,int,bool) const;
-%End
virtual void sortChildItems(int,bool);
int childCount() const;
@@ -209,13 +122,7 @@ public:
bool isSelected() const;
virtual void paintCell(TQPainter *,const TQColorGroup &,int,int,int);
-%If (- TQt_3_0_0)
- virtual void paintBranches(TQPainter *,const TQColorGroup &,int,int,int,
- GUIStyle);
-%End
-%If (TQt_3_0_0 -)
virtual void paintBranches(TQPainter *,const TQColorGroup &,int,int,int);
-%End
virtual void paintFocus(TQPainter *,const TQColorGroup &,const TQRect &);
TQListViewItem *firstChild() const;
@@ -237,17 +144,9 @@ public:
void repaint() const;
-%If (TQt_2_1_0 - TQt_3_0_0)
- void sort();
-%End
-%If (TQt_3_0_0 -)
virtual void sort();
-%End
-%If (TQt_2_2_0 -)
void moveItem(TQListViewItem *);
-%End
-%If (TQt_3_0_0 -)
virtual void setDragEnabled(bool);
virtual void setDropEnabled(bool);
bool dragEnabled() const;
@@ -268,17 +167,13 @@ public:
virtual void setMultiLinesEnabled(bool);
bool multiLinesEnabled() const;
-%End
protected:
virtual void enforceSortOrder() const;
virtual void setHeight(int);
virtual void activate();
-%If (TQt_2_1_0 -)
bool activatedPos(TQPoint &);
-%End
-%If (TQt_3_0_0 -)
virtual void dropped(TQDropEvent *);
virtual void dragEntered();
virtual void dragLeft();
@@ -286,11 +181,8 @@ protected:
virtual void cancelRename(int);
void ignoreDoubleClick();
-%End
};
-%End
-
class TQListView : TQScrollView
{
@@ -299,44 +191,22 @@ class TQListView : TQScrollView
%End
public:
-%If (TQt_2_2_0 - TQt_3_0_0)
- TQListView(TQWidget * /TransferThis/,const char *,WFlags);
-%End
-%If (- TQt_3_0_0)
- TQListView(TQWidget * /TransferThis/ = 0,const char * = 0);
-%End
-%If (TQt_3_0_0 -)
TQListView(TQWidget * /TransferThis/ = 0,const char * = 0,WFlags = 0);
-%End
int treeStepSize() const;
virtual void setTreeStepSize(int);
virtual void insertItem(TQListViewItem * /Transfer/);
-%If (TQt_2_00 -)
virtual void takeItem(TQListViewItem * /TransferBack/);
-%End
-%If (- TQt_3_0_0)
- virtual void clear();
-%End
TQHeader *header() const;
-%If (- TQt_2_00)
- virtual int addColumn(const char *,int = -1);
- virtual void setColumnText(int,const char *);
- const char *columnText(int) const;
-%End
-%If (TQt_2_00 -)
virtual int addColumn(const TQString &,int = -1);
virtual int addColumn(const TQIconSet &,const TQString &,int = -1);
-%If (TQt_2_1_0 -)
void removeColumn(int);
-%End
virtual void setColumnText(int,const TQString &);
virtual void setColumnText(int,const TQIconSet &,const TQString &);
TQString columnText(int) const;
-%End
virtual void setColumnWidth(int,int);
int columnWidth(int) const;
@@ -348,9 +218,7 @@ public:
virtual void setColumnWidthMode(int,WidthMode);
WidthMode columnWidthMode(int) const;
-%If (TQt_2_1_0 -)
int columns() const;
-%End
virtual void setColumnAlignment(int,int);
int columnAlignment(int) const;
@@ -368,7 +236,6 @@ public:
virtual void setMultiSelection(bool);
bool isMultiSelection() const;
-%If (TQt_2_1_0 -)
enum SelectionMode {
Single,
Multi,
@@ -378,19 +245,12 @@ public:
void setSelectionMode(SelectionMode);
SelectionMode selectionMode() const;
-%End
-%If (TQt_2_1_0 -)
virtual void clearSelection();
-%End
virtual void setSelected(TQListViewItem *,bool);
-%If (TQt_3_2_0 -)
void setSelectionAnchor(TQListViewItem *);
-%End
bool isSelected(TQListViewItem *) const;
-%If (TQt_2_1_0 -)
TQListViewItem *selectedItem() const;
-%End
virtual void setOpen(TQListViewItem *,bool);
bool isOpen(TQListViewItem *) const;
@@ -398,9 +258,7 @@ public:
TQListViewItem *currentItem() const;
TQListViewItem *firstChild() const;
-%If (TQt_3_0_0 -)
TQListViewItem *lastItem() const;
-%End
int childCount() const;
@@ -414,43 +272,22 @@ public:
bool rootIsDecorated() const;
virtual void setSorting(int,bool = 1);
-%If (TQt_3_1_0 -)
int sortColumn() const;
-%End
-%If (TQt_3_2_0 -)
void setSortColumn(int);
SortOrder sortOrder() const;
void setSortOrder(SortOrder);
-%End
-%If (TQt_3_0_0 -)
virtual void sort();
-%End
-%If (TQt_2_1_0 - TQt_3_0_0)
- void sort();
-%End
-%If (- TQt_2_00)
- void setStyle(GUIStyle);
- void setFont(const TQFont &);
- void setPalette(const TQPalette &);
-%End
-%If (TQt_2_00 -)
virtual void setFont(const TQFont &);
virtual void setPalette(const TQPalette &);
-%End
bool eventFilter(TQObject *,TQEvent *);
TQSize sizeHint() const;
-%If (TQt_2_00 -)
TQSize minimumSizeHint() const;
-%End
-%If (TQt_2_1_0 -)
void setShowSortIndicator(bool);
bool showSortIndicator() const;
-%End
-%If (TQt_3_0_0 -)
virtual void setShowToolTips(bool);
bool showToolTips() const;
@@ -474,83 +311,51 @@ public:
virtual void setDefaultRenameAction(RenameAction);
RenameAction defaultRenameAction() const;
bool isRenaming() const;
-%End
-%If (TQt_3_2_0 -)
void hideColumn(int);
-%End
public slots:
-%If (TQt_3_0_0 -)
virtual void clear();
-%End
-%If (TQt_2_1_0 -)
void invertSelection();
void selectAll(bool);
void setContentsPos(int,int);
-%End
void triggerUpdate();
-%If (TQt_3_2_0 -)
void adjustColumn(int);
-%End
signals:
void selectionChanged();
void selectionChanged(TQListViewItem *);
void currentChanged(TQListViewItem *);
-%If (TQt_2_1_0 -)
void clicked(TQListViewItem *);
void clicked(TQListViewItem *,const TQPoint &,int);
void pressed(TQListViewItem *);
void pressed(TQListViewItem *,const TQPoint &,int);
-%End
void doubleClicked(TQListViewItem *);
-%If (TQt_3_2_0 -)
void doubleClicked(TQListViewItem *,const TQPoint &,int);
-%End
void returnPressed(TQListViewItem *);
-%If (TQt_3_0_0 -)
void spacePressed(TQListViewItem *);
-%End
void rightButtonClicked(TQListViewItem *,const TQPoint &,int);
void rightButtonPressed(TQListViewItem *,const TQPoint &,int);
-%If (TQt_2_1_0 -)
void mouseButtonPressed(int,TQListViewItem *,const TQPoint &,int);
void mouseButtonClicked(int,TQListViewItem *,const TQPoint &,int);
-%End
-%If (TQt_3_0_0 -)
void contextMenuRequested(TQListViewItem *,const TQPoint &,int);
-%End
-%If (TQt_2_1_0 -)
void onItem(TQListViewItem *);
void onViewport();
void expanded(TQListViewItem *);
void collapsed(TQListViewItem *);
-%End
-%If (TQt_3_0_0 -)
void dropped(TQDropEvent *);
void itemRenamed(TQListViewItem *,int,const TQString &);
void itemRenamed(TQListViewItem *,int);
-%End
protected:
-%If (- TQt_2_00)
- void mousePressEvent(TQMouseEvent *);
- void mouseReleaseEvent(TQMouseEvent *);
- void mouseMoveEvent(TQMouseEvent *);
- void mouseDoubleClickEvent(TQMouseEvent *);
-%End
-%If (TQt_2_00 -)
void contentsMousePressEvent(TQMouseEvent *);
void contentsMouseReleaseEvent(TQMouseEvent *);
void contentsMouseMoveEvent(TQMouseEvent *);
void contentsMouseDoubleClickEvent(TQMouseEvent *);
-%End
-%If (TQt_3_0_0 -)
void contentsContextMenuEvent(TQContextMenuEvent *);
void contentsDragEnterEvent(TQDragEnterEvent *);
void contentsDragMoveEvent(TQDragMoveEvent *);
@@ -558,7 +363,6 @@ protected:
void contentsDropEvent(TQDropEvent *);
virtual TQDragObject *dragObject();
virtual void startDrag();
-%End
void focusInEvent(TQFocusEvent *);
void focusOutEvent(TQFocusEvent *);
@@ -566,37 +370,22 @@ protected:
void keyPressEvent(TQKeyEvent *);
void resizeEvent(TQResizeEvent *);
-%If (TQt_3_0_0 -)
void viewportResizeEvent(TQResizeEvent *);
-%End
-%If (TQt_2_00 -)
void showEvent(TQShowEvent *);
-%End
void drawContentsOffset(TQPainter *,int,int,int,int,int,int);
virtual void paintEmptyArea(TQPainter *,const TQRect &);
-%If (TQt_2_00 -)
void styleChange(TQStyle &);
-%End
-%If (- TQt_3_0_0)
- void enabledChange(bool);
-%End
-%If (TQt_3_0_0 -)
void windowActivationChange(bool);
-%End
protected slots:
void updateContents();
-%If (TQt_2_00 -)
void doAutoScroll();
-%End
private:
-%If (TQt_2_1_0 -)
TQListView(const TQWidget &);
-%End
};
@@ -611,21 +400,16 @@ public:
RadioButton,
CheckBox,
Controller,
-%If (TQt_3_2_0 -)
RadioButtonController,
CheckBoxController,
-%End
};
-%If (TQt_3_2_0 -)
enum ToggleState {
Off,
NoChange,
On
};
-%End
-%If (TQt_3_2_0 -)
TQCheckListItem(TQCheckListItem * /TransferThis/,const TQString &,
Type = RadioButtonController);
TQCheckListItem(TQCheckListItem * /TransferThis/,TQListViewItem *,
@@ -638,91 +422,36 @@ public:
Type = RadioButtonController);
TQCheckListItem(TQListView * /TransferThis/,TQListViewItem *,
const TQString &,Type = RadioButtonController);
-%End
-%If (TQt_2_00 - TQt_3_2_0)
- TQCheckListItem(TQCheckListItem * /TransferThis/,const TQString &,
- Type = Controller);
-%If (TQt_3_1_0 -)
- TQCheckListItem(TQCheckListItem * /TransferThis/,TQListViewItem *,
- const TQString &,Type = Controller);
-%End
- TQCheckListItem(TQListViewItem * /TransferThis/,const TQString &,
- Type = Controller);
-%If (TQt_3_1_0 -)
- TQCheckListItem(TQListViewItem * /TransferThis/,TQListViewItem *,
- const TQString &,Type = Controller);
-%End
- TQCheckListItem(TQListView * /TransferThis/,const TQString &,
- Type = Controller);
-%If (TQt_3_1_0 -)
- TQCheckListItem(TQListView * /TransferThis/,TQListViewItem *,
- const TQString &,Type = Controller);
-%End
-%End
-%If (TQt_2_00 -)
TQCheckListItem(TQListViewItem * /TransferThis/,const TQString &,
const TQPixmap &);
TQCheckListItem(TQListView * /TransferThis/,const TQString &,
const TQPixmap &);
-%End
-%If (- TQt_2_00)
- TQCheckListItem(TQCheckListItem * /TransferThis/,const char *,
- Type = Controller);
- TQCheckListItem(TQListView * /TransferThis/,const char *,
- Type = Controller);
- TQCheckListItem(TQListViewItem * /TransferThis/,const char *,
- const TQPixmap &);
- TQCheckListItem(TQListView * /TransferThis/,const char *,
- const TQPixmap &);
-%End
void paintCell(TQPainter *,const TQColorGroup &,int,int,int);
-%If (TQt_2_00 -)
virtual void paintFocus(TQPainter *,const TQColorGroup &,const TQRect &);
-%End
int width(const TQFontMetrics &,const TQListView *,int) const;
void setup();
-%If (- TQt_2_00)
- void setOn(bool);
-%End
-%If (TQt_2_00 -)
virtual void setOn(bool);
-%End
bool isOn() const;
Type type() const;
-%If (- TQt_2_00)
- const char *text() const;
- const char *text(int) const;
-%End
-%If (TQt_2_00 -)
TQString text() const;
TQString text(int) const;
-%End
-%If (TQt_3_2_0 -)
void setTristate(bool);
bool isTristate() const;
ToggleState state() const;
void setState(ToggleState);
-%End
-%If (TQt_3_0_0 -)
int rtti() const;
-%End
protected:
-%If (- TQt_3_0_0)
- void paintBranches(TQPainter *,const TQColorGroup &,int,int,int,GUIStyle);
-%End
void activate();
void turnOffChild();
virtual void stateChange(bool);
};
-%If (TQt_2_00 -)
-
class TQListViewItemIterator
{
%TypeHeaderCode
@@ -730,7 +459,6 @@ class TQListViewItemIterator
%End
public:
-%If (TQt_3_2_0 -)
enum IteratorFlag {
Visible,
Invisible,
@@ -747,24 +475,17 @@ public:
Checked,
NotChecked
};
-%End
TQListViewItemIterator();
TQListViewItemIterator(TQListViewItem *);
-%If (TQt_3_2_0 -)
TQListViewItemIterator(TQListViewItem *,int);
-%End
TQListViewItemIterator(const TQListViewItemIterator &);
TQListViewItemIterator(TQListView *);
-%If (TQt_3_2_0 -)
TQListViewItemIterator(TQListView *,int);
-%End
TQListViewItemIterator &operator+=(int);
TQListViewItemIterator &operator-=(int);
TQListViewItem *current() const;
};
-
-%End
diff --git a/sip/qt/qmainwindow.sip b/sip/qt/qmainwindow.sip
index ca21ec4..19535ca 100644
--- a/sip/qt/qmainwindow.sip
+++ b/sip/qt/qmainwindow.sip
@@ -19,6 +19,7 @@
// PyTQt; see the file LICENSE. If not, write to the Free Software Foundation,
// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+%DefaultEncoding "UTF-8"
%ExportedDoc
<Sect2><Title>TQMainWindow</Title>
diff --git a/sip/qt/qmemarray.sip b/sip/qt/qmemarray.sip
index 5fc5d02..d7a4a7b 100644
--- a/sip/qt/qmemarray.sip
+++ b/sip/qt/qmemarray.sip
@@ -50,7 +50,7 @@ converted to and from Python lists of the type.
// Get it.
for (uint i = 0; i < sipCpp -> size(); ++i)
- if (PyList_SetItem(l,i,PyInt_FromLong((long)sipCpp -> at(i))) < 0)
+ if (PyList_SetItem(l,i,PyLong_FromLong((long)sipCpp -> at(i))) < 0)
{
Py_DECREF(l);
@@ -72,7 +72,7 @@ converted to and from Python lists of the type.
for (int i = 0; i < PyList_GET_SIZE(sipPy); ++i)
{
- (*qma)[i] = (int)PyInt_AsLong(PyList_GET_ITEM(sipPy,i));
+ (*qma)[i] = (int)PyLong_AsLong(PyList_GET_ITEM(sipPy,i));
if (PyErr_Occurred() != NULL)
{
diff --git a/sip/qt/qobject.sip b/sip/qt/qobject.sip
index 2ce5778..0f3a23e 100644
--- a/sip/qt/qobject.sip
+++ b/sip/qt/qobject.sip
@@ -403,7 +403,11 @@ public:
// the true (Python) class name.
SIP_PYOBJECT className() const;
%MethodCode
+#if PY_MAJOR_VERSION >= 3
+ sipRes = PyUnicode_FromString(sipSelf->ob_type->tp_name);
+#else
sipRes = sipClassName(sipSelf);
+#endif
%End
%If (- TQt_3_0_0)
@@ -425,49 +429,69 @@ public:
// trUtf8() methods for a Python sub-class instance in the sub-class's
// ctor.
- TQString tr(const char *,const char * = 0);
+ TQString tr(SIP_PYOBJECT sourceText /TypeHint="str"/,const char * = 0);
%MethodCode
- PyObject *nmobj;
+ if (tqApp)
+ {
+ const char *source = PyTQt_qt_encode(&a0, TQApplication::DefaultCodec);
- if ((nmobj = sipClassName(sipSelf)) == NULL)
- sipIsErr = 1;
+ if (source)
+ {
+ sipRes = new TQString(tqApp->translate(Py_TYPE(sipSelf)->tp_name, source,
+ a1, TQApplication::DefaultCodec));
+ Py_DECREF(a0);
+ }
+ else
+ {
+ sipIsErr = 1;
+ }
+ }
else
{
- char *cname = PyString_AsString(nmobj);
+ const char *source = sipString_AsLatin1String(&a0);
- Py_BEGIN_ALLOW_THREADS
-
- if (cname && tqApp)
- sipRes = new TQString(tqApp -> translate(cname,a0,a1,TQApplication::DefaultCodec));
+ if (source)
+ {
+ sipRes = new TQString(QString::fromLatin1(source));
+ Py_DECREF(a0);
+ }
else
- sipRes = new TQString(TQString::fromLatin1(a0));
-
- Py_END_ALLOW_THREADS
-
- Py_DECREF(nmobj);
+ {
+ sipIsErr = 1;
+ }
}
%End
- TQString trUtf8(const char *,const char * = 0);
+ TQString trUtf8(SIP_PYOBJECT sourceText /TypeHint="str"/,const char * = 0);
%MethodCode
- PyObject *nmobj;
+ if (tqApp)
+ {
+ const char *source = PyTQt_qt_encode(&a0, TQApplication::DefaultCodec);
- if ((nmobj = sipClassName(sipSelf)) == NULL)
- sipIsErr = 1;
+ if (source)
+ {
+ sipRes = new TQString(tqApp->translate(Py_TYPE(sipSelf)->tp_name, source,
+ a1, TQApplication::UnicodeUTF8));
+ Py_DECREF(a0);
+ }
+ else
+ {
+ sipIsErr = 1;
+ }
+ }
else
{
- char *cname = PyString_AsString(nmobj);
-
- Py_BEGIN_ALLOW_THREADS
+ const char *source = sipString_AsLatin1String(&a0);
- if (cname && tqApp)
- sipRes = new TQString(tqApp -> translate(cname,a0,a1,TQApplication::UnicodeUTF8));
+ if (source)
+ {
+ sipRes = new TQString(TQString::fromLatin1(source));
+ Py_DECREF(a0);
+ }
else
- sipRes = new TQString(TQString::fromUtf8(a0));
-
- Py_END_ALLOW_THREADS
-
- Py_DECREF(nmobj);
+ {
+ sipIsErr = 1;
+ }
}
%End
%End
@@ -811,7 +835,11 @@ public:
// it we can ignore it.
SIP_PYOBJECT className() const;
%MethodCode
+#if PY_MAJOR_VERSION >= 3
+ sipRes = PyUnicode_FromString(sipSelf->ob_type->tp_name);
+#else
sipRes = sipClassName(sipSelf);
+#endif
%End
bool isA(const char *) const;
@@ -866,7 +894,7 @@ private:
%End
-SIP_PYOBJECT SLOT(const char *);
+SIP_PYOBJECT SLOT(const char * /Encoding="ASCII"/) /TypeHint="QT_SLOT"/;
%MethodCode
if (!a0)
{
@@ -877,11 +905,11 @@ SIP_PYOBJECT SLOT(const char *);
{
int len = strlen(a0);
- if ((sipRes = PyString_FromStringAndSize(NULL,1 + len)) == NULL)
+ if ((sipRes = SIPBytes_FromStringAndSize(NULL,1 + len)) == NULL)
sipIsErr = 1;
else
{
- char *dp = PyString_AS_STRING(sipRes);
+ char *dp = SIPBytes_AS_STRING(sipRes);
*dp++ = '1';
@@ -891,7 +919,7 @@ SIP_PYOBJECT SLOT(const char *);
%End
-SIP_PYOBJECT SIGNAL(const char *);
+SIP_PYOBJECT SIGNAL(const char * /Encoding="ASCII"/) /TypeHint="QT_SIGNAL"/;
%MethodCode
if (!a0)
{
@@ -902,11 +930,11 @@ SIP_PYOBJECT SIGNAL(const char *);
{
int len = strlen(a0);
- if ((sipRes = PyString_FromStringAndSize(NULL,1 + len)) == NULL)
+ if ((sipRes = SIPBytes_FromStringAndSize(NULL,1 + len)) == NULL)
sipIsErr = 1;
else
{
- char *dp = PyString_AS_STRING(sipRes);
+ char *dp = SIPBytes_AS_STRING(sipRes);
*dp++ = '2';
@@ -916,7 +944,7 @@ SIP_PYOBJECT SIGNAL(const char *);
%End
-SIP_PYOBJECT PYSIGNAL(const char *);
+SIP_PYOBJECT PYSIGNAL(const char * /Encoding="ASCII"/);
%MethodCode
if (!a0)
{
@@ -927,11 +955,11 @@ SIP_PYOBJECT PYSIGNAL(const char *);
{
int len = strlen(a0);
- if ((sipRes = PyString_FromStringAndSize(NULL,1 + len)) == NULL)
+ if ((sipRes = SIPBytes_FromStringAndSize(NULL,1 + len)) == NULL)
sipIsErr = 1;
else
{
- char *dp = PyString_AS_STRING(sipRes);
+ char *dp = SIPBytes_AS_STRING(sipRes);
*dp++ = '9';
@@ -992,16 +1020,30 @@ extern "C" {
// The meta-type for PyTQt classes. It is just a marker type so that we can
// safely cast to get access to PyTQt3-specific data structures.
PyTypeObject pyqtWrapperType_Type = {
+#if PY_MAJOR_VERSION >= 3
+ PyVarObject_HEAD_INIT(NULL, 0)
+#else
PyObject_HEAD_INIT(NULL)
0, /* ob_size */
+#endif
"qt.pyqtWrapperType", /* tp_name */
sizeof (sipWrapperType), /* tp_basicsize */
0, /* tp_itemsize */
0, /* tp_dealloc */
+#if PY_VERSION_HEX >= 0x03080000
+ 0, /* tp_vectorcall_offset */
+#else
0, /* tp_print */
+#endif
0, /* tp_getattr */
0, /* tp_setattr */
+#if PY_VERSION_HEX >= 0x03050000
+ 0, /* tp_as_async */
+#elif PY_VERSION_HEX >= 0x03010000
+ 0, /* tp_reserved */
+#else
0, /* tp_compare */
+#endif
0, /* tp_repr */
0, /* tp_as_number */
0, /* tp_as_sequence */
@@ -1042,6 +1084,15 @@ PyTypeObject pyqtWrapperType_Type = {
#if PY_VERSION_HEX >= 0x02060000
0, /* tp_version_tag */
#endif
+#if PY_VERSION_HEX >= 0x03040000
+ 0, /* tp_finalize */
+#endif
+#if PY_VERSION_HEX >= 0x03080000
+ 0, /* tp_vectorcall */
+#endif
+#if PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION == 8
+ 0, /* tp_print (deprecated) */
+#endif
};
@@ -1196,16 +1247,30 @@ static sipWrapperType pyqtWrapper_Type = {
{
#endif
{
+#if PY_MAJOR_VERSION >= 3
+ PyVarObject_HEAD_INIT(&pyqtWrapperType_Type, 0)
+#else
PyObject_HEAD_INIT(&pyqtWrapperType_Type)
0, /* ob_size */
+#endif
"qt.pyqtWrapper", /* tp_name */
sizeof (pyqtWrapper), /* tp_basicsize */
0, /* tp_itemsize */
(destructor)pyqtWrapper_dealloc, /* tp_dealloc */
+#if PY_VERSION_HEX >= 0x03080000
+ 0, /* tp_vectorcall_offset */
+#else
0, /* tp_print */
+#endif
0, /* tp_getattr */
0, /* tp_setattr */
+#if PY_VERSION_HEX >= 0x03050000
+ 0, /* tp_as_async */
+#elif PY_VERSION_HEX >= 0x03010000
+ 0, /* tp_reserved */
+#else
0, /* tp_compare */
+#endif
0, /* tp_repr */
0, /* tp_as_number */
0, /* tp_as_sequence */
@@ -1246,6 +1311,15 @@ static sipWrapperType pyqtWrapper_Type = {
#if PY_VERSION_HEX >= 0x02060000
0, /* tp_version_tag */
#endif
+#if PY_VERSION_HEX >= 0x03040000
+ 0, /* tp_finalize */
+#endif
+#if PY_VERSION_HEX >= 0x03080000
+ 0, /* tp_vectorcall */
+#endif
+#if PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION == 8
+ 0, /* tp_print (deprecated) */
+#endif
},
#if !defined(STACKLESS)
},
@@ -1500,17 +1574,17 @@ bool UniversalSlot::tqt_invoke(int id, TQUObject *qargs)
case char_sat:
case schar_sat:
case uchar_sat:
- arg = PyString_FromStringAndSize((char *)static_QUType_ptr.get(qargs), 1);
+ arg = SIPBytes_FromStringAndSize((char *)static_QUType_ptr.get(qargs), 1);
break;
case string_sat:
case sstring_sat:
case ustring_sat:
- arg = PyString_FromString((char *)static_QUType_ptr.get(qargs));
+ arg = SIPBytes_FromString((char *)static_QUType_ptr.get(qargs));
break;
case short_sat:
- arg = PyInt_FromLong(*(short *)static_QUType_ptr.get(qargs));
+ arg = PyLong_FromLong(*(short *)static_QUType_ptr.get(qargs));
break;
case ushort_sat:
@@ -1519,9 +1593,9 @@ bool UniversalSlot::tqt_invoke(int id, TQUObject *qargs)
case int_sat:
if (qv)
- arg = PyInt_FromLong(qv -> asInt());
+ arg = PyLong_FromLong(qv -> asInt());
else
- arg = PyInt_FromLong(static_QUType_int.get(qargs));
+ arg = PyLong_FromLong(static_QUType_int.get(qargs));
break;
case uint_sat:
@@ -1557,7 +1631,7 @@ bool UniversalSlot::tqt_invoke(int id, TQUObject *qargs)
break;
case bool_sat:
- arg = PyInt_FromLong(static_QUType_bool.get(qargs));
+ arg = PyLong_FromLong(static_QUType_bool.get(qargs));
break;
case void_sat:
@@ -1628,7 +1702,14 @@ static void *sipTQtCreateUniversalSlot(sipWrapper *tx, const char *sig,
pyqt3SlotConnection conn;
/* Initialise the connection. */
- conn.sc_transmitter = (tx ? sipGetCppPtr((sipSimpleWrapper *)tx, 0) : 0);
+ if (sipGetAddress(&tx->super) == NULL)
+ {
+ conn.sc_transmitter = 0;
+ }
+ else
+ {
+ conn.sc_transmitter = (tx ? sipGetCppPtr(&tx->super, 0) : 0);
+ }
/* Save the real slot. */
if (sipSaveSlot(&conn.sc_slot, rxObj, slot) < 0)
diff --git a/sip/qt/qpainter.sip b/sip/qt/qpainter.sip
index 15ef70b..17c359f 100644
--- a/sip/qt/qpainter.sip
+++ b/sip/qt/qpainter.sip
@@ -289,7 +289,7 @@ public:
do
{
- if (PyList_SetItem(sipRes,len,PyInt_FromLong((long)*tp)) < 0)
+ if (PyList_SetItem(sipRes,len,PyLong_FromLong((long)*tp)) < 0)
{
Py_DECREF(sipRes);
sipIsErr = 1;
@@ -316,11 +316,11 @@ public:
{
// Convert the list.
- int *tp = tabs;
+ long *tp = tabs;
for (int i = 0; i < len; ++i)
{
- *tp++ = (int)PyInt_AsLong(PyList_GET_ITEM(a0,i));
+ *tp++ = PyLong_AsLong(PyList_GET_ITEM(a0,i));
if (PyErr_Occurred() != NULL)
{
@@ -612,7 +612,7 @@ public:
do
{
- if (PyList_SetItem(sipRes,len,PyInt_FromLong((long)*tp)) < 0)
+ if (PyList_SetItem(sipRes,len,PyLong_FromLong((long)*tp)) < 0)
{
Py_DECREF(sipRes);
sipIsErr = 1;
@@ -643,7 +643,7 @@ public:
for (int i = 0; i < len; ++i)
{
- *tp++ = (int)PyInt_AsLong(PyList_GET_ITEM(a0,i));
+ *tp++ = (int)PyLong_AsLong(PyList_GET_ITEM(a0,i));
if (PyErr_Occurred() != NULL)
{
diff --git a/sip/qt/qpair.sip b/sip/qt/qpair.sip
index 22de053..5065d2a 100644
--- a/sip/qt/qpair.sip
+++ b/sip/qt/qpair.sip
@@ -51,8 +51,8 @@ converted to and from Python tuples of two elements.
// Fill it.
- PyTuple_SET_ITEM(t,0,PyInt_FromLong((long)sipCpp -> first));
- PyTuple_SET_ITEM(t,1,PyInt_FromLong((long)sipCpp -> second));
+ PyTuple_SET_ITEM(t,0,PyLong_FromLong((long)sipCpp -> first));
+ PyTuple_SET_ITEM(t,1,PyLong_FromLong((long)sipCpp -> second));
return t;
%End
@@ -65,8 +65,8 @@ converted to and from Python tuples of two elements.
PyErr_Clear();
- int fst = (int)PyInt_AsLong(PyTuple_GET_ITEM(sipPy,0));
- int sec = (int)PyInt_AsLong(PyTuple_GET_ITEM(sipPy,1));
+ int fst = (int)PyLong_AsLong(PyTuple_GET_ITEM(sipPy,0));
+ int sec = (int)PyLong_AsLong(PyTuple_GET_ITEM(sipPy,1));
if (PyErr_Occurred() != NULL)
{
diff --git a/sip/qt/qpointarray.sip b/sip/qt/qpointarray.sip
index 959963a..5112a2f 100644
--- a/sip/qt/qpointarray.sip
+++ b/sip/qt/qpointarray.sip
@@ -109,7 +109,7 @@ static TQCOORD *getPoints(int nrpnts,PyObject *pntlist)
for (int i = 0; i < nrpnts; ++i)
{
- *pp++ = (TQCOORD)PyInt_AsLong(PyList_GetItem(pntlist,i));
+ *pp++ = (TQCOORD)PyLong_AsLong(PyList_GetItem(pntlist,i));
if (PyErr_Occurred() != NULL)
{
diff --git a/sip/qt/qpushbutton.sip b/sip/qt/qpushbutton.sip
index 69e961d..4fb26b1 100644
--- a/sip/qt/qpushbutton.sip
+++ b/sip/qt/qpushbutton.sip
@@ -19,6 +19,7 @@
// PyTQt; see the file LICENSE. If not, write to the Free Software Foundation,
// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+%DefaultEncoding "UTF-8"
%ExportedDoc
<Sect2><Title>TQPushButton</Title>
diff --git a/sip/qt/qstring.sip b/sip/qt/qstring.sip
index ab30fa4..581bb0a 100644
--- a/sip/qt/qstring.sip
+++ b/sip/qt/qstring.sip
@@ -195,53 +195,8 @@ public:
static const TQChar replacement;
static const TQChar byteOrderMark;
static const TQChar byteOrderSwapped;
-%If (TQt_2_2_0 -)
static const TQChar nbsp;
-%End
-%If (- TQt_3_0_0)
- enum Category {
- NoCategory,
-
- Mark_NonSpacing,
- Mark_SpacingCombining,
- Mark_Enclosing,
-
- Number_DecimalDigit,
- Number_Letter,
- Number_Other,
-
- Separator_Space,
- Separator_Line,
- Separator_Paragraph,
-
- Other_Control,
- Other_Format,
- Other_Surrogate,
- Other_PrivateUse,
- Other_NotAssigned,
-
- Letter_Uppercase,
- Letter_Lowercase,
- Letter_Titlecase,
- Letter_Modifier,
- Letter_Other,
-
- Punctuation_Connector,
- Punctuation_Dask,
- Punctuation_Open,
- Punctuation_Close,
- Punctuation_InitialQuote,
- Punctuation_FinalQuote,
- Punctuation_Other,
-
- Symbol_Math,
- Symbol_Currency,
- Symbol_Modifier,
- Symbol_Other
- };
-%End
-%If (TQt_3_0_0 -)
enum Category {
NoCategory,
@@ -282,24 +237,7 @@ public:
Symbol_Modifier,
Symbol_Other
};
-%End
-%If (- TQt_3_0_0)
- enum Direction {
- DirL,
- DirR,
- DirEN,
- DirES,
- DirET,
- DirAN,
- DirCS,
- DirB,
- DirS,
- DirWS,
- DirON
- };
-%End
-%If (TQt_3_0_0 -)
enum Direction {
DirL,
DirR,
@@ -321,7 +259,6 @@ public:
DirNSM,
DirBN
};
-%End
enum Decomposition {
Single,
@@ -351,7 +288,6 @@ public:
Center
};
-%If (TQt_3_0_0 -)
enum CombiningClass {
Combining_BelowLeftAttached,
Combining_BelowAttached,
@@ -375,7 +311,6 @@ public:
Combining_DoubleAbove,
Combining_IotaSubscript
};
-%End
int digitValue() const;
TQChar lower() const;
@@ -385,19 +320,10 @@ public:
Direction direction() const;
Joining joining() const;
bool mirrored() const;
-%If (TQt_2_1_0 -)
TQChar mirroredChar() const;
-%End
-%If (- TQt_3_0_0)
- TQString decomposition() const;
-%End
-%If (TQt_3_0_0 -)
const TQString &decomposition() const;
-%End
Decomposition decompositionTag() const;
-%If (TQt_3_0_0 -)
unsigned char combiningClass() const;
-%End
char latin1() const;
ushort unicode() const;
@@ -409,22 +335,16 @@ public:
bool isMark() const;
bool isLetter() const;
bool isNumber() const;
-%If (TQt_2_1_0 -)
bool isLetterOrNumber() const;
-%End
bool isDigit() const;
-%If (TQt_3_0_0 -)
bool isSymbol() const;
-%End
// uchar& cell();
// uchar& row();
uchar cell() const;
uchar row() const;
-%If (TQt_3_0_0 -)
void setCell(uchar);
void setRow(uchar);
-%End
static bool networkOrdered();
};
@@ -447,6 +367,7 @@ class TQString
{
%TypeHeaderCode
#include <tqstring.h>
+#include <tqtextcodec.h>
%End
public:
@@ -457,18 +378,14 @@ public:
// TQString(const TQChar *,uint);
// TQString(const char *);
-%If (TQt_2_1_0 -)
// This is how we implement TQUrl::operator TQString() const.
TQString(const TQUrl &);
-%End
-%If (TQt_3_0_0 -)
// This is how we implement TQKeySequence::operator TQString() const.
TQString(const TQKeySequence &);
// This is how we implement TQUuid::operator TQString() const.
TQString(const TQUuid &);
-%End
static const TQString null;
@@ -476,20 +393,13 @@ public:
bool isEmpty() const;
uint length() const;
void truncate(uint);
-%If (- TQt_3_0_0)
- void fill(TQChar,int = -1);
-%End
-%If (TQt_3_0_0 -)
TQString &fill(TQChar,int = -1);
-%End
TQString copy() const;
TQString arg(int /Constrained/,int = 0,int = 10) const;
TQString arg(double /Constrained/,int = 0,char = 'g',int = -1) const;
-%If (TQt_3_2_0 -)
// TQString arg(TQ_LLONG,int = 0,int = 10) const;
// TQString arg(TQ_ULLONG,int = 0,int = 10) const;
-%End
TQString arg(long,int = 0,int = 10) const;
TQString arg(ulong,int = 0,int = 10) const;
// TQString arg(uint,int = 0,int = 10) const;
@@ -498,12 +408,10 @@ public:
TQString arg(char,int = 0) const;
TQString arg(TQChar,int = 0) const;
TQString arg(const TQString&,int = 0) const;
-%If (TQt_3_2_0 -)
TQString arg(const TQString &,const TQString &) const;
TQString arg(const TQString &,const TQString &,const TQString &) const;
TQString arg(const TQString &,const TQString &,const TQString &,
const TQString &) const;
-%End
// TQString &sprintf(const char *,...);
@@ -523,7 +431,6 @@ public:
int contains(const TQString &,bool = 1) const;
int contains(const TQRegExp &) const;
-%If (TQt_3_0_0 -)
enum SectionFlags {
SectionDefault,
SectionSkipEmpty,
@@ -540,7 +447,6 @@ public:
int = SectionDefault) const;
TQString section(const TQRegExp &,int,int = 0xffffffff,
int = SectionDefault) const;
-%End
TQString left(uint) const;
TQString right(uint) const;
@@ -553,56 +459,36 @@ public:
TQString simplifyWhiteSpace() const;
TQString &insert(uint,const TQString &);
-%If (TQt_3_2_0 -)
TQString &insert(uint,const TQByteArray &);
// TQString &insert(uint,const char *);
-%End
TQString &insert(uint,TQChar *,uint);
TQString &insert(uint,TQChar);
TQString &insert(uint,char);
TQString &append(char);
-%If (TQt_2_2_0 -)
TQString &append(TQChar);
-%End
TQString &append(const TQString &);
TQString &prepend(char);
-%If (TQt_2_2_0 -)
TQString &prepend(TQChar);
-%End
TQString &prepend(const TQString &);
TQString &remove(uint,uint);
-%If (TQt_3_1_0 -)
TQString &remove(const TQString &);
-%If (TQt_3_2_0 -)
TQString &remove(const TQString &,bool);
-%End
TQString &remove(TQChar);
TQString &remove(char);
TQString &remove(const TQRegExp &);
-%End
TQString &replace(uint,uint,const TQString &);
TQString &replace(uint,uint,const TQChar *,uint);
-%If (TQt_3_1_0 -)
TQString &replace(uint,uint,TQChar);
TQString &replace(uint,uint,char);
TQString &replace(TQChar,const TQString &);
-%If (TQt_3_2_0 -)
TQString &replace(TQChar,const TQString &,bool);
-%End
TQString &replace(char,const TQString &);
-%If (TQt_3_2_0 -)
TQString &replace(char,const TQString &,bool);
-%End
TQString &replace(const TQString &,const TQString &);
-%If (TQt_3_2_0 -)
TQString &replace(const TQString &,const TQString &,bool);
-%End
-%End
TQString &replace(const TQRegExp &,const TQString &);
-%If (TQt_3_1_0 -)
TQString &replace(TQChar,TQChar);
-%End
short toShort(bool * = 0,int = 10) const;
ushort toUShort(bool * = 0,int = 10) const;
@@ -610,10 +496,8 @@ public:
uint toUInt(bool * = 0,int = 10) const;
long toLong(bool * = 0,int = 10) const;
ulong toULong(bool * = 0,int = 10) const;
-%If (TQt_3_2_0 -)
// TQ_LLONG toLongLong(bool * = 0,int = 10) const;
// TQ_ULLONG toULongLong(bool * = 0,int = 10) const;
-%End
float toFloat(bool * = 0) const;
double toDouble(bool * = 0) const;
@@ -624,28 +508,22 @@ public:
// TQString &setNum(uint,int = 10);
TQString &setNum(long,int = 10);
TQString &setNum(ulong,int = 10);
-%If (TQt_3_2_0 -)
// TQString &setNum(TQ_LLONG,int = 10);
// TQString &setNum(TQ_ULLONG,int = 10);
-%End
// TQString &setNum(float,char = 'g',int = 6);
static TQString number(int /Constrained/,int = 10);
static TQString number(double /Constrained/,char = 'g',int = 6);
static TQString number(long,int = 10);
static TQString number(ulong,int = 10);
-%If (TQt_3_2_0 -)
// static TQString number(TQ_LLONG,int = 10);
// static TQString number(TQ_ULLONG,int = 10);
-%End
// static TQString number(uint,int = 10);
void setExpand(uint,TQChar);
TQString &operator+=(const TQString &);
-%If (TQt_3_3_0 -)
TQString &operator+=(const TQByteArray &);
-%End
TQString &operator+=(TQChar);
//TQString &operator+=(char);
@@ -673,9 +551,7 @@ public:
// TQChar &ref(uint);
// const TQChar *unicode() const;
const char *ascii() const;
-%If (TQt_3_1_0 -)
static TQString fromAscii(const char *,int = -1);
-%End
const char *latin1() const;
static TQString fromLatin1(const char *,int = -1);
TQCString utf8() const;
@@ -683,62 +559,34 @@ public:
TQCString local8Bit() const;
static TQString fromLocal8Bit(const char *,int = -1);
-%If (TQt_3_1_0 -)
// static TQString fromUcs2(const unsigned short *);
// const unsigned short *ucs2() const;
-%End
-%If (TQt_2_1_0 -)
// TQString &setUnicode(const TQChar *,uint);
// TQString &setUnicodeCodes(const ushort *,uint);
-%End
-%If (TQt_3_1_0 -)
TQString &setAscii(const char *,int = -1);
-%End
-%If (TQt_2_1_0 -)
TQString &setLatin1(const char *,int = -1);
-%End
int compare(const TQString &) const;
static int compare(const TQString &,const TQString &);
-%If (TQt_3_0_0 -)
int localeAwareCompare(const TQString &) const;
static int localeAwareCompare(const TQString &,const TQString &);
-%End
void compose();
-%If (- TQt_3_0_0)
- TQChar::Direction basicDirection();
- TQString visual(int = 0,int = -1);
-%End
-%If (TQt_2_2_0 -)
bool startsWith(const TQString &) const;
-%End
-%If (TQt_3_2_0 -)
bool startsWith(const TQString &,bool) const;
-%End
-%If (TQt_3_0_0 -)
bool endsWith(const TQString &) const;
-%End
-%If (TQt_3_2_0 -)
bool endsWith(const TQString &,bool) const;
-%End
-%If (TQt_3_0_0 -)
void setLength(uint);
-%End
-%If (TQt_3_2_0 -)
uint capacity() const;
void reserve(uint);
void squeeze();
-%End
-%If (TQt_3_0_0 -)
bool simpleText() const;
bool isRightToLeft() const;
-%End
// Force the numeric interpretation so that str + TQString gets handled
// as we want.
@@ -792,81 +640,12 @@ public:
SIP_PYOBJECT __unicode__();
%MethodCode
-#if PY_VERSION_HEX >= 0x01060000
- sipRes = TQStringToPyUnicode(sipCpp);
-#else
- Py_INCREF(Py_None);
- sipRes = Py_None;
-#endif
+ sipRes = PyTQt_qt_PyObject_FromTQString(sipCpp);
%End
SIP_PYOBJECT __str__();
%MethodCode
-#if PY_VERSION_HEX >= 0x01060000
- sipRes = TQStringToPyUnicode(sipCpp);
-#else
- const char *s;
-
- Py_BEGIN_ALLOW_THREADS
- s = *sipCpp;
- Py_END_ALLOW_THREADS
-
- if (s == NULL)
- s = "";
-
- sipRes = PyString_FromString(s);
-#endif
-%End
-
-%TypeCode
-#include <tqtextcodec.h>
-
-#if PY_VERSION_HEX >= 0x01060000
-// Convenience function for converting a TQString to a Python Unicode object.
-static PyObject *TQStringToPyUnicode(TQString *qs)
-{
- PyObject *uobj;
-
- if ((uobj = PyUnicode_FromUnicode(NULL,qs -> length())) == NULL)
- return NULL;
-
- Py_UNICODE *pyu = PyUnicode_AS_UNICODE(uobj);
-
- for (uint i = 0; i < qs -> length(); ++i)
- *pyu++ = (qs -> at(i)).unicode();
-
- return uobj;
-}
-#endif
-
-// Convenience function for converting a Python unicode or string object to a
-// TQString on the heap.
-static TQString *PyUnicodeStringToTQString(PyObject *py)
-{
-#if PY_VERSION_HEX >= 0x01060000
- if (PyUnicode_Check(py))
- {
- TQString *qs = new TQString;
-
-#if defined(Py_UNICODE_WIDE)
- PY_UNICODE_TYPE *ucode = PyUnicode_AS_UNICODE(py);
- int len = PyUnicode_GET_SIZE(py);
-
- for (int i = 0; i < len; ++i)
- qs->ref(i) = (uint)ucode[i];
-#else
- qs -> setUnicodeCodes((ushort *)PyUnicode_AS_UNICODE(py),PyUnicode_GET_SIZE(py));
-#endif
-
- return qs;
- }
-#endif
-
- if (PyString_Check(py))
- return new TQString(PyString_AS_STRING(py));
-
- return 0;
-}
+ sipRes = PyTQt_qt_PyObject_FromTQString(sipCpp);
%End
%ConvertToTypeCode
@@ -874,13 +653,11 @@ static TQString *PyUnicodeStringToTQString(PyObject *py)
// expected.
if (sipIsErr == NULL)
- return (PyString_Check(sipPy) ||
-#if PY_VERSION_HEX >= 0x01060000
+ return (SIPBytes_Check(sipPy) ||
PyUnicode_Check(sipPy) ||
-#endif
sipCanConvertToInstance(sipPy,sipClass_TQString,SIP_NO_CONVERTORS));
- *sipCppPtr = PyUnicodeStringToTQString(sipPy);
+ *sipCppPtr = PyTQt_qt_PyObject_AsTQString(sipPy);
if (*sipCppPtr)
return sipGetState(sipTransferObj);
@@ -942,7 +719,7 @@ static TQString *PyUnicodeStringToTQString(PyObject *py)
enc = codec->fromUnicode(*sipCpp);
- if ((encobj = PyString_FromString(enc.data())) != NULL)
+ if ((encobj = SIPBytes_FromString(enc.data())) != NULL)
{
*sipPtrPtr = (void *)PyString_AS_STRING(encobj);
sipRes = PyString_GET_SIZE(encobj);
@@ -973,107 +750,227 @@ bool operator>=(const TQString &,const TQString &);
%End
-%If (- TQt_2_00)
+%ModuleHeaderCode
+extern PyObject *PyTQt_qt_PyObject_FromTQString(const TQString *qstr);
+%End
-class TQString : TQByteArray
+%ModuleCode
+// Convert a QString to a Python Unicode object.
+PyObject *PyTQt_qt_PyObject_FromTQString(const TQString *qstr)
{
-%TypeHeaderCode
-#include <tqstring.h>
+ PyObject *obj;
+
+#if PY_VERSION_HEX >= 0x03030000
+ // We have to work out exactly which kind to use. We assume ASCII while we
+ // are checking so that we only go through the string once in the most
+ // common case. Note that we can't use PyUnicode_FromKindAndData() because
+ // it doesn't handle surrogates in UCS2 strings.
+
+ int qt_len = qstr->length();
+ Py_UCS4 maxchar = 0x007f;
+
+ for (int qt_i = 0; qt_i < qt_len && maxchar < 0xffff; ++qt_i)
+ {
+ Py_UCS4 uch = qstr->at(qt_i).unicode();
+
+ if (uch > 0x00ff)
+ {
+ maxchar = 0xffff;
+ }
+ else if (uch > 0x007f)
+ {
+ maxchar = 0x00ff;
+ }
+ }
+
+ // Create the correctly sized object.
+ if ((obj = PyUnicode_New(qt_len, maxchar)) == NULL)
+ return NULL;
+
+ int kind = PyUnicode_KIND(obj);
+ void *data = PyUnicode_DATA(obj);
+
+ for (int qt_i = 0; qt_i < qt_len; ++qt_i)
+ {
+ Py_UCS4 uch = qstr->at(qt_i).unicode();
+ PyUnicode_WRITE(kind, data, qt_i, uch);
+ }
+#elif defined(Py_UNICODE_WIDE)
+ // Note that this doesn't handle code points greater than 0xffff. It could
+ // but it's only an issue for old versions of Qt.
+
+ if ((obj = PyUnicode_FromUnicode(NULL, qstr->length())) == NULL)
+ return NULL;
+
+ Py_UNICODE *pyu = PyUnicode_AS_UNICODE(obj);
+
+ for (unsigned int i = 0; i < qstr->length(); ++i)
+ *pyu++ = (qstr->at(i)).unicode();
+#else
+ if ((obj = PyUnicode_FromUnicode(NULL, qstr->length())) == NULL)
+ return NULL;
+
+ memcpy(PyUnicode_AS_UNICODE(obj), qstr->ucs2(),
+ qstr->length() * sizeof (Py_UNICODE));
+#endif
+
+ return obj;
+}
%End
-public:
- TQString();
- TQString(int);
- TQString(const TQString &);
- TQString(const char *);
- TQString(const char *,uint);
- bool isNull() const;
- bool isEmpty() const;
- uint length() const;
- bool resize(uint);
- bool truncate(uint);
- bool fill(char,int = -1);
- TQString copy() const;
-// TQString &sprintf(const char *,...);
- int find(char,int = 0,bool = 1) const;
- int find(const char *,int = 0,bool = 1) const;
- int find(const TQRegExp &,int = 0) const;
- int findRev(char,int = -1,bool = 1) const;
- int findRev(const char *,int = -1,bool = 1) const;
- int findRev(const TQRegExp &,int = -1) const;
- int contains(char,bool = 1) const;
- int contains(const char *,bool = 1) const;
- int contains(const TQRegExp &) const;
- TQString left(uint) const;
- TQString right(uint) const;
- TQString mid(uint,uint) const;
- TQString leftJustify(uint,char = ' ',bool = 0) const;
- TQString rightJustify(uint,char = ' ',bool = 0) const;
- TQString lower() const;
- TQString upper() const;
- TQString stripWhiteSpace() const;
- TQString simplifyWhiteSpace() const;
- TQString &insert(uint,const char *);
- TQString &insert(uint,char);
- TQString &append(const char *);
- TQString &prepend(const char *);
- TQString &remove(uint,uint);
- TQString &replace(uint,uint,const char *);
- TQString &replace(const TQRegExp &,const char *);
-
- short toShort(bool * = 0) const;
- ushort toUShort(bool * = 0) const;
- int toInt(bool * = 0) const;
- uint toUInt(bool * = 0) const;
- long toLong(bool * = 0) const;
- ulong toULong(bool * = 0) const;
- float toFloat(bool * = 0) const;
- double toDouble(bool * = 0) const;
+%ModuleHeaderCode
+extern TQString *PyTQt_qt_PyObject_AsTQString(PyObject *obj);
+%End
- TQString &setStr(const char *);
-// TQString &setNum(short);
-// TQString &setNum(ushort);
- TQString &setNum(int /Constrained/);
-// TQString &setNum(uint);
-// TQString &setNum(long);
-// TQString &setNum(ulong);
-// TQString &setNum(float,char = 'g',int = 6);
- TQString &setNum(double,char = 'g',int = 6);
- bool setExpand(uint,char);
+%ModuleCode
+// Convert a Python Unicode object to a QString.
+TQString *PyTQt_qt_PyObject_AsTQString(PyObject *obj)
+{
+ if (PyUnicode_Check(obj))
+ {
+#if PY_VERSION_HEX >= 0x03030000
+ SIP_SSIZE_T len = PyUnicode_GET_LENGTH(obj);
- SIP_PYOBJECT __str__();
-%MethodCode
- const char *s;
+ switch (PyUnicode_KIND(obj))
+ {
+ case PyUnicode_1BYTE_KIND:
+ return new TQString(TQString::fromLatin1((char *)PyUnicode_1BYTE_DATA(obj), len));
- Py_BEGIN_ALLOW_THREADS
- s = *sipCpp;
- Py_END_ALLOW_THREADS
+ case PyUnicode_2BYTE_KIND:
+ // The (TQChar *) cast should be safe.
+ return new TQString((TQChar *)PyUnicode_2BYTE_DATA(obj), len);
- if (s == NULL)
- s = "";
+ case PyUnicode_4BYTE_KIND:
+ // Note that this doesn't handle code points greater than 0xffff. It
+ // could but it's only an issue for old versions of Qt.
- sipRes = PyString_FromString(s);
-%End
+ TQString *qstr = new TQString;
-%ConvertToTypeCode
- // Allow a Python string whenever a TQString is expected.
+ Py_UCS4 *ucode = PyUnicode_4BYTE_DATA(obj);
- if (sipIsErr == NULL)
- return (PyString_Check(sipPy) ||
- sipCanConvertToInstance(sipPy,sipClass_TQString,SIP_NO_CONVERTORS));
+ for (SIP_SSIZE_T i = 0; i < len; ++i)
+ qstr->append(TQChar((uint)ucode[i]));
- if (PyString_Check(sipPy))
- {
- *sipCppPtr = new TQString(PyString_AS_STRING(sipPy));
+ return qstr;
+ }
- return sipGetState(sipTransferObj);
- }
+ return NULL;
+#else
+ TQString *qstr = new TQString;
- *sipCppPtr = reinterpret_cast<TQString *>(sipConvertToInstance(sipPy,sipClass_TQString,sipTransferObj,SIP_NO_CONVERTORS,0,sipIsErr));
+# ifdef Py_UNICODE_WIDE
+ Py_UNICODE *ucode = PyUnicode_AS_UNICODE(obj);
+ SIP_SSIZE_T len = PyUnicode_GET_SIZE(obj);
- return 0;
+ for (SIP_SSIZE_T i = 0; i < len; ++i)
+ qstr->append(TQChar((uint)ucode[i]));
+# else
+ qstr->setUnicodeCodes((ushort *)PyUnicode_AS_UNICODE(obj),PyUnicode_GET_SIZE(obj));
+# endif
+
+ return qstr;
+#endif
+ }
+ else if (PyBytes_Check(obj))
+ {
+ return new TQString(SIPBytes_AS_STRING(obj));
+ }
+#if PY_MAJOR_VERSION < 3
+ else if (PyString_Check(obj))
+ {
+ return new TQString(PyString_AS_STRING(obj));
+ }
+#endif
+
+ return NULL;
+}
+%End
+
+
+%ModuleHeaderCode
+extern const char *PyTQt_qt_encode(PyObject **s, TQApplication::Encoding encoding);
%End
-};
+%ModuleCode
+// Convert a Python unicode/string/bytes object to a character string encoded
+// according to the given encoding. Update the object with a new reference to
+// the object that owns the data.
+const char *PyTQt_qt_encode(PyObject **s, TQApplication::Encoding encoding)
+{
+ PyObject *obj = *s;
+ const char *es = 0;
+ SIP_SSIZE_T sz;
+
+ if (PyUnicode_Check(obj))
+ {
+ if (encoding == TQApplication::UnicodeUTF8)
+ {
+ obj = PyUnicode_AsUTF8String(obj);
+ }
+ else
+ {
+ TQTextCodec *codec = TQTextCodec::codecForTr();
+
+ if (codec)
+ {
+ // Use the Qt codec to get to a byte string, and then to a
+ // Python object.
+ TQString *qstr = PyTQt_qt_PyObject_AsTQString(obj);
+ TQString qs = *qstr;
+ TQByteArray ba = codec->fromUnicode(qs);
+ delete qstr;
+
+#if PY_MAJOR_VERSION >= 3
+ obj = PyBytes_FromStringAndSize(ba.data(), ba.size());
+#else
+ obj = PyString_FromStringAndSize(ba.data(), ba.size());
+#endif
+ }
+ else
+ {
+ obj = PyUnicode_AsLatin1String(obj);
+ }
+ }
+
+ if (obj)
+ {
+#if PY_MAJOR_VERSION >= 3
+ es = PyBytes_AS_STRING(obj);
+#else
+ es = PyString_AS_STRING(obj);
+#endif
+ }
+ }
+#if PY_MAJOR_VERSION >= 3
+ else if (PyBytes_Check(obj))
+ {
+ es = PyBytes_AS_STRING(obj);
+ Py_INCREF(obj);
+ }
+#else
+ else if (PyString_Check(obj))
+ {
+ es = PyString_AS_STRING(obj);
+ Py_INCREF(obj);
+ }
+#endif
+ else if (PyObject_AsCharBuffer(obj, &es, &sz) >= 0)
+ {
+ Py_INCREF(obj);
+ }
+
+ if (es)
+ {
+ *s = obj;
+ }
+ else
+ {
+ PyErr_Format(PyExc_UnicodeEncodeError,
+ "unable to convert '%s' to requested encoding",
+ Py_TYPE(*s)->tp_name);
+ }
+
+ return es;
+}
%End
diff --git a/sip/qt/qstringlist.sip b/sip/qt/qstringlist.sip
index 23ef47b..ead39dc 100644
--- a/sip/qt/qstringlist.sip
+++ b/sip/qt/qstringlist.sip
@@ -188,7 +188,7 @@ public:
sipRes = new TQString((*sipCpp)[a0]);
%End
- TQStringList operator[](SIP_PYSLICE);
+ TQStringList operator[](SIP_PYSLICE slice);
%MethodCode
#if PY_VERSION_HEX >= 0x02050000
Py_ssize_t len, start, stop, step, slicelength, i;
diff --git a/sip/qt/qstrlist.sip b/sip/qt/qstrlist.sip
index 0fd3976..695c872 100644
--- a/sip/qt/qstrlist.sip
+++ b/sip/qt/qstrlist.sip
@@ -57,7 +57,7 @@ is used instead.
{
PyObject *ps;
- if ((ps = PyString_FromString(s)) == NULL || PyList_SetItem(l,i,ps) < 0)
+ if ((ps = SIPBytes_FromString(s)) == NULL || PyList_SetItem(l,i,ps) < 0)
{
Py_XDECREF(ps);
Py_DECREF(l);
@@ -80,13 +80,17 @@ is used instead.
for (int i = 0; i < PyList_GET_SIZE(sipPy); ++i)
{
+ PyObject *object = PyList_GET_ITEM(sipPy, i);
char *s;
- if ((s = PyString_AsString(PyList_GET_ITEM(sipPy,i))) == NULL)
+ if (PyUnicode_Check(object))
+ {
+ s = tqstrdup(sipString_AsLatin1String(&object));
+ }
+ else if ((s = (char *)sipBytes_AsString(object)) == NULL)
{
*sipIsErr = 1;
delete qsl;
-
return 0;
}
diff --git a/sip/qt/qvaluelist.sip b/sip/qt/qvaluelist.sip
index e64fb30..e2a1d9b 100644
--- a/sip/qt/qvaluelist.sip
+++ b/sip/qt/qvaluelist.sip
@@ -139,7 +139,7 @@ template<Type>
// Get it.
for (uint i = 0; i < sipCpp -> count(); ++i)
- if (PyList_SetItem(l,i,PyInt_FromLong((long)(*sipCpp)[i])) < 0)
+ if (PyList_SetItem(l,i,PyLong_FromLong((long)(*sipCpp)[i])) < 0)
{
Py_DECREF(l);
@@ -161,7 +161,7 @@ template<Type>
for (int i = 0; i < PyList_GET_SIZE(sipPy); ++i)
{
- qvl -> append((int)PyInt_AsLong(PyList_GET_ITEM(sipPy,i)));
+ qvl -> append(PyLong_AsLong(PyList_GET_ITEM(sipPy,i)));
if (PyErr_Occurred() != NULL)
{
diff --git a/sip/qtnetwork/qftp.sip b/sip/qtnetwork/qftp.sip
index e5f46d8..94aed30 100644
--- a/sip/qtnetwork/qftp.sip
+++ b/sip/qtnetwork/qftp.sip
@@ -130,7 +130,7 @@ public:
Py_INCREF(Py_None);
sipRes = Py_None;
}
- else if ((sipRes = PyString_FromStringAndSize(buf,actlen)) == NULL)
+ else if ((sipRes = SIPBytes_FromStringAndSize(buf,actlen)) == NULL)
sipIsErr = 1;
sipFree((void *)buf);
diff --git a/sip/qtnetwork/qhttp.sip b/sip/qtnetwork/qhttp.sip
index 8fbeae7..4762c30 100644
--- a/sip/qtnetwork/qhttp.sip
+++ b/sip/qtnetwork/qhttp.sip
@@ -226,7 +226,7 @@ public:
Py_INCREF(Py_None);
sipRes = Py_None;
}
- else if ((sipRes = PyString_FromStringAndSize(buf,actlen)) == NULL)
+ else if ((sipRes = SIPBytes_FromStringAndSize(buf,actlen)) == NULL)
sipIsErr = 1;
sipFree((void *)buf);
diff --git a/sip/qtnetwork/qsocket.sip b/sip/qtnetwork/qsocket.sip
index 077443e..b97f243 100644
--- a/sip/qtnetwork/qsocket.sip
+++ b/sip/qtnetwork/qsocket.sip
@@ -194,7 +194,7 @@ public:
}
else
{
- sipRes = PyString_FromStringAndSize(buf,actlen);
+ sipRes = SIPBytes_FromStringAndSize(buf,actlen);
sipFree((void *)buf);
@@ -229,7 +229,7 @@ public:
}
else
{
- sipRes = PyString_FromStringAndSize(buf,actlen);
+ sipRes = SIPBytes_FromStringAndSize(buf,actlen);
sipFree((void *)buf);
@@ -263,7 +263,7 @@ public:
}
else
{
- sipRes = PyString_FromStringAndSize(buf,actlen);
+ sipRes = SIPBytes_FromStringAndSize(buf,actlen);
sipFree((void *)buf);
@@ -299,7 +299,7 @@ public:
}
else
{
- sipRes = PyString_FromStringAndSize(buf,actlen);
+ sipRes = SIPBytes_FromStringAndSize(buf,actlen);
sipFree((void *)buf);
diff --git a/sip/qtnetwork/qsocketdevice.sip b/sip/qtnetwork/qsocketdevice.sip
index 41da2f5..bbaa008 100644
--- a/sip/qtnetwork/qsocketdevice.sip
+++ b/sip/qtnetwork/qsocketdevice.sip
@@ -145,7 +145,7 @@ public:
Py_INCREF(Py_None);
sipRes = Py_None;
}
- else if ((sipRes = PyString_FromStringAndSize(buf,actlen)) == NULL)
+ else if ((sipRes = SIPBytes_FromStringAndSize(buf,actlen)) == NULL)
sipIsErr = 1;
sipFree((void *)buf);
@@ -176,7 +176,7 @@ public:
Py_INCREF(Py_None);
sipRes = Py_None;
}
- else if ((sipRes = PyString_FromStringAndSize(buf,actlen)) == NULL)
+ else if ((sipRes = SIPBytes_FromStringAndSize(buf,actlen)) == NULL)
sipIsErr = 1;
sipFree((void *)buf);
diff --git a/sip/qtpe/qpeapplication.sip b/sip/qtpe/qpeapplication.sip
index 5b76b22..9e6b99b 100644
--- a/sip/qtpe/qpeapplication.sip
+++ b/sip/qtpe/qpeapplication.sip
@@ -186,7 +186,7 @@ static char **pyArgvToC(PyObject *argvlist,int *argcp)
char *arg;
// Get the argument and allocate memory for it.
- if ((arg = PyString_AsString(PyList_GetItem(argvlist,a))) == NULL ||
+ if ((arg = (char *)sipBytes_AsString(PyList_GetItem(argvlist,a))) == NULL ||
(argv[a] = (char *)sipMalloc(strlen(arg) + 1)) == NULL)
return NULL;