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>
pull/7/head
aneejit1 2 years ago committed by Slávek Banko
parent 63fe0b82b4
commit 6be0466422
No known key found for this signature in database
GPG Key ID: 608F5293A04BE668

@ -37,8 +37,8 @@ import string
try: try:
import sip_tqt_config import sip_tqt_config
except: except:
print "Unable to import the sip_tqt_config module. Please make sure you have" print("Unable to import the sip_tqt_config module. Please make sure you have")
print "SIP-TQt v3.9 or later installed." print("SIP-TQt v3.9 or later installed.")
sys.exit(1) sys.exit(1)
config = sip_tqt_config.SIPConfig("PyTQt 3.18.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. rcode is the return code passed back to the calling process.
""" """
print "Usage:" 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(" %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("where:")
print " -h display this help message" print(" -h display this help message")
print " -a tag explicitly enable the qtpe module" 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(" -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(" -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(" -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(" -g always release the GIL (SIP-TQt v3.x behaviour)")
print " -j # split the concatenated C++ source files into # pieces [default 1]" 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(" -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(" -o dir the directory containing the TQScintilla library [default %s]" % config.qt_lib_dir)
print " -r generate code with tracing enabled [default disabled]" 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(" -v dir where the PyTQt .sip files will be installed [default %s]" % config.default_sip_dir)
sys.exit(rcode) sys.exit(rcode)
@ -439,7 +439,7 @@ def versionToTag(vers, tags, desc):
""" """
tag = None tag = None
vl = tags.keys() vl = list(tags.keys())
vl.sort() vl.sort()
# For a snapshot use the latest tag. # For a snapshot use the latest tag.
@ -723,8 +723,7 @@ if __name__ == "__main__":
except SystemExit: except SystemExit:
raise raise
except: except:
print \ print("""An internal error occured. Please report all the output from the program,
"""An internal error occured. Please report all the output from the program,
including the following traceback, to support@riverbankcomputing.co.uk. including the following traceback, to support@riverbankcomputing.co.uk.
""" """)
raise raise

@ -85,6 +85,7 @@ opt_split = 1
opt_tracing = 0 opt_tracing = 0
opt_verbose = 0 opt_verbose = 0
opt_keepfeatures = 0 opt_keepfeatures = 0
opt_accept_license = 0
opt_vendorcheck = 0 opt_vendorcheck = 0
opt_vendincdir = sipcfg.py_inc_dir 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(" -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(" -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(" -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) 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("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("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: 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 modules will be installed in %s." % opt_pyqtmoddir)
sip_tqt_config.inform("The PyTQt .sip files will be installed in %s." % opt_pyqtsipdir) 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 # If we find a snapshot then set a negative version number as a
# special case. # special case.
if string.find(sciversstr, "snapshot") >= 0: if sciversstr.find("snapshot") >= 0:
qsci_version = -1 qsci_version = -1
else: 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) 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() line = ff.readline()
while line: while line:
flags.extend(string.split(line)) flags.extend(line.split())
line = ff.readline() line = ff.readline()
if sipcfg.sip_version >= 0x040702: 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")) argv.append(os.path.join(src_dir, "sip"))
# SIP-TQt assumes POSIX style path separators. # 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. # Check the result.
if not os.access(buildfile, os.F_OK): if not os.access(buildfile, os.F_OK):
@ -1005,7 +1007,7 @@ def check_license():
lname = "GNU General Public License" lname = "GNU General Public License"
lfile = None 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. # Common checks.
if ltype == "GPL" and sys.platform == "win32": if ltype == "GPL" and sys.platform == "win32":
@ -1029,12 +1031,17 @@ Type 'no' to decline the terms of the license.
""") """)
while 1: while 1:
sys.stdout.write("Do you accept the terms of the license? ")
sys.stdout.flush()
try: try:
resp = raw_input("Do you accept the terms of the license? ") resp = sys.stdin.readline()
except KeyboardInterrupt:
raise SystemExit
except: except:
resp = "" resp = ""
resp = string.lower(string.strip(resp)) resp = resp.strip().lower()
if resp == "yes": if resp == "yes":
break break
@ -1060,7 +1067,7 @@ def get_build_macros(overrides):
overrides is a list of macros overrides from the user. overrides is a list of macros overrides from the user.
""" """
# Get the name of the qmake configuration file to take the macros from. # 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") fname = os.path.join(qt_dir, "mkspecs", os.environ["QMAKESPEC"], "qmake.conf")
else: else:
fname = os.path.join(qt_dir, "mkspecs", "default", "qmake.conf") 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) 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. # 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("INCDIR_TQT")
names.append("LIBDIR_TQT") names.append("LIBDIR_TQT")
names.append("MOC") names.append("MOC")
@ -1163,7 +1170,7 @@ def check_qt_installation(macros):
l = f.readline() l = f.readline()
while l: while l:
wl = string.split(l) wl = l.split()
if len(wl) == 3 and wl[0] == "#define" and wl[1] == "QT_PRODUCT_LICENSE": if len(wl) == 3 and wl[0] == "#define" and wl[1] == "QT_PRODUCT_LICENSE":
qt_edition = wl[2][4:-1] qt_edition = wl[2][4:-1]
break break
@ -1193,7 +1200,7 @@ def check_qt_installation(macros):
cfg = f.readline() cfg = f.readline()
f.close() f.close()
val = string.find(cfg, "=") val = cfg.find("=")
if val >= 0: if val >= 0:
qt_winconfig = string.strip(cfg[val + 1:]) 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) sip_tqt_config.error("No TQt libraries could be found in %s." % qt_libdir)
if len(names) > 1: 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): def is_qt_library(generator, lib):
@ -1320,10 +1327,6 @@ def main(argv):
argv is the list of command line arguments. 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. # Check SIP-TQt is new enough.
if sipcfg.sip_version_str[:8] != "snapshot": if sipcfg.sip_version_str[:8] != "snapshot":
if sipcfg.sip_version < sip_min_version: if sipcfg.sip_version < sip_min_version:
@ -1331,7 +1334,7 @@ def main(argv):
# Parse the command line. # Parse the command line.
try: 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: except getopt.GetoptError:
usage() usage()
@ -1342,6 +1345,7 @@ def main(argv):
global opt_qsciincdir, opt_qscilibdir, qsci_define global opt_qsciincdir, opt_qscilibdir, qsci_define
global opt_vendorcheck, opt_vendincdir, opt_vendlibdir global opt_vendorcheck, opt_vendincdir, opt_vendlibdir
global opt_libpython global opt_libpython
global opt_accept_license
opt_libpython = None opt_libpython = None
@ -1396,6 +1400,8 @@ def main(argv):
opt_tqtlib = arg opt_tqtlib = arg
else: else:
usage() usage()
elif opt == "-z":
opt_accept_license = 1
# Check that we know the name of the TQt root directory. # Check that we know the name of the TQt root directory.
if not qt_dir: if not qt_dir:
@ -1418,7 +1424,10 @@ def main(argv):
check_qt_installation(macros) check_qt_installation(macros)
# Check the licenses are compatible. # 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 for TQScintilla.
check_qscintilla() check_qscintilla()

@ -8,7 +8,7 @@ def TQMIN(x, y):
return x return x
class AnalogClock(TQWidget): class AnalogClock(TQWidget):
def __init__(self, *args): def __init__(self, *args):
apply(TQWidget.__init__,(self,) + args) TQWidget.__init__(*(self,) + args)
self.time = TQTime.currentTime() self.time = TQTime.currentTime()
internalTimer = TQTimer(self) internalTimer = TQTimer(self)
self.connect(internalTimer, SIGNAL("timeout()"), self.timeout) self.connect(internalTimer, SIGNAL("timeout()"), self.timeout)

@ -78,7 +78,7 @@ fileprint = [
class ABCentralWidget( TQWidget ): class ABCentralWidget( TQWidget ):
def __init__( self, *args ): def __init__( self, *args ):
apply( TQWidget.__init__, (self, ) + args ) TQWidget.__init__(*(self, ) + args)
self.mainGrid = TQGridLayout( self, 2, 1, 5, 5 ) self.mainGrid = TQGridLayout( self, 2, 1, 5, 5 )
self.setupTabWidget() self.setupTabWidget()

@ -179,7 +179,7 @@ class ApplicationWindow(TQMainWindow):
return return
for l in f.readlines(): for l in f.readlines():
self.e.append(string.rstrip(l)) self.e.append(l.rstrip())
f.close() f.close()

@ -21,7 +21,7 @@ FALSE = 0
class ButtonsGroups( TQWidget ): class ButtonsGroups( TQWidget ):
def __init__( self, *args ): def __init__( self, *args ):
apply( TQWidget.__init__, (self,) + args ) TQWidget.__init__(*(self,) + args)
# Create Widgets which allow easy layouting # Create Widgets which allow easy layouting
self.vbox = TQVBoxLayout( self ) self.vbox = TQVBoxLayout( self )

@ -47,7 +47,7 @@ class DigitalClock(TQLCDNumber):
s[2] = ' ' s[2] = ' '
if s[0] == '0': if s[0] == '0':
s[0] = ' ' s[0] = ' '
s = string.join(s,'') s = ''.join(s)
self.display(s) self.display(s)
a = TQApplication(sys.argv) a = TQApplication(sys.argv)

@ -26,7 +26,7 @@ maxcurves = 8
def poly(): def poly():
d = TQApplication.desktop() d = TQApplication.desktop()
d.setBackgroundColor(white) d.setPaletteBackgroundColor(white)
xvel = [ 0 ] * 8 xvel = [ 0 ] * 8
yvel = [ 0 ] * 8 yvel = [ 0 ] * 8
head = 0 head = 0
@ -65,16 +65,16 @@ def poly():
y = y + yvel[i] y = y + yvel[i]
if x >= maxx: if x >= maxx:
x = maxx - (x - maxx + 1) x = maxx - (x - maxx + 1)
xvel[i] = -velocity(i) xvel[i] = -velocity(i)
if x <= minx: if x <= minx:
x = minx + (minx - x + 1) x = minx + (minx - x + 1)
xvel[i] = velocity(i) xvel[i] = velocity(i)
if y >= maxy: if y >= maxy:
y = maxy - (y - maxy + 1) y = maxy - (y - maxy + 1)
yvel[i] = -velocity(i) yvel[i] = -velocity(i)
if y <= miny: if y <= miny:
y = miny + (miny - y + 1) y = miny + (miny - y + 1)
yvel[i] = velocity(i) yvel[i] = velocity(i)
a[head].setPoint(i, x, y) a[head].setPoint(i, x, y)
paint.end() paint.end()
@ -98,7 +98,7 @@ def rotate():
m = TQWMatrix() m = TQWMatrix()
m.rotate(i) m.rotate(i)
rpm = pm.xForm(m) rpm = pm.xForm(m)
d.setBackgroundPixmap(rpm) d.setPaletteBackgroundPixmap(rpm)
d.update() d.update()
def generateStone(pm, c1, c2, c3): def generateStone(pm, c1, c2, c3):
@ -142,7 +142,7 @@ class DesktopWidget(TQWidget):
if not self.pm: if not self.pm:
self.pm = TQPixmap(64, 64) self.pm = TQPixmap(64, 64)
generateStone(self.pm, c1, c2, c3) generateStone(self.pm, c1, c2, c3)
self.setBackgroundPixmap(self.pm) self.setPaletteBackgroundPixmap(self.pm)
self.update() self.update()
br = self.fontMetrics().boundingRect(self.text) br = self.fontMetrics().boundingRect(self.text)
offscreen = TQPixmap(br.width(), br.height()) 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) drawShadeText(p, -r.x()+border, -r.y()+border, s, c2, c3)
p.end() p.end()
tqApp.desktop().setBackgroundPixmap(pm) tqApp.desktop().setPaletteBackgroundPixmap(pm)
a = TQApplication(sys.argv) a = TQApplication(sys.argv)
if len(sys.argv) > 1: if len(sys.argv) > 1:

@ -5,7 +5,7 @@ from python_tqt.qt import *
class Directory(TQListViewItem): class Directory(TQListViewItem):
def __init__(self, parent, name=None): def __init__(self, parent, name=None):
apply(TQListViewItem.__init__,(self,parent)) TQListViewItem.__init__(*(self,parent))
if isinstance(parent, TQListView): if isinstance(parent, TQListView):
self.p = None self.p = None
self.f = '/' self.f = '/'

@ -49,15 +49,15 @@ class DropSite(TQLabel):
t += str(e.format( i )) t += str(e.format( i ))
i += 1 i += 1
self.emit(PYSIGNAL('message(TQString &)'), (TQString(t),)) self.emit(PYSIGNAL('message(TQString &)'), (TQString(t),))
self.setBackgroundColor(TQt.white) self.setPaletteBackgroundColor(TQt.white)
def dragLeaveEvent( self, TQDragLeaveEvent ): def dragLeaveEvent( self, TQDragLeaveEvent ):
# Give the user some feedback... # Give the user some feedback...
self.emit(PYSIGNAL('message(TQString &)'), (TQString(''),)) self.emit(PYSIGNAL('message(TQString &)'), (TQString(''),))
self.setBackgroundColor(TQt.lightGray) self.setPaletteBackgroundColor(TQt.lightGray)
def dropEvent( self, e ): def dropEvent( self, e ):
self.setBackgroundColor(TQt.lightGray) self.setPaletteBackgroundColor(TQt.lightGray)
# Try to decode to the data you understand... # Try to decode to the data you understand...
str = TQString() str = TQString()
if ( TQTextDrag.decode( e, str ) ) : if ( TQTextDrag.decode( e, str ) ) :

@ -227,7 +227,7 @@ if __name__=='__main__':
app=TQApplication(sys.argv) app=TQApplication(sys.argv)
if not TQGLFormat.hasOpenGL(): if not TQGLFormat.hasOpenGL():
raise 'No TQt OpenGL support.' raise Exception('No TQt OpenGL support.')
widget=GearWidget() widget=GearWidget()
app.setMainWidget(widget) app.setMainWidget(widget)

@ -133,7 +133,7 @@ p4_xpm = [
class MenuExample( TQWidget ): class MenuExample( TQWidget ):
def __init__( self, parent=None, name=None ): 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.p1 = TQIconSet( TQPixmap ( p1_xpm ) )
self.p2 = TQIconSet( TQPixmap ( p2_xpm ) ) self.p2 = TQIconSet( TQPixmap ( p2_xpm ) )
self.p3 = TQIconSet( TQPixmap ( p3_xpm ) ) self.p3 = TQIconSet( TQPixmap ( p3_xpm ) )

@ -52,7 +52,7 @@ picture_xpm = [
class SecretSource(TQLabel): class SecretSource(TQLabel):
def __init__(self, secret, parent=None, name=None): def __init__(self, secret, parent=None, name=None):
TQLabel.__init__(self, "Secret", parent, name) TQLabel.__init__(self, "Secret", parent, name)
self.setBackgroundColor( TQt.blue.light() ) self.setPaletteBackgroundColor( TQt.blue.light() )
self.setFrameStyle( TQLabel.Box | TQLabel.Sunken ) self.setFrameStyle( TQLabel.Box | TQLabel.Sunken )
self.setMinimumHeight( self.sizeHint().height()*2 ) self.setMinimumHeight( self.sizeHint().height()*2 )
self.setAlignment( TQLabel.AlignCenter ) self.setAlignment( TQLabel.AlignCenter )

@ -9,7 +9,7 @@ import sys
try: try:
from python_tqt.qt import TQThread from python_tqt.qt import TQThread
except: except:
print "Thread support not enabled" print("Thread support not enabled")
sys.exit(1) sys.exit(1)
from python_tqt.qt import * from python_tqt.qt import *
@ -176,9 +176,9 @@ class SemaphoreExample(TQWidget):
self.mlineedit.append(s) self.mlineedit.append(s)
if s.latin1() == "Green!": if s.latin1() == "Green!":
self.label.setBackgroundColor(TQt.green) self.label.setPaletteBackgroundColor(TQt.green)
else: else:
self.label.setBackgroundColor(TQt.yellow) self.label.setPaletteBackgroundColor(TQt.yellow)
self.label.setText(s) self.label.setText(s)
@ -192,7 +192,7 @@ class SemaphoreExample(TQWidget):
del s del s
else: else:
print "Unknown custom event type:", event.type() print("Unknown custom event type:", event.type())
app = TQApplication(sys.argv) app = TQApplication(sys.argv)

@ -16,13 +16,13 @@ class Test(TQWidget):
y1 = 0 y1 = 0
y2 = self.height() - 1 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, 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)
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(x1, y, x1+d, y-d) p.drawLine(x1, y, x1+d, y-d)
p.drawLine(x2, y, x2-d, y+d) p.drawLine(x2, y, x2-d, y+d)
@ -36,25 +36,25 @@ if __name__=="__main__":
s2 = TQSplitter(TQt.Horizontal, s1, "top") s2 = TQSplitter(TQt.Horizontal, s1, "top")
t1 = Test(s2) t1 = Test(s2)
t1.setBackgroundColor(TQt.blue.light(180)) t1.setPaletteBackgroundColor(TQt.blue.light(180))
t1.setMinimumSize(50,0) t1.setMinimumSize(50,0)
t2 = Test(s2) t2 = Test(s2)
t2.setBackgroundColor(TQt.green.light(180)) t2.setPaletteBackgroundColor(TQt.green.light(180))
s2.setResizeMode(t2, TQSplitter.KeepSize) s2.setResizeMode(t2, TQSplitter.KeepSize)
s2.moveToFirst(t2) s2.moveToFirst(t2)
s3 = TQSplitter(TQt.Horizontal, s1, "bottom") s3 = TQSplitter(TQt.Horizontal, s1, "bottom")
t3 = Test(s3) t3 = Test(s3)
t3.setBackgroundColor(TQt.red) t3.setPaletteBackgroundColor(TQt.red)
t4 = Test(s3) t4 = Test(s3)
t4.setBackgroundColor(TQt.white) t4.setPaletteBackgroundColor(TQt.white)
t5 = Test(s3) t5 = Test(s3)
t5.setMaximumHeight(250) t5.setMaximumHeight(250)
t5.setMinimumSize(80,50) t5.setMinimumSize(80,50)
t5.setBackgroundColor(TQt.yellow) t5.setPaletteBackgroundColor(TQt.yellow)
s1.setOpaqueResize(1) s1.setOpaqueResize(1)
s2.setOpaqueResize(1) s2.setOpaqueResize(1)

@ -14,8 +14,8 @@ class Table(TQTableView):
self.setCellWidth(100) self.setCellWidth(100)
self.setCellHeight(30) self.setCellHeight(30)
self.setTableFlags(Tbl_vScrollBar | self.setTableFlags(Tbl_vScrollBar |
Tbl_hScrollBar | Tbl_hScrollBar |
Tbl_clipCellPainting) Tbl_clipCellPainting)
self.resize(400,200) self.resize(400,200)
self.contents = [''] * (numRows * numCols) self.contents = [''] * (numRows * numCols)
@ -64,27 +64,27 @@ class Table(TQTableView):
if key == Key_Left: if key == Key_Left:
if self.curCol > 0: if self.curCol > 0:
self.curCol = self.curCol - 1 self.curCol = self.curCol - 1
edge = self.leftCell() edge = self.leftCell()
if self.curCol < edge: if self.curCol < edge:
self.setLeftCell(edge-1) self.setLeftCell(edge-1)
elif key == Key_Right: elif key == Key_Right:
if self.curCol < self.numCols()-1: if self.curCol < self.numCols()-1:
self.curCol = self.curCol + 1 self.curCol = self.curCol + 1
edge = self.lastColVisible() edge = self.lastColVisible()
if self.curCol >= edge: if self.curCol >= edge:
self.setLeftCell(self.leftCell()+1) self.setLeftCell(self.leftCell()+1)
elif key == Key_Up: elif key == Key_Up:
if self.curRow > 0: if self.curRow > 0:
self.curRow = self.curRow - 1 self.curRow = self.curRow - 1
edge = self.topCell() edge = self.topCell()
if self.curRow < edge: if self.curRow < edge:
self.setTopCell(edge-1) self.setTopCell(edge-1)
elif key == Key_Down: elif key == Key_Down:
if self.curRow < self.numRows()-1: if self.curRow < self.numRows()-1:
self.curRow = self.curRow + 1 self.curRow = self.curRow + 1
edge = self.lastRowVisible() edge = self.lastRowVisible()
if self.curRow >= edge: if self.curRow >= edge:
self.setTopCell(self.topCell()+1) self.setTopCell(self.topCell()+1)
else: else:
ke.ignore() ke.ignore()
return return

@ -27,7 +27,7 @@ class LCDRange(TQVBox):
def setRange(self,minVal,maxVal): def setRange(self,minVal,maxVal):
if minVal < 0 or maxVal > 99 or 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) self.slider.setRange(minVal,maxVal)

@ -28,7 +28,7 @@ class LCDRange(TQVBox):
def setRange(self,minVal,maxVal): def setRange(self,minVal,maxVal):
if minVal < 0 or maxVal > 99 or 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) self.slider.setRange(minVal,maxVal)
@ -149,7 +149,7 @@ class CannonField(TQWidget):
y = y0 + vely * time - 0.5 * gravity * time * time y = y0 + vely * time - 0.5 * gravity * time * time
r = TQRect(0,0,6,6) 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 return r
def sizePolicy(self): def sizePolicy(self):

@ -36,7 +36,7 @@ class LCDRange(TQVBox):
def setRange(self,minVal,maxVal): def setRange(self,minVal,maxVal):
if minVal < 0 or maxVal > 99 or 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) self.slider.setRange(minVal,maxVal)
def text(self): def text(self):
@ -183,7 +183,7 @@ class CannonField(TQWidget):
y = y0 + vely * time - 0.5 * gravity * time * time y = y0 + vely * time - 0.5 * gravity * time * time
r = TQRect(0,0,6,6) 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 return r
def targetRect(self): def targetRect(self):

@ -41,7 +41,7 @@ class LCDRange(TQWidget):
def setRange(self,minVal,maxVal): def setRange(self,minVal,maxVal):
if minVal < 0 or maxVal > 99 or 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) self.slider.setRange(minVal,maxVal)
def text(self): def text(self):
@ -215,7 +215,7 @@ class CannonField(TQWidget):
y = y0 + vely * time - 0.5 * gravity * time * time y = y0 + vely * time - 0.5 * gravity * time * time
r = TQRect(0,0,6,6) 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 return r
def targetRect(self): def targetRect(self):

@ -41,7 +41,7 @@ class LCDRange(TQWidget):
def setRange(self,minVal,maxVal): def setRange(self,minVal,maxVal):
if minVal < 0 or maxVal > 99 or 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) self.slider.setRange(minVal,maxVal)
def text(self): def text(self):
@ -245,7 +245,7 @@ class CannonField(TQWidget):
y = y0 + vely * time - 0.5 * gravity * time * time y = y0 + vely * time - 0.5 * gravity * time * time
r = TQRect(0,0,6,6) 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 return r
def targetRect(self): def targetRect(self):

@ -27,7 +27,7 @@ class LCDRange(TQVBox):
def setRange(self,minVal,maxVal): def setRange(self,minVal,maxVal):
if minVal < 0 or maxVal > 99 or 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) self.slider.setRange(minVal,maxVal)

@ -27,7 +27,7 @@ class LCDRange(TQVBox):
def setRange(self,minVal,maxVal): def setRange(self,minVal,maxVal):
if minVal < 0 or maxVal > 99 or 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) self.slider.setRange(minVal,maxVal)

@ -18,7 +18,7 @@ def TQMIN( x, y ):
class AnalogClock( TQWidget ): class AnalogClock( TQWidget ):
def __init__( self, *args ): def __init__( self, *args ):
apply( TQWidget.__init__, (self,) + args ) TQWidget.__init__(*(self,) + args)
self.time = TQTime.currentTime() # get current time self.time = TQTime.currentTime() # get current time
internalTimer = TQTimer( self ) # create internal timer internalTimer = TQTimer( self ) # create internal timer
self.connect( internalTimer, SIGNAL("timeout()"), self.timeout ) self.connect( internalTimer, SIGNAL("timeout()"), self.timeout )
@ -74,7 +74,7 @@ class AnalogClock( TQWidget ):
class DigitalClock( TQLCDNumber ): class DigitalClock( TQLCDNumber ):
def __init__( self, *args ): def __init__( self, *args ):
apply( TQLCDNumber.__init__,(self,) + args ) TQLCDNumber.__init__(*(self,) + args)
self.showingColon = 0 self.showingColon = 0
self.setFrameStyle(TQFrame.Panel | TQFrame.Raised) self.setFrameStyle(TQFrame.Panel | TQFrame.Raised)
self.setLineWidth( 2 ) self.setLineWidth( 2 )
@ -112,7 +112,7 @@ class DigitalClock( TQLCDNumber ):
s[2] = ' ' s[2] = ' '
if s[0] == '0': if s[0] == '0':
s[0] = ' ' s[0] = ' '
s = string.join(s,'') s = ''.join(s)
self.display( s ) self.display( s )
def TQMIN( x, y ): def TQMIN( x, y ):
@ -130,7 +130,7 @@ MOVIEFILENAME = "trolltech.gif"
class WidgetView ( TQWidget ): class WidgetView ( TQWidget ):
def __init__( self, *args ): def __init__( self, *args ):
apply( TQWidget.__init__, (self,) + args ) TQWidget.__init__(*(self,) + args)
# Set the window caption/title # Set the window caption/title
self.setCaption( "TQt Widgets Demo Application" ) self.setCaption( "TQt Widgets Demo Application" )
@ -186,14 +186,14 @@ class WidgetView ( TQWidget ):
TQToolTip.add( self.dclock, "custom widget: digital clock" ) TQToolTip.add( self.dclock, "custom widget: digital clock" )
# Create a push button. # 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.setText( "Push button 1" )
self.pb.setFixedHeight( self.pb.sizeHint().height() ) self.pb.setFixedHeight( self.pb.sizeHint().height() )
self.grid.addWidget( self.pb, 0, 0, TQt.AlignVCenter ) self.grid.addWidget( self.pb, 0, 0, TQt.AlignVCenter )
self.connect( self.pb, SIGNAL("clicked()"), self.button1Clicked ) self.connect( self.pb, SIGNAL("clicked()"), self.button1Clicked )
TQToolTip.add( self.pb, "push button 1" ) TQToolTip.add( self.pb, "push button 1" )
self.pm = TQPixmap() 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: if not self.pix:
TQMessageBox.information( None, "TQt Widgets Example", TQMessageBox.information( None, "TQt Widgets Example",
"Could not load the file \"qt.png\", which\n" "Could not load the file \"qt.png\", which\n"
@ -224,7 +224,7 @@ class WidgetView ( TQWidget ):
self.vbox.addSpacing( self.bg.fontMetrics().height() ) 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] = TQCheckBox( self.bg )
self.cb[0].setText( "Read" ) self.cb[0].setText( "Read" )
self.vbox.addWidget( self.cb[0] ) self.vbox.addWidget( self.cb[0] )
@ -466,20 +466,20 @@ class WidgetView ( TQWidget ):
self.msg.setText( txt ) self.msg.setText( txt )
if index == 0: if index == 0:
TQApplication.setWinStyleHighlightColor( TQt.darkBlue ) TQApplication.setWinStyleHighlightColor( TQt.darkBlue )
elif index == 1: elif index == 1:
TQApplication.setWinStyleHighlightColor( TQt.darkRed ) TQApplication.setWinStyleHighlightColor( TQt.darkRed )
elif index == 2: elif index == 2:
TQApplication.setWinStyleHighlightColor( TQt.darkGreen ) TQApplication.setWinStyleHighlightColor( TQt.darkGreen )
elif index == 3: elif index == 3:
TQApplication.setWinStyleHighlightColor( TQt.blue ) TQApplication.setWinStyleHighlightColor( TQt.blue )
elif index == 4: elif index == 4:
TQApplication.setWinStyleHighlightColor( TQt.red ) TQApplication.setWinStyleHighlightColor( TQt.red )
def lineEditTextChanged( self, newText ): def lineEditTextChanged( self, newText ):
self.msg.setText("Line edit text: " + unicode(newText)) self.msg.setText("Line edit text: " + str(newText))
def spinBoxValueChanged( self, valueText ): 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. # All application events are passed throught this event filter.
# We're using it to display some information about a clicked # We're using it to display some information about a clicked
@ -496,10 +496,10 @@ class WidgetView ( TQWidget ):
# txt = txt + TQObject.name() # txt = txt + TQObject.name()
# else: # else:
# txt = txt + "<no name>" # 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 ) # TQMessageBox.message( "Identify Widget", txt, 0, TQObject )
# identify_now = TRUE; # allow it again # identify_now = TRUE; # allow it again
# return FALSE # don't eat event # return FALSE # don't eat event
################################################################################################ ################################################################################################

@ -14,7 +14,7 @@ def createConnection():
driver = DB_DRIVER driver = DB_DRIVER
# all qt examples use TQSqlDatabase::addDatabase, but # all qt examples use TQSqlDatabase::addDatabase, but
# this never returns NULL in my experience # this never returns NULL in my experience
drivers = map(str, TQSqlDatabase.drivers()) drivers = list(map(str, TQSqlDatabase.drivers()))
if driver in drivers: if driver in drivers:
dlg = dbConnect(driver) dlg = dbConnect(driver)
#TODO: make connection parameters accessible #TODO: make connection parameters accessible
@ -40,8 +40,8 @@ class dbConnect(frmConnect):
self.txtName.setText(self.username) self.txtName.setText(self.username)
self.txtPasswd.setText(self.password) self.txtPasswd.setText(self.password)
map(self.cmbServer.insertItem, self.hostnames) list(map(self.cmbServer.insertItem, self.hostnames))
map(self.cmbDatabase.insertItem, self.databases) list(map(self.cmbDatabase.insertItem, self.databases))
self.connect(self.buttonHelp, SIGNAL("clicked()"), self.connect(self.buttonHelp, SIGNAL("clicked()"),
self.buttonHelp_clicked) self.buttonHelp_clicked)
@ -77,6 +77,6 @@ class dbConnect(frmConnect):
if __name__ == "__main__": if __name__ == "__main__":
app = TQApplication(sys.argv) app = TQApplication(sys.argv)
if createConnection(): if createConnection():
print "ok" print("ok")
else: else:
print "cancel" print("cancel")

@ -31,7 +31,7 @@ class CustomTable(TQDataTable):
query = TQSqlQuery("SELECT name FROM prices WHERE id=%s" % query = TQSqlQuery("SELECT name FROM prices WHERE id=%s" %
field.value().toString()) field.value().toString())
value = "" value = ""
if query.next(): if next(query):
value = query.value(0).toString() value = query.value(0).toString()
p.drawText(2, 2, cr.width()-4, cr.height()-4, p.drawText(2, 2, cr.width()-4, cr.height()-4,
self.fieldAlignment(field), value) self.fieldAlignment(field), value)
@ -42,7 +42,7 @@ class CustomTable(TQDataTable):
v = field.value().toDouble() v = field.value().toDouble()
if v < 0: if v < 0:
p.setPen(TQColor("red")) 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, p.drawText(2, 2, cr.width()-6, cr.height()-4,
TQt.AlignRight|TQt.AlignVCenter, value) TQt.AlignRight|TQt.AlignVCenter, value)
elif fn == "paiddate": elif fn == "paiddate":
@ -74,17 +74,17 @@ class InvoiceItemCursor(TQSqlCursor):
if fn == "productname": if fn == "productname":
query = TQSqlQuery("SELECT name FROM prices WHERE id=%d;" % query = TQSqlQuery("SELECT name FROM prices WHERE id=%d;" %
(self.field("pricesid").value().toInt())) (self.field("pricesid").value().toInt()))
if query.next(): if next(query):
return query.value(0) return query.value(0)
elif fn == "price": elif fn == "price":
query = TQSqlQuery("SELECT price FROM prices WHERE id=%d;" % query = TQSqlQuery("SELECT price FROM prices WHERE id=%d;" %
(self.field("pricesid").value().toInt())) (self.field("pricesid").value().toInt()))
if query.next(): if next(query):
return query.value(0) return query.value(0)
elif fn == "cost": elif fn == "cost":
query = TQSqlQuery("SELECT price FROM prices WHERE id=%d;" % query = TQSqlQuery("SELECT price FROM prices WHERE id=%d;" %
(self.field("pricesid").value().toInt())) (self.field("pricesid").value().toInt()))
if query.next(): if next(query):
return TQVariant(query.value(0).toDouble() * return TQVariant(query.value(0).toDouble() *
self.value("quantity").toDouble()) self.value("quantity").toDouble())
return TQVariant(TQString.null) return TQVariant(TQString.null)
@ -102,7 +102,7 @@ class ProductPicker(TQComboBox):
TQComboBox.__init__(self, parent, name) TQComboBox.__init__(self, parent, name)
cur = TQSqlCursor("prices") cur = TQSqlCursor("prices")
cur.select(cur.index("id")) cur.select(cur.index("id"))
while cur.next(): while next(cur):
self.insertItem(cur.value("name").toString(), cur.value("id").toInt()) self.insertItem(cur.value("name").toString(), cur.value("id").toInt())

@ -31,7 +31,7 @@ class CustomTable(TQDataTable):
v = field.value().toDouble() v = field.value().toDouble()
if v < 0: if v < 0:
p.setPen(TQColor("red")) p.setPen(TQColor("red"))
value = TQString(u"%.2f \u20ac" % v) value = TQString("%.2f \u20ac" % v)
#print unicode(value).encode("iso-8859-15") #print unicode(value).encode("iso-8859-15")
p.drawText(2, 2, cr.width()-6, cr.height()-4, p.drawText(2, 2, cr.width()-6, cr.height()-4,
TQt.AlignRight|TQt.AlignVCenter, value) TQt.AlignRight|TQt.AlignVCenter, value)
@ -39,7 +39,7 @@ class CustomTable(TQDataTable):
query = TQSqlQuery("SELECT name FROM status WHERE id=%s" % query = TQSqlQuery("SELECT name FROM status WHERE id=%s" %
field.value().toString()) field.value().toString())
value = "" value = ""
if query.next(): if next(query):
value = query.value(0).toString() value = query.value(0).toString()
p.drawText(2, 2, cr.width()-4, cr.height()-4, p.drawText(2, 2, cr.width()-4, cr.height()-4,
self.fieldAlignment(field), value) self.fieldAlignment(field), value)
@ -52,7 +52,7 @@ class StatusPicker(TQComboBox):
TQComboBox.__init__(self, parent, name) TQComboBox.__init__(self, parent, name)
cur = TQSqlCursor("status") cur = TQSqlCursor("status")
cur.select(cur.index("id")) cur.select(cur.index("id"))
while cur.next(): while next(cur):
self.insertItem(cur.value("name").toString(), cur.value("id").toInt()) self.insertItem(cur.value("name").toString(), cur.value("id").toInt())

@ -8,7 +8,7 @@ def TQMIN(x, y):
return x return x
class AnalogClock(TQWidget): class AnalogClock(TQWidget):
def __init__(self, *args): def __init__(self, *args):
apply(TQWidget.__init__,(self,) + args) TQWidget.__init__(*(self,) + args)
self.time = TQTime.currentTime() self.time = TQTime.currentTime()
internalTimer = TQTimer(self) internalTimer = TQTimer(self)
self.connect(internalTimer, SIGNAL("timeout()"), self.timeout) self.connect(internalTimer, SIGNAL("timeout()"), self.timeout)

@ -78,7 +78,7 @@ fileprint = [
class ABCentralWidget( TQWidget ): class ABCentralWidget( TQWidget ):
def __init__( self, *args ): def __init__( self, *args ):
apply( TQWidget.__init__, (self, ) + args ) TQWidget.__init__(*(self, ) + args)
self.mainGrid = TQGridLayout( self, 2, 1, 5, 5 ) self.mainGrid = TQGridLayout( self, 2, 1, 5, 5 )
self.setupTabWidget() self.setupTabWidget()

@ -179,7 +179,7 @@ class ApplicationWindow(TQMainWindow):
return return
for l in f.readlines(): for l in f.readlines():
self.e.append(string.rstrip(l)) self.e.append(l.rstrip())
f.close() f.close()

@ -5,7 +5,7 @@ from python_tqt.qt import *
if TQT_VERSION < 0x030100: 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) sys.exit(1)

@ -21,7 +21,7 @@ FALSE = 0
class ButtonsGroups( TQWidget ): class ButtonsGroups( TQWidget ):
def __init__( self, *args ): def __init__( self, *args ):
apply( TQWidget.__init__, (self,) + args ) TQWidget.__init__(*(self,) + args)
# Create Widgets which allow easy layouting # Create Widgets which allow easy layouting
self.vbox = TQVBoxLayout( self, 11, 6 ) self.vbox = TQVBoxLayout( self, 11, 6 )

@ -9,27 +9,27 @@ TRUE = 1
FALSE = 0 FALSE = 0
class CheckLists(TQWidget): class CheckLists(TQWidget):
def __init__(self, *args): def __init__(self, *args):
apply( TQWidget.__init__, (self, ) + args ) TQWidget.__init__(* (self, ) + args )
lay = TQHBoxLayout(self) lay = TQHBoxLayout(self)
lay.setMargin(5) lay.setMargin(5)
vbox1 = TQVBoxLayout(lay) vbox1 = TQVBoxLayout(lay)
vbox1.setMargin(5) vbox1.setMargin(5)
# First child: a Label # First child: a Label
vbox1.addWidget(TQLabel("Check some items!", self)) vbox1.addWidget(TQLabel("Check some items!", self))
# Second child: the ListView # Second child: the ListView
self.lv1 = TQListView(self) self.lv1 = TQListView(self)
vbox1.addWidget(self.lv1) vbox1.addWidget(self.lv1)
self.lv1.addColumn("Items") self.lv1.addColumn("Items")
self.lv1.setRootIsDecorated(TRUE) 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 1" ) )
parentList.append( TQListViewItem( self.lv1, "Parent Item 2" ) ) parentList.append( TQListViewItem( self.lv1, "Parent Item 2" ) )
@ -91,7 +91,7 @@ class CheckLists(TQWidget):
self.label = TQLabel( "No Item yet...", self ) self.label = TQLabel( "No Item yet...", self )
tmp3.addWidget( self.label ) tmp3.addWidget( self.label )
def copy1to2(self): def copy1to2(self):
self.lv2.clear() self.lv2.clear()
# Insert first a controller Item into the second ListView. Always if Radio-ListViewItems # Insert first a controller Item into the second ListView. Always if Radio-ListViewItems

@ -18,33 +18,33 @@ cb_width = 32
cb_height = 32 cb_height = 32
# cursor bitmap # cursor bitmap
cb_bits = "\x00\x00\x00\x00\x00\x00\x00\x00\x00\xf8\x0f\x00" \ cb_bits = b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\xf8\x0f\x00" \
"\x00\x06\x30\x00\x80\x01\xc0\x00\x40\x00\x00\x01" \ b"\x00\x06\x30\x00\x80\x01\xc0\x00\x40\x00\x00\x01" \
"\x20\x00\x00\x02\x10\x00\x00\x04\x08\x3e\x3e\x08" \ b"\x20\x00\x00\x02\x10\x00\x00\x04\x08\x3e\x3e\x08" \
"\x08\x03\xe0\x08\xc4\x00\x00\x11\x04\x1e\x78\x10" \ b"\x08\x03\xe0\x08\xc4\x00\x00\x11\x04\x1e\x78\x10" \
"\x02\x0c\x30\x20\x02\x40\x00\x20\x02\x40\x00\x20" \ b"\x02\x0c\x30\x20\x02\x40\x00\x20\x02\x40\x00\x20" \
"\x02\x40\x00\x20\x02\x20\x04\x20\x02\x20\x04\x20" \ b"\x02\x40\x00\x20\x02\x20\x04\x20\x02\x20\x04\x20" \
"\x02\x10\x08\x20\x02\x08\x08\x20\x02\xf0\x07\x20" \ b"\x02\x10\x08\x20\x02\x08\x08\x20\x02\xf0\x07\x20" \
"\x04\x00\x00\x10\x04\x00\x00\x10\x08\x00\xc0\x08" \ b"\x04\x00\x00\x10\x04\x00\x00\x10\x08\x00\xc0\x08" \
"\x08\x3c\x30\x08\x10\xe6\x19\x04\x20\x00\x0f\x02" \ b"\x08\x3c\x30\x08\x10\xe6\x19\x04\x20\x00\x0f\x02" \
"\x40\x00\x00\x01\x80\x01\xc0\x00\x00\x06\x30\x00" \ b"\x40\x00\x00\x01\x80\x01\xc0\x00\x00\x06\x30\x00" \
"\x00\xf8\x0f\x00\x00\x00\x00\x00" b"\x00\xf8\x0f\x00\x00\x00\x00\x00"
cm_width = 32 cm_width = 32
cm_height = 32 cm_height = 32
# cursor bitmap mask # cursor bitmap mask
cm_bits = "\x00\x00\x00\x00\x00\xf8\x1f\x00\x00\xfe\x3f\x00" \ cm_bits = b"\x00\x00\x00\x00\x00\xf8\x1f\x00\x00\xfe\x3f\x00" \
"\x80\x07\xf0\x00\xc0\x01\xc0\x01\x60\x00\x00\x03" \ b"\x80\x07\xf0\x00\xc0\x01\xc0\x01\x60\x00\x00\x03" \
"\x30\x00\x00\x06\x18\x00\x00\x0c\x0c\x3e\x3e\x18" \ b"\x30\x00\x00\x06\x18\x00\x00\x0c\x0c\x3e\x3e\x18" \
"\x0e\x03\xe0\x18\xc6\x00\x00\x31\x07\x1e\x78\x30" \ b"\x0e\x03\xe0\x18\xc6\x00\x00\x31\x07\x1e\x78\x30" \
"\x03\x0c\x30\x60\x03\x40\x00\x60\x03\x40\x00\x60" \ b"\x03\x0c\x30\x60\x03\x40\x00\x60\x03\x40\x00\x60" \
"\x03\x40\x00\x60\x03\x20\x04\x60\x03\x20\x04\x60" \ b"\x03\x40\x00\x60\x03\x20\x04\x60\x03\x20\x04\x60" \
"\x03\x10\x08\x60\x03\x08\x08\x60\x03\xf0\x07\x60" \ b"\x03\x10\x08\x60\x03\x08\x08\x60\x03\xf0\x07\x60" \
"\x06\x00\x00\x30\x06\x00\x00\x30\x0c\x00\xc0\x18" \ b"\x06\x00\x00\x30\x06\x00\x00\x30\x0c\x00\xc0\x18" \
"\x0c\x3c\x30\x18\x18\xe6\x19\x0c\x30\x00\x0f\x06" \ b"\x0c\x3c\x30\x18\x18\xe6\x19\x0c\x30\x00\x0f\x06" \
"\x60\x00\x00\x03\xc0\x01\xc0\x01\x80\x07\xf0\x00" \ b"\x60\x00\x00\x03\xc0\x01\xc0\x01\x80\x07\xf0\x00" \
"\x00\xfe\x3f\x00\x00\xf8\x0f\x00" b"\x00\xfe\x3f\x00\x00\xf8\x0f\x00"
# The CursorView contains many labels with different cursors. # The CursorView contains many labels with different cursors.
class CursorView( TQWidget ): # cursor view class CursorView( TQWidget ): # cursor view

@ -47,7 +47,7 @@ class DigitalClock(TQLCDNumber):
s[2] = ' ' s[2] = ' '
if s[0] == '0': if s[0] == '0':
s[0] = ' ' s[0] = ' '
s = string.join(s,'') s = ''.join(s)
self.display(s) self.display(s)
a = TQApplication(sys.argv) a = TQApplication(sys.argv)

@ -220,11 +220,11 @@ if len(sys.argv) == 3:
validOptions = 0 validOptions = 0
if not validOptions: if not validOptions:
print """Usage: print("""Usage:
\tdesktop -poly \tdesktop -poly
\tdesktop -rotate \tdesktop -rotate
\tdesktop -troll \tdesktop -troll
\tdesktop -trollwidget \tdesktop -trollwidget
\tdesktop -shadetext <text> \tdesktop -shadetext <text>
\tdesktop -shadewidget <text>""" \tdesktop -shadewidget <text>""")
rotate() rotate()

@ -41,15 +41,15 @@ class FontRowTable( TQFrame ):
fm = self.fontMetrics() fm = self.fontMetrics()
ml = self.frameWidth() + self.margin() + 1 + max(0,-fm.minLeftBearing()) ml = self.frameWidth() + self.margin() + 1 + max(0,-fm.minLeftBearing())
mt = self.frameWidth() + self.margin() 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() : if not cell.width() or not cell.height() :
return return
mini = r.left() / cell.width() mini = int(r.left() / cell.width())
maxi = (r.right()+cell.width()-1) / cell.width() maxi = int((r.right()+cell.width()-1) / cell.width())
minj = r.top() / cell.height() minj = int(r.top() / cell.height())
maxj = (r.bottom()+cell.height()-1) / cell.height() maxj = int((r.bottom()+cell.height()-1) / cell.height())
h = fm.height() h = fm.height()
@ -83,13 +83,13 @@ class FontRowTable( TQFrame ):
else: sign = positive else: sign = positive
if l > 0: lsign = 0 if l > 0: lsign = 0
else: lsign = 1 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 :
if r < 0: sign = rnegative if r < 0: sign = rnegative
else: sign = rpositive else: sign = rpositive
if r > 0: rsign = r if r > 0: rsign = r
else: rsign = 0 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 ) s = TQString( ch )
p.setPen(TQPen(TQt.black)) p.setPen(TQPen(TQt.black))
p.drawText(x,y,s) p.drawText(x,y,s)

@ -19,10 +19,8 @@ class Viewer( TQWidget ):
self.setFontSubstitutions() self.setFontSubstitutions()
#greeting_heb = TQString.fromUtf8( "\327\251\327\234\327\225\327\235" ) greeting_heb = TQString.fromUtf8( b"\327\251\327\234\327\225\327\235" )
greeting_heb = unicode( '\327\251\327\234\327\225\327\235','utf8' ) 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_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_en = "Hello" greeting_en = "Hello"
self.greetings = TQTextView( self, "textview" ) self.greetings = TQTextView( self, "textview" )

@ -227,7 +227,7 @@ if __name__=='__main__':
app=TQApplication(sys.argv) app=TQApplication(sys.argv)
if not TQGLFormat.hasOpenGL(): if not TQGLFormat.hasOpenGL():
raise 'No TQt OpenGL support.' raise Exception('No TQt OpenGL support.')
widget=GearWidget() widget=GearWidget()
app.setMainWidget(widget) app.setMainWidget(widget)

@ -80,7 +80,7 @@ def showLang(lang):
translator.load(language,".") translator.load(language,".")
tqApp.installTranslator(translator) tqApp.installTranslator(translator)
m = MyWidget() m = MyWidget()
m.setCaption("PyTQt Example - i18n - " + unicode(m.caption())) m.setCaption("PyTQt Example - i18n - " + str(m.caption()))
wlist.append(m) wlist.append(m)
return m return m

@ -77,12 +77,12 @@ fileprint = [
document = [ document = [
"12 16 6 1", "12 16 6 1",
" c #040404", " c #040404",
". c None", ". c None",
"X c white", "X c white",
"o c #808304", "o c #808304",
"O c black", "O c black",
"+ c #f3f7f3", "+ c #f3f7f3",
" .....", " .....",
" XXXXX ....", " XXXXX ....",
" XXXXX X ...", " XXXXX X ...",
@ -115,8 +115,8 @@ filePrintText = \
'''Click this button to print the file you are editing.<br><br> '''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.''' You can also select the <b>Print</b> command from the <b>File</b> menu.'''
True=1 #True=1
False=0 #False=0
class ApplicationWindow(TQMainWindow): class ApplicationWindow(TQMainWindow):
def __init__(self): def __init__(self):
@ -132,7 +132,7 @@ class ApplicationWindow(TQMainWindow):
saveIcon = TQPixmap(filesave) saveIcon = TQPixmap(filesave)
self.fileSave = TQToolButton(TQIconSet(saveIcon),'Save File',TQString.null,self.save,self.fileTools,'save file') 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') self.filePrint = TQToolButton(TQIconSet(printIcon),'Print File',TQString.null,self.printDoc,self.fileTools,'print file')
TQWhatsThis.whatsThisButton(self.fileTools) TQWhatsThis.whatsThisButton(self.fileTools)
@ -168,10 +168,10 @@ class ApplicationWindow(TQMainWindow):
self.menuBar().insertSeparator() self.menuBar().insertSeparator()
self.windows = TQPopupMenu( self ) self.windows = TQPopupMenu( self )
self.windows.setCheckable( True ) self.windows.setCheckable( True )
self.connect( self.windows, SIGNAL( "aboutToShow()" ), self.connect( self.windows, SIGNAL( "aboutToShow()" ),
self.windowsMenuAboutToShow ) self.windowsMenuAboutToShow )
self.menuBar().insertItem( "&Windows", self.windows ) self.menuBar().insertItem( "&Windows", self.windows )
self.help = TQPopupMenu(self) self.help = TQPopupMenu(self)
self.menuBar().insertSeparator() self.menuBar().insertSeparator()
@ -180,15 +180,15 @@ class ApplicationWindow(TQMainWindow):
self.help.insertItem('&About',self.about,TQt.Key_F1) self.help.insertItem('&About',self.about,TQt.Key_F1)
self.help.insertItem('About &TQt',self.aboutTQt) self.help.insertItem('About &TQt',self.aboutTQt)
self.help.insertSeparator() 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 = TQVBox( self )
self.vb.setFrameStyle( TQFrame.StyledPanel | TQFrame.Sunken ) self.vb.setFrameStyle( TQFrame.StyledPanel | TQFrame.Sunken )
self.ws = TQWorkspace( self.vb ) self.ws = TQWorkspace( self.vb )
self.ws.setScrollBarsEnabled( True ) self.ws.setScrollBarsEnabled( True )
self.setCentralWidget( self.vb ) self.setCentralWidget( self.vb )
self.statusBar().message('Ready',2000) self.statusBar().message('Ready',2000)
#self.resize(450,600) #self.resize(450,600)
@ -265,90 +265,90 @@ class ApplicationWindow(TQMainWindow):
class MDIWindow( TQMainWindow): class MDIWindow( TQMainWindow):
def __init__(self,parent, name, wflags ): def __init__(self,parent, name, wflags ):
TQMainWindow.__init__(self,parent, name, wflags ) TQMainWindow.__init__(self,parent, name, wflags )
self.mmovie = 0 self.mmovie = 0
self.medit = TQMultiLineEdit( self ) self.medit = TQMultiLineEdit( self )
self.setFocusProxy( self.medit ) self.setFocusProxy( self.medit )
self.setCentralWidget( self.medit ); self.setCentralWidget( self.medit );
def load(self, fn ): def load(self, fn ):
self.filename = fn self.filename = fn
self.f=TQFile( self.filename ) self.f=TQFile( self.filename )
if not self.f.open( IO_ReadOnly ): if not self.f.open( IO_ReadOnly ):
return return
if fn.contains(".gif"): if fn.contains(".gif"):
tmp=TQWidget(self) tmp=TQWidget(self)
self.setFocusProxy(tmp) self.setFocusProxy(tmp)
self.setCentralWidget(tmp) self.setCentralWidget(tmp)
self.medit.hide() self.medit.hide()
del self.medit del self.medit
qm=TQMovie(fn) qm=TQMovie(fn)
#ifdef Q_WS_QWS // temporary speed-test hack #ifdef Q_WS_QWS // temporary speed-test hack
#qm->setDisplayWidget(tmp); #qm->setDisplayWidget(tmp);
#endif #endif
tmp.setBackgroundMode(TQWidget.NoBackground) tmp.setBackgroundMode(TQWidget.NoBackground)
tmp.show() tmp.show()
self.mmovie=qm self.mmovie=qm
else : else :
self.mmovie = 0 self.mmovie = 0
t=TQTextStream(self.f) t=TQTextStream(self.f)
s = t.read() s = t.read()
self.medit.setText( s ) self.medit.setText( s )
self.f.close() self.f.close()
self.setCaption( self.filename ) self.setCaption( self.filename )
self.emit(PYSIGNAL( "message"),(TQString("Loaded document %1").arg(self.filename),2000 )) self.emit(PYSIGNAL( "message"),(TQString("Loaded document %1").arg(self.filename),2000 ))
def save(self): def save(self):
if self.filename.isEmpty(): if self.filename.isEmpty():
self.saveAs() self.saveAs()
return return
text = self.medit.text() text = self.medit.text()
output=open(str(self.filename),'w') output=open(str(self.filename),'w')
output.write(str(text)) output.write(str(text))
#emit message( TQString("Could not write to %1").arg(filename), 2000 ); #emit message( TQString("Could not write to %1").arg(filename), 2000 );
#return #return
output.close() output.close()
self.setCaption(self.filename) self.setCaption(self.filename)
self.emit(PYSIGNAL( "message"),(TQString("File %1 saved").arg(self.filename),2000 )) self.emit(PYSIGNAL( "message"),(TQString("File %1 saved").arg(self.filename),2000 ))
def saveAs(self): def saveAs(self):
fn = TQFileDialog.getSaveFileName( self.filename, TQString.null, self ) fn = TQFileDialog.getSaveFileName( self.filename, TQString.null, self )
if not fn.isEmpty(): if not fn.isEmpty():
self.filename = fn self.filename = fn
self.save() self.save()
else : else :
self.emit(PYSIGNAL( "message"),(TQString("Saving aborted"),2000 )) self.emit(PYSIGNAL( "message"),(TQString("Saving aborted"),2000 ))
def printDoc(self,printer): def printDoc(self,printer):
Margin = 10 Margin = 10
pageNo = 1 pageNo = 1
if printer.setup(self): if printer.setup(self):
self.emit(PYSIGNAL( "message"),(TQString("Printing..."),2000 )) self.emit(PYSIGNAL( "message"),(TQString("Printing..."),2000 ))
p = TQPainter() p = TQPainter()
p.begin(printer) p.begin(printer)
p.setFont(self.medit.font()) p.setFont(self.medit.font())
yPos = 0 yPos = 0
fm = p.fontMetrics() fm = p.fontMetrics()
metrics = TQPaintDeviceMetrics(printer) metrics = TQPaintDeviceMetrics(printer)
for i in range(self.medit.numLines()): for i in range(self.medit.numLines()):
if Margin + yPos > metrics.height() - Margin: if Margin + yPos > metrics.height() - Margin:
pageNo = pageNo + 1 pageNo = pageNo + 1
self.emit(PYSIGNAL( "message"),(TQString("Printing (page %1) ...").arg(pageNo),2000 )) self.emit(PYSIGNAL( "message"),(TQString("Printing (page %1) ...").arg(pageNo),2000 ))
printer.newPage() printer.newPage()
yPos = 0 yPos = 0
p.drawText(Margin,Margin + yPos,metrics.width(),fm.lineSpacing(),TQt.ExpandTabs | TQt.DontClip,self.medit.textLine(i)) p.drawText(Margin,Margin + yPos,metrics.width(),fm.lineSpacing(),TQt.ExpandTabs | TQt.DontClip,self.medit.textLine(i))
yPos = yPos + fm.lineSpacing() yPos = yPos + fm.lineSpacing()
p.end() p.end()
self.emit(PYSIGNAL( "message"),(TQString("Printing completed"),2000 )) self.emit(PYSIGNAL( "message"),(TQString("Printing completed"),2000 ))
else: else:
self.emit(PYSIGNAL( "message"),(TQString("Printing aborted"),2000 )) self.emit(PYSIGNAL( "message"),(TQString("Printing aborted"),2000 ))
if __name__=='__main__': if __name__=='__main__':

@ -87,7 +87,7 @@ class AnimatedThingy(TQLabel):
def _drawqix(self, p, pn, step): def _drawqix(self, p, pn, step):
# rainbow effect # 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.setPen(pn)
p.drawLine(self.ox[step][0], self.oy[step][0], p.drawLine(self.ox[step][0], self.oy[step][0],
self.ox[step][1], self.oy[step][1]) self.ox[step][1], self.oy[step][1])

@ -2,6 +2,7 @@
# #
# 2005-02-12 initial version hp # 2005-02-12 initial version hp
from __future__ import print_function
import os import os
import pickle import pickle
from python_tqt.qt import * from python_tqt.qt import *
@ -97,7 +98,7 @@ class Preview(TQWidgetStack):
err = False err = False
try: try:
text = open(path.latin1(), "r").read() text = open(path.latin1(), "r").read()
except IOError, msg: except IOError as msg:
text = TQString(str(msg)) text = TQString(str(msg))
err = True err = True
if not err and fi.extension().lower().contains("htm"): if not err and fi.extension().lower().contains("htm"):
@ -159,8 +160,8 @@ class CustomFileDialog(TQFileDialog):
if os.path.exists(self.bookmarkFile): if os.path.exists(self.bookmarkFile):
try: try:
self.bookmarkList = pickle.loads(open(self.bookmarkFile, "rb").read()) self.bookmarkList = pickle.loads(open(self.bookmarkFile, "rb").read())
except IOError, msg: except IOError as msg:
print msg print(msg)
self.setDir("/") self.setDir("/")
self.dirView = DirectoryView(self, None, True) self.dirView = DirectoryView(self, None, True)
self.dirView.addColumn("") self.dirView.addColumn("")
@ -209,8 +210,8 @@ class CustomFileDialog(TQFileDialog):
if self.bookmarkList: if self.bookmarkList:
try: try:
open(self.bookmarkFile, "wb").write(pickle.dumps(self.bookmarkList)) open(self.bookmarkFile, "wb").write(pickle.dumps(self.bookmarkList))
except IOError, msg: except IOError as msg:
print msg print(msg)
return TQFileDialog.done(self, r) return TQFileDialog.done(self, r)
def showEvent(self, e): def showEvent(self, e):
@ -245,8 +246,8 @@ if __name__ == '__main__':
def usage(msg = None): def usage(msg = None):
if msg: if msg:
print >> sys.stderr, msg print(msg, file=sys.stderr)
print >> sys.stderr, """\ print("""\
usage: qdir [--any | --dir | --custom] [--preview] [--default f] {--filter f} [caption ...] usage: qdir [--any | --dir | --custom] [--preview] [--default f] {--filter f} [caption ...]
--any Get any filename, need not exist. --any Get any filename, need not exist.
--dir Return a directory rather than a file. --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. --default f Start from directory/file f.
--filter f eg. '*.gif' '*.bmp' --filter f eg. '*.gif' '*.bmp'
caption ... Caption for dialog. caption ... Caption for dialog.
""" """, file=sys.stderr)
sys.exit(1) sys.exit(1)
def main(): def main():
@ -270,7 +271,7 @@ usage: qdir [--any | --dir | --custom] [--preview] [--default f] {--filter f} [c
try: try:
optlist, args = getopt.getopt(sys.argv[1:], "h", options) optlist, args = getopt.getopt(sys.argv[1:], "h", options)
except getopt.error, msg: except getopt.error as msg:
usage(msg) usage(msg)
for opt, par in optlist: for opt, par in optlist:
@ -311,7 +312,7 @@ usage: qdir [--any | --dir | --custom] [--preview] [--default f] {--filter f} [c
fd.setCaption(caption) fd.setCaption(caption)
fd.setSelection(start) fd.setSelection(start)
if fd.exec_loop() == TQDialog.Accepted: if fd.exec_loop() == TQDialog.Accepted:
print "%s\n" % fd.selectedFile().latin1() print("%s\n" % fd.selectedFile().latin1())
return 0 return 0
else: else:
return 1 return 1

@ -13,7 +13,7 @@
import sys import sys
from python_tqt.qt import * from python_tqt.qt import *
INT_MAX = sys.maxint INT_MAX = sys.maxsize
class RangeControls( TQVBox ): class RangeControls( TQVBox ):
def __init__( self, parent=None, name=None ): def __init__( self, parent=None, name=None ):

@ -99,7 +99,7 @@ class MyRichText( TQVBox ):
self.connect( self.bClose, SIGNAL("clicked()"), tqApp, SLOT("quit()") ) self.connect( self.bClose, SIGNAL("clicked()"), tqApp, SLOT("quit()") )
self.connect( self.bPrev, SIGNAL("clicked()"), self.prev ) 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 self.num = 0
@ -112,7 +112,7 @@ class MyRichText( TQVBox ):
self.bPrev.setEnabled( False ) self.bPrev.setEnabled( False )
self.bNext.setEnabled( True ) self.bNext.setEnabled( True )
def next( self ): def __next__( self ):
self.num += 1 self.num += 1
if not sayings[self.num]: if not sayings[self.num]:
return return

@ -9,7 +9,7 @@ import sys
try: try:
from python_tqt.qt import TQThread from python_tqt.qt import TQThread
except: except:
print "Thread support not enabled" print("Thread support not enabled")
sys.exit(1) sys.exit(1)
from python_tqt.qt import * from python_tqt.qt import *
@ -192,7 +192,7 @@ class SemaphoreExample(TQWidget):
del s del s
else: else:
print "Unknown custom event type:", event.type() print("Unknown custom event type:", event.type())
app = TQApplication(sys.argv) app = TQApplication(sys.argv)

@ -16,13 +16,13 @@ class Test(TQWidget):
y1 = 0 y1 = 0
y2 = self.height() - 1 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, 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)
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(x1, y, x1+d, y-d) p.drawLine(x1, y, x1+d, y-d)
p.drawLine(x2, y, x2-d, y+d) p.drawLine(x2, y, x2-d, y+d)

@ -53,6 +53,8 @@ class Table(TQTable):
# read all the TQt source and header files into a list # read all the TQt source and header files into a list
all = [] all = []
qtdir = os.getenv("TQTDIR") qtdir = os.getenv("TQTDIR")
if qtdir is None:
raise Exception("The TQTDIR environment variable has not been set.")
for i in dirs: for i in dirs:
dir = TQDir(os.path.join(qtdir, "src", i)) dir = TQDir(os.path.join(qtdir, "src", i))
lst = TQStringList(dir.entryList("*.cpp; *.h")) lst = TQStringList(dir.entryList("*.cpp; *.h"))
@ -65,7 +67,7 @@ class Table(TQTable):
self.setNumRows(len(all) + 1) self.setNumRows(len(all) + 1)
i = 0 i = 0
sum = 0L sum = 0
# insert the data into the table # insert the data into the table
for it in all: for it in all:
self.setText(i, TB_FILE, it) self.setText(i, TB_FILE, it)
@ -82,11 +84,11 @@ class Table(TQTable):
if col < TB_SIZE or col > TB_FLAG: if col < TB_SIZE or col > TB_FLAG:
return return
sum = 0L sum = 0
for i in range(self.numRows()-1): for i in range(self.numRows()-1):
if str(self.text(i, TB_FLAG)) == "No": if str(self.text(i, TB_FLAG)) == "No":
continue continue
sum += long(str(self.text(i, TB_SIZE))) sum += int(str(self.text(i, TB_SIZE)))
self.displaySum(sum) self.displaySum(sum)
def displaySum(self, sum): def displaySum(self, sum):
@ -108,7 +110,7 @@ class Table(TQTable):
class TableItem(TQTableItem): class TableItem(TQTableItem):
def __init__(self, *args): def __init__(self, *args):
apply(TQTableItem.__init__, (self,) + args) TQTableItem.__init__(*(self,) + args)
def paint(self, p, cg, cr, selected): def paint(self, p, cg, cr, selected):
g = TQColorGroup(cg) g = TQColorGroup(cg)

@ -76,7 +76,7 @@ class TellMe( TQWidget ):
self.r2 = self.randomRect() self.r2 = self.randomRect()
def randomRect( self ): 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 ): def tip( self, p ):

@ -27,7 +27,7 @@ class LCDRange(qt.TQVBox):
def setRange(self, minVal, maxVal): def setRange(self, minVal, maxVal):
if minVal < 0 or maxVal > 99 or 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) self.slider.setRange(minVal, maxVal)

@ -28,7 +28,7 @@ class LCDRange(qt.TQVBox):
def setRange(self, minVal, maxVal): def setRange(self, minVal, maxVal):
if minVal < 0 or maxVal > 99 or 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) self.slider.setRange(minVal, maxVal)
@ -149,7 +149,7 @@ class CannonField(qt.TQWidget):
y = y0 + vely * time - 0.5 * gravity * time * time y = y0 + vely * time - 0.5 * gravity * time * time
r = qt.TQRect(0, 0, 6, 6) 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 return r
def sizePolicy(self): def sizePolicy(self):

@ -36,7 +36,7 @@ class LCDRange(qt.TQVBox):
def setRange(self, minVal, maxVal): def setRange(self, minVal, maxVal):
if minVal < 0 or maxVal > 99 or 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) self.slider.setRange(minVal, maxVal)
@ -184,7 +184,7 @@ class CannonField(qt.TQWidget):
y = y0 + vely * time - 0.5 * gravity * time * time y = y0 + vely * time - 0.5 * gravity * time * time
r = qt.TQRect(0, 0, 6, 6) 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 return r
def targetRect(self): def targetRect(self):

@ -41,7 +41,7 @@ class LCDRange(qt.TQWidget):
def setRange(self, minVal, maxVal): def setRange(self, minVal, maxVal):
if minVal < 0 or maxVal > 99 or 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) self.slider.setRange(minVal, maxVal)
@ -216,7 +216,7 @@ class CannonField(qt.TQWidget):
y = y0 + vely * time - 0.5 * gravity * time * time y = y0 + vely * time - 0.5 * gravity * time * time
r = qt.TQRect(0, 0, 6, 6) 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 return r
def targetRect(self): def targetRect(self):

@ -41,7 +41,7 @@ class LCDRange(qt.TQWidget):
def setRange(self, minVal, maxVal): def setRange(self, minVal, maxVal):
if minVal < 0 or maxVal > 99 or 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) self.slider.setRange(minVal, maxVal)
@ -246,7 +246,7 @@ class CannonField(qt.TQWidget):
y = y0 + vely * time - 0.5 * gravity * time * time y = y0 + vely * time - 0.5 * gravity * time * time
r = qt.TQRect(0, 0, 6, 6) 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 return r
def targetRect(self): def targetRect(self):

@ -27,7 +27,7 @@ class LCDRange(qt.TQVBox):
def setRange(self, minVal, maxVal): def setRange(self, minVal, maxVal):
if minVal < 0 or maxVal > 99 or 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) self.slider.setRange(minVal, maxVal)

@ -27,7 +27,7 @@ class LCDRange(qt.TQVBox):
def setRange(self, minVal, maxVal): def setRange(self, minVal, maxVal):
if minVal < 0 or maxVal > 99 or 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) self.slider.setRange(minVal, maxVal)

@ -1064,34 +1064,34 @@ class MainWindow(TQMainWindow):
def go(self): def go(self):
print "MainWindow.go(): Not implemented yet" print("MainWindow.go(): Not implemented yet")
def newWindow(self): def newWindow(self):
print "MainWindow.newWindow(): Not implemented yet" print("MainWindow.newWindow(): Not implemented yet")
def setProgress(self,a0,a1): def setProgress(self,a0,a1):
print "MainWindow.setProgress(int,int): Not implemented yet" print("MainWindow.setProgress(int,int): Not implemented yet")
def init(self): def init(self):
pass pass
def setTitle(self,a0): 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): def setCommandState(self,a0,a1):
print "MainWindow.setCommandState(int,bool): Not implemented yet" print("MainWindow.setCommandState(int,bool): Not implemented yet")
def navigateComplete(self): def navigateComplete(self):
print "MainWindow.navigateComplete(): Not implemented yet" print("MainWindow.navigateComplete(): Not implemented yet")
def navigateBegin(self): def navigateBegin(self):
print "MainWindow.navigateBegin(): Not implemented yet" print("MainWindow.navigateBegin(): Not implemented yet")
def aboutSlot(self): def aboutSlot(self):
print "MainWindow.aboutSlot(): Not implemented yet" print("MainWindow.aboutSlot(): Not implemented yet")
def aboutTQtSlot(self): def aboutTQtSlot(self):
print "MainWindow.aboutTQtSlot(): Not implemented yet" print("MainWindow.aboutTQtSlot(): Not implemented yet")
def __tr(self,s,c = None): def __tr(self,s,c = None):
return tqApp.translate("MainWindow",s,c) return tqApp.translate("MainWindow",s,c)

@ -18,7 +18,7 @@ def TQMIN( x, y ):
class AnalogClock( TQWidget ): class AnalogClock( TQWidget ):
def __init__( self, *args ): def __init__( self, *args ):
apply( TQWidget.__init__, (self,) + args ) TQWidget.__init__(*(self,) + args)
self.time = TQTime.currentTime() # get current time self.time = TQTime.currentTime() # get current time
internalTimer = TQTimer( self ) # create internal timer internalTimer = TQTimer( self ) # create internal timer
self.connect( internalTimer, SIGNAL("timeout()"), self.timeout ) self.connect( internalTimer, SIGNAL("timeout()"), self.timeout )
@ -74,7 +74,7 @@ class AnalogClock( TQWidget ):
class DigitalClock( TQLCDNumber ): class DigitalClock( TQLCDNumber ):
def __init__( self, *args ): def __init__( self, *args ):
apply( TQLCDNumber.__init__,(self,) + args ) TQLCDNumber.__init__(*(self,) + args)
self.showingColon = 0 self.showingColon = 0
self.setFrameStyle(TQFrame.Panel | TQFrame.Raised) self.setFrameStyle(TQFrame.Panel | TQFrame.Raised)
self.setLineWidth( 2 ) self.setLineWidth( 2 )
@ -112,7 +112,7 @@ class DigitalClock( TQLCDNumber ):
s[2] = ' ' s[2] = ' '
if s[0] == '0': if s[0] == '0':
s[0] = ' ' s[0] = ' '
s = string.join(s,'') s = ''.join(s)
self.display( s ) self.display( s )
def TQMIN( x, y ): def TQMIN( x, y ):
@ -130,7 +130,7 @@ MOVIEFILENAME = "trolltech.gif"
class WidgetView ( TQWidget ): class WidgetView ( TQWidget ):
def __init__( self, *args ): def __init__( self, *args ):
apply( TQWidget.__init__, (self,) + args ) TQWidget.__init__(*(self,) + args)
# Set the window caption/title # Set the window caption/title
self.setCaption( "TQt Widgets Demo Application" ) self.setCaption( "TQt Widgets Demo Application" )
@ -223,7 +223,7 @@ class WidgetView ( TQWidget ):
self.vbox.addSpacing( self.bg.fontMetrics().height() ) 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] = TQCheckBox( self.bg )
self.cb[0].setText( "Read" ) self.cb[0].setText( "Read" )
self.vbox.addWidget( self.cb[0] ) self.vbox.addWidget( self.cb[0] )
@ -464,10 +464,10 @@ class WidgetView ( TQWidget ):
TQApplication.setPalette( p, TRUE ) TQApplication.setPalette( p, TRUE )
def lineEditTextChanged( self, newText ): def lineEditTextChanged( self, newText ):
self.msg.setText("Line edit text: " + unicode(newText)) self.msg.setText("Line edit text: " + str(newText))
def spinBoxValueChanged( self, valueText ): 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. # All application events are passed throught this event filter.
# We're using it to display some information about a clicked # We're using it to display some information about a clicked

@ -17,8 +17,8 @@ __all__ = [
'qt', 'qt',
'qtcanvas', 'qtcanvas',
'qtnetwork', 'qtnetwork',
'qtsql',
'qttable', 'qttable',
'qtsql',
'qtui', 'qtui',
'qtxml', 'qtxml',
] ]

@ -64,6 +64,9 @@ This has been renamed to <Literal>exec_loop</Literal> in Python.
</Sect2> </Sect2>
%End %End
%ModuleHeaderCode
#include <tqapplication.h>
%End
TQApplication *tqApp; TQApplication *tqApp;
@ -128,7 +131,6 @@ public:
} }
%End %End
%If (TQt_2_2_0 -)
enum Type { enum Type {
Tty, Tty,
GuiClient, GuiClient,
@ -159,7 +161,6 @@ public:
// Now modify the original list. // Now modify the original list.
updatePyArgv(a0,argc,argv); updatePyArgv(a0,argc,argv);
} }
%End
%End %End
~TQApplication(); ~TQApplication();
@ -209,7 +210,7 @@ public:
sipIsErr = 1; sipIsErr = 1;
else else
for (int a = 0; a < argc; ++a) 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); Py_DECREF(sipRes);
sipIsErr = 1; sipIsErr = 1;
@ -217,39 +218,17 @@ public:
} }
%End %End
%If (TQt_2_3_0 -)
Type type() const; Type type() const;
%End
%If (- TQt_2_00)
static GUIStyle style();
static void setStyle(GUIStyle);
%End
%If (TQt_2_00 -)
static TQStyle &style(); static TQStyle &style();
static void setStyle(TQStyle * /Transfer/); static void setStyle(TQStyle * /Transfer/);
%End
%If (TQt_3_0_0 -)
static TQStyle *setStyle(const TQString &); 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 enum ColorSpec
{ {
NormalColor = 0, NormalColor = 0,
CustomColor = 1, CustomColor = 1,
ManyColor = 2 ManyColor = 2
}; };
%End
static int colorSpec(); static int colorSpec();
static void setColorSpec(int); static void setColorSpec(int);
@ -258,51 +237,26 @@ public:
static void restoreOverrideCursor(); static void restoreOverrideCursor();
static bool hasGlobalMouseTracking(); static bool hasGlobalMouseTracking();
static void setGlobalMouseTracking(bool); 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 TQPalette palette(const TQWidget * = 0);
static void setPalette(TQPalette &,bool = 0,const char * = 0); static void setPalette(TQPalette &,bool = 0,const char * = 0);
static TQFont font(const TQWidget * = 0); static TQFont font(const TQWidget * = 0);
static void setFont(const TQFont &,bool = 0,const char * = 0); static void setFont(const TQFont &,bool = 0,const char * = 0);
%End
static TQFontMetrics fontMetrics(); static TQFontMetrics fontMetrics();
TQWidget *mainWidget() const; 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 setMainWidget(TQWidget *);
virtual void polish(TQWidget *); virtual void polish(TQWidget *);
%End
static TQWidgetList *allWidgets(); static TQWidgetList *allWidgets();
static TQWidgetList *topLevelWidgets(); static TQWidgetList *topLevelWidgets();
%If (- TQt_3_0_0)
static TQWidget *desktop();
%End
%If (TQt_3_0_0 -)
static TQDesktopWidget *desktop(); static TQDesktopWidget *desktop();
%End
static TQWidget *activePopupWidget(); static TQWidget *activePopupWidget();
static TQWidget *activeModalWidget(); static TQWidget *activeModalWidget();
static TQClipboard *clipboard(); static TQClipboard *clipboard();
TQWidget *focusWidget() const; TQWidget *focusWidget() const;
%If (TQt_2_00 -)
TQWidget *activeWindow() const; TQWidget *activeWindow() const;
%End
static TQWidget *widgetAt(int,int,bool = 0); static TQWidget *widgetAt(int,int,bool = 0);
static TQWidget *widgetAt(const TQPoint &,bool = 0); static TQWidget *widgetAt(const TQPoint &,bool = 0);
%If (TQt_3_1_0 -)
static TQEventLoop *eventLoop(); static TQEventLoop *eventLoop();
%End
int exec() /PyName=exec_loop, ReleaseGIL, int exec() /PyName=exec_loop, ReleaseGIL,
PreHook=__pyTQtPreEventLoopHook__, PreHook=__pyTQtPreEventLoopHook__,
@ -310,44 +264,27 @@ public:
void processEvents() /ReleaseGIL/; void processEvents() /ReleaseGIL/;
void processEvents(int) /ReleaseGIL/; void processEvents(int) /ReleaseGIL/;
void processOneEvent() /ReleaseGIL/; void processOneEvent() /ReleaseGIL/;
%If (TQt_3_0_0 -)
bool hasPendingEvents(); bool hasPendingEvents();
%End
int enter_loop() /ReleaseGIL/; int enter_loop() /ReleaseGIL/;
void exit_loop(); void exit_loop();
%If (TQt_2_00 -)
int loopLevel() const; int loopLevel() const;
%End
static void exit(int = 0); static void exit(int = 0);
static bool sendEvent(TQObject *,TQEvent *) /ReleaseGIL/; static bool sendEvent(TQObject *,TQEvent *) /ReleaseGIL/;
static void postEvent(TQObject *,TQEvent * /Transfer/) /ReleaseGIL/; static void postEvent(TQObject *,TQEvent * /Transfer/) /ReleaseGIL/;
static void sendPostedEvents(TQObject *,int) /ReleaseGIL/; static void sendPostedEvents(TQObject *,int) /ReleaseGIL/;
%If (TQt_2_00 -)
static void sendPostedEvents() /ReleaseGIL/; static void sendPostedEvents() /ReleaseGIL/;
static void removePostedEvents(TQObject *); static void removePostedEvents(TQObject *);
%End
virtual bool notify(TQObject *,TQEvent *) /ReleaseGIL/; virtual bool notify(TQObject *,TQEvent *) /ReleaseGIL/;
static bool startingUp(); static bool startingUp();
static bool closingDown(); static bool closingDown();
static void flushX(); static void flushX();
%If (TQt_3_0_0 -)
static void flush(); static void flush();
%End
static void syncX(); static void syncX();
static void beep(); static void beep();
%If (TQt_2_00 -)
void setDefaultCodec(TQTextCodec *); void setDefaultCodec(TQTextCodec *);
TQTextCodec *defaultCodec() const; TQTextCodec *defaultCodec() const;
void installTranslator(TQTranslator *); void installTranslator(TQTranslator *);
void removeTranslator(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 { enum Encoding {
DefaultCodec, DefaultCodec,
UnicodeUTF8 UnicodeUTF8
@ -355,98 +292,59 @@ public:
TQString translate(const char *,const char *,const char * = 0, TQString translate(const char *,const char *,const char * = 0,
Encoding = DefaultCodec) const; Encoding = DefaultCodec) const;
%End
%If (TQt_3_2_0 -)
TQString applicationDirPath(); TQString applicationDirPath();
TQString applicationFilePath(); 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 void setDesktopSettingsAware(bool);
static bool desktopSettingsAware(); static bool desktopSettingsAware();
static void setCursorFlashTime(int); static void setCursorFlashTime(int);
static int cursorFlashTime(); static int cursorFlashTime();
%End
static void setDoubleClickInterval(int); static void setDoubleClickInterval(int);
static int doubleClickInterval(); static int doubleClickInterval();
%If (TQt_2_1_0 -)
static void setWheelScrollLines(int); static void setWheelScrollLines(int);
static int wheelScrollLines(); static int wheelScrollLines();
%If (TQt_2_2_0 -)
static void setGlobalStrut(const TQSize &); static void setGlobalStrut(const TQSize &);
static TQSize globalStrut(); static TQSize globalStrut();
%End
%If (TQt_3_0_0 -)
static void setLibraryPaths(const TQStringList &); static void setLibraryPaths(const TQStringList &);
static TQStringList libraryPaths(); static TQStringList libraryPaths();
static void addLibraryPath(const TQString &); static void addLibraryPath(const TQString &);
static void removeLibraryPath(const TQString &); static void removeLibraryPath(const TQString &);
%End
static void setStartDragTime(int); static void setStartDragTime(int);
static int startDragTime(); static int startDragTime();
static void setStartDragDistance(int); static void setStartDragDistance(int);
static int startDragDistance(); static int startDragDistance();
%If (TQt_3_0_0 -)
static void setReverseLayout(bool); static void setReverseLayout(bool);
static bool reverseLayout(); static bool reverseLayout();
static int horizontalAlignment(int); static int horizontalAlignment(int);
%End
%If (TQt_2_2_0 -)
static bool isEffectEnabled(TQt::UIEffect); static bool isEffectEnabled(TQt::UIEffect);
static void setEffectEnabled(TQt::UIEffect,bool = 1); static void setEffectEnabled(TQt::UIEffect,bool = 1);
%End
%End
%If (TQt_2_00 -)
bool isSessionRestored() const; bool isSessionRestored() const;
TQString sessionId() const; TQString sessionId() const;
%If (TQt_3_1_0 -)
TQString sessionKey() const; TQString sessionKey() const;
%End
virtual void commitData(TQSessionManager &); virtual void commitData(TQSessionManager &);
virtual void saveState(TQSessionManager &); virtual void saveState(TQSessionManager &);
%End
%If (TQt_2_1_0 -)
void wakeUpGuiThread(); void wakeUpGuiThread();
%End
%If (TQt_THREAD_SUPPORT) %If (TQt_THREAD_SUPPORT)
%If (TQt_2_2_0 -)
void lock() /ReleaseGIL/; void lock() /ReleaseGIL/;
void unlock(bool = 1); void unlock(bool = 1);
bool locked(); bool locked();
%End
%If (TQt_3_0_0 -)
bool tryLock(); bool tryLock();
%End %End
%End
signals: signals:
void lastWindowClosed(); void lastWindowClosed();
%If (TQt_2_00 -)
void aboutToQuit(); void aboutToQuit();
%End
%If (TQt_2_1_0 -)
void guiThreadAwake(); void guiThreadAwake();
%End
public slots: public slots:
void quit(); void quit();
%If (TQt_2_00 -)
void closeAllWindows(); void closeAllWindows();
%End
%If (TQt_3_2_0 -)
void aboutTQt(); void aboutTQt();
%End
protected: protected:
%If (TQt_3_1_0 -)
bool event(TQEvent *); bool event(TQEvent *);
%End
private: private:
TQApplication(const TQApplication &); TQApplication(const TQApplication &);
@ -471,19 +369,26 @@ static char **pyArgvToC(PyObject *argvlist,int &argc)
// Convert the list. // Convert the list.
for (int a = 0; a < argc; ++a) for (int a = 0; a < argc; ++a)
{ {
PyObject *argObject = PyList_GET_ITEM(argvlist, a);
char *arg; char *arg;
// Get the argument and allocate memory for it. if (PyUnicode_Check(argObject))
if ((arg = PyString_AsString(PyList_GetItem(argvlist,a))) == NULL || {
(argv[a] = (char *)sipMalloc(strlen(arg) + 1)) == NULL) arg = tqstrdup(sipString_AsLatin1String(&argObject));
}
else if (SIPBytes_Check(argObject))
{
arg = tqstrdup(SIPBytes_AS_STRING(argObject));
}
else
{
return NULL; return NULL;
}
// Copy the argument and save a pointer to it. argv[a] = argv[a + argc + 1] = arg;
strcpy(argv[a],arg);
argv[a + argc + 1] = argv[a];
} }
argv[argc + argc + 1] = argv[argc] = NULL; argv[argc] = argv[argc + argc + 1] = NULL;
return argv; return argv;
} }
@ -544,19 +449,7 @@ static void pyqtMsgHandler(TQtMsgType type, const char *msg)
SIP_BLOCK_THREADS SIP_BLOCK_THREADS
#if SIP_VERSION >= 0x040200
res = sipCallMethod(0, pyqtPyMsgHandler, "Es", type, sipEnum_TQtMsgType, msg); 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); Py_XDECREF(res);

@ -52,7 +52,7 @@ converted to and from Python lists of the type.
// Get it. // Get it.
for (uint i = 0; i < sipCpp -> count(); ++i) 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); 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) 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) if (PyErr_Occurred() != NULL)
{ {

@ -19,6 +19,7 @@
// PyTQt; see the file LICENSE. If not, write to the Free Software Foundation, // PyTQt; see the file LICENSE. If not, write to the Free Software Foundation,
// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
%DefaultEncoding "UTF-8"
%ExportedDoc %ExportedDoc
<Sect2><Title>TQButtonGroup</Title> <Sect2><Title>TQButtonGroup</Title>

@ -98,6 +98,36 @@ class TQByteArray
#include <tqstring.h> #include <tqstring.h>
%End %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: public:
TQByteArray(); TQByteArray();
TQByteArray(int); TQByteArray(int);
@ -105,27 +135,20 @@ public:
SIP_PYOBJECT data() const; SIP_PYOBJECT data() const;
%MethodCode %MethodCode
// TQByteArrays aren't '\0' terminated so set the size PyObject* res = TQByteArray_To_String(sipCpp);
// explicitly.
char *res;
uint len;
Py_BEGIN_ALLOW_THREADS
res = sipCpp -> data();
len = sipCpp -> size();
Py_END_ALLOW_THREADS
if (res) if (res == Py_None)
{ {
if ((sipRes = PyString_FromStringAndSize(res,len)) == NULL) Py_INCREF(Py_None);
sipIsErr = 1;
} }
else else if (res == NULL)
{ {
Py_INCREF(Py_None); sipIsErr = 1;
sipRes = Py_None;
} }
else
{
sipRes = res;
}
%End %End
// These are actually in TQMemArray, which isn't implemented so pretend // These are actually in TQMemArray, which isn't implemented so pretend
@ -151,36 +174,62 @@ public:
SIP_PYOBJECT __str__(); SIP_PYOBJECT __str__();
%MethodCode %MethodCode
// TQByteArrays aren't '\0' terminated so set the size PyObject* res = TQByteArray_To_String(sipCpp);
// explicitly.
char *data; if (res == Py_None)
uint len; {
sipRes = SIPBytes_FromString("");
Py_BEGIN_ALLOW_THREADS }
data = sipCpp -> data();
len = sipCpp -> size();
Py_END_ALLOW_THREADS
if (data == NULL)
sipRes = PyString_FromString("");
else else
sipRes = PyString_FromStringAndSize(data,len); {
sipRes = res;
}
%End %End
%ConvertToTypeCode %ConvertToTypeCode
// Allow a Python string whenever a TQByteArray is expected. // Allow a Python string whenever a TQByteArray is expected.
if (sipIsErr == NULL) if (sipIsErr == NULL)
return (PyString_Check(sipPy) || return (SIPBytes_Check(sipPy) ||
PyUnicode_Check(sipPy) ||
sipCanConvertToInstance(sipPy,sipClass_TQByteArray,SIP_NO_CONVERTORS)); 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 Py_BEGIN_ALLOW_THREADS
TQByteArray *ba = new TQByteArray(); 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; *sipCppPtr = ba;
Py_END_ALLOW_THREADS Py_END_ALLOW_THREADS
@ -195,9 +244,7 @@ public:
}; };
%If (TQt_3_1_0 -)
TQByteArray tqCompress(const uchar * /Array/,int /ArraySize/); TQByteArray tqCompress(const uchar * /Array/,int /ArraySize/);
TQByteArray tqCompress(const TQByteArray &); TQByteArray tqCompress(const TQByteArray &);
TQByteArray tqUncompress(const uchar * /Array/,int /ArraySize/); TQByteArray tqUncompress(const uchar * /Array/,int /ArraySize/);
TQByteArray tqUncompress(const TQByteArray &); TQByteArray tqUncompress(const TQByteArray &);
%End

@ -197,19 +197,19 @@ public:
if (s == NULL) if (s == NULL)
s = ""; s = "";
sipRes = PyString_FromString(s); sipRes = SIPBytes_FromString(s);
%End %End
%ConvertToTypeCode %ConvertToTypeCode
// Allow a Python string whenever a TQCString is expected. // Allow a Python string whenever a TQCString is expected.
if (sipIsErr == NULL) if (sipIsErr == NULL)
return (PyString_Check(sipPy) || return (SIPBytes_Check(sipPy) ||
sipCanConvertToInstance(sipPy,sipClass_TQCString,SIP_NO_CONVERTORS)); 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); return sipGetState(sipTransferObj);
} }

@ -20,6 +20,7 @@
// PyTQt; see the file LICENSE. If not, write to the Free Software Foundation, // PyTQt; see the file LICENSE. If not, write to the Free Software Foundation,
// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
%DefaultEncoding "UTF-8"
%ExportedDoc %ExportedDoc
<Sect2><Title>TQColorDrag (TQt v2.1+)</Title> <Sect2><Title>TQColorDrag (TQt v2.1+)</Title>

@ -167,7 +167,7 @@ public:
Py_INCREF(Py_None); Py_INCREF(Py_None);
sipRes = Py_None; sipRes = Py_None;
} }
else if ((sipRes = PyString_FromStringAndSize(buf,actlen)) == NULL) else if ((sipRes = SIPBytes_FromStringAndSize(buf,actlen)) == NULL)
sipIsErr = 1; sipIsErr = 1;
sipFree((void *)buf); sipFree((void *)buf);
@ -196,7 +196,7 @@ public:
Py_INCREF(Py_None); Py_INCREF(Py_None);
sipRes = Py_None; sipRes = Py_None;
} }
else if ((sipRes = PyString_FromStringAndSize(buf,actlen)) == NULL) else if ((sipRes = SIPBytes_FromStringAndSize(buf,actlen)) == NULL)
sipIsErr = 1; sipIsErr = 1;
sipFree((void *)buf); sipFree((void *)buf);
@ -238,7 +238,7 @@ public:
} }
else else
{ {
sipRes = PyString_FromStringAndSize(buf,actlen); sipRes = SIPBytes_FromStringAndSize(buf,actlen);
sipFree((void *)buf); sipFree((void *)buf);
@ -272,7 +272,7 @@ public:
} }
else else
{ {
sipRes = PyString_FromStringAndSize(buf,actlen); sipRes = SIPBytes_FromStringAndSize(buf,actlen);
sipFree((void *)buf); sipFree((void *)buf);

@ -201,7 +201,7 @@ static int intListToArray(PyObject *pl,int **ap)
for (i = 0; i < nint; ++i) for (i = 0; i < nint; ++i)
{ {
*ip++ = PyInt_AsLong(PyList_GetItem(pl,i)); *ip++ = PyLong_AsLong(PyList_GetItem(pl,i));
if (PyErr_Occurred()) if (PyErr_Occurred())
{ {

@ -515,7 +515,7 @@ const char **PyTQt_qt_ListToArray(PyObject *lst);
// TQPixmap. // TQPixmap.
const char **PyTQt_qt_ListToArray(PyObject *lst) const char **PyTQt_qt_ListToArray(PyObject *lst)
{ {
int nstr; SIP_SSIZE_T nstr;
const char **str, **sp; const char **str, **sp;
nstr = PyList_Size(lst); nstr = PyList_Size(lst);
@ -528,15 +528,16 @@ const char **PyTQt_qt_ListToArray(PyObject *lst)
for (int i = 0; i < nstr; ++i) 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); sipFree((void *)str);
return NULL; return NULL;
} }
*sp++ = s; *sp++ = item_ascii;
} }
return str; return str;

@ -151,7 +151,7 @@ public:
} }
else else
{ {
sipRes = PyString_FromStringAndSize(buf,actlen); sipRes = SIPBytes_FromStringAndSize(buf,actlen);
sipFree((void *)buf); sipFree((void *)buf);
@ -171,15 +171,15 @@ public:
if (buf == Py_None) if (buf == Py_None)
sipRes = -1; sipRes = -1;
else if (!PyString_Check(buf)) else if (!SIPBytes_Check(buf))
{ {
sipBadCatcherResult(sipMethod); sipBadCatcherResult(sipMethod);
sipIsErr = 1; sipIsErr = 1;
} }
else else
{ {
memcpy(a0,PyString_AS_STRING(buf),PyString_GET_SIZE(buf)); memcpy(a0,SIPBytes_AS_STRING(buf),SIPBytes_GET_SIZE(buf));
sipRes = PyString_GET_SIZE(buf); sipRes = SIPBytes_GET_SIZE(buf);
} }
Py_DECREF(buf); Py_DECREF(buf);
@ -211,7 +211,7 @@ public:
} }
else else
{ {
sipRes = PyString_FromStringAndSize(buf,actlen); sipRes = SIPBytes_FromStringAndSize(buf,actlen);
sipFree((void *)buf); sipFree((void *)buf);
@ -231,15 +231,15 @@ public:
if (buf == Py_None) if (buf == Py_None)
sipRes = -1L; sipRes = -1L;
else if (!PyString_Check(buf)) else if (!SIPBytes_Check(buf))
{ {
sipBadCatcherResult(sipMethod); sipBadCatcherResult(sipMethod);
sipIsErr = 1; sipIsErr = 1;
} }
else else
{ {
memcpy(a0,PyString_AS_STRING(buf),PyString_GET_SIZE(buf)); memcpy(a0,SIPBytes_AS_STRING(buf),SIPBytes_GET_SIZE(buf));
sipRes = PyString_GET_SIZE(buf); sipRes = SIPBytes_GET_SIZE(buf);
} }
Py_DECREF(buf); Py_DECREF(buf);
@ -281,7 +281,7 @@ public:
} }
else else
{ {
sipRes = PyString_FromStringAndSize(buf,actlen); sipRes = SIPBytes_FromStringAndSize(buf,actlen);
sipFree((void *)buf); sipFree((void *)buf);
@ -301,15 +301,15 @@ public:
if (buf == Py_None) if (buf == Py_None)
sipRes = -1; sipRes = -1;
else if (!PyString_Check(buf)) else if (!SIPBytes_Check(buf))
{ {
sipBadCatcherResult(sipMethod); sipBadCatcherResult(sipMethod);
sipIsErr = 1; sipIsErr = 1;
} }
else else
{ {
memcpy(a0,PyString_AS_STRING(buf),PyString_GET_SIZE(buf)); memcpy(a0,SIPBytes_AS_STRING(buf),SIPBytes_GET_SIZE(buf));
sipRes = PyString_GET_SIZE(buf); sipRes = SIPBytes_GET_SIZE(buf);
} }
Py_DECREF(buf); Py_DECREF(buf);
@ -341,7 +341,7 @@ public:
} }
else else
{ {
sipRes = PyString_FromStringAndSize(buf,actlen); sipRes = SIPBytes_FromStringAndSize(buf,actlen);
sipFree((void *)buf); sipFree((void *)buf);
@ -361,15 +361,15 @@ public:
if (buf == Py_None) if (buf == Py_None)
sipRes = -1L; sipRes = -1L;
else if (!PyString_Check(buf)) else if (!SIPBytes_Check(buf))
{ {
sipBadCatcherResult(sipMethod); sipBadCatcherResult(sipMethod);
sipIsErr = 1; sipIsErr = 1;
} }
else else
{ {
memcpy(a0,PyString_AS_STRING(buf),PyString_GET_SIZE(buf)); memcpy(a0,SIPBytes_AS_STRING(buf),SIPBytes_GET_SIZE(buf));
sipRes = PyString_GET_SIZE(buf); sipRes = SIPBytes_GET_SIZE(buf);
} }
Py_DECREF(buf); Py_DECREF(buf);

@ -71,7 +71,7 @@ public:
PyErr_Clear(); PyErr_Clear();
PyInt_AsLong(sipPy); PyLong_AsLong(sipPy);
return !PyErr_Occurred(); return !PyErr_Occurred();
} }
@ -106,7 +106,7 @@ public:
return sipGetState(sipTransferObj); return sipGetState(sipTransferObj);
} }
int key = PyInt_AsLong(sipPy); int key = (int)PyLong_AsLong(sipPy);
Py_BEGIN_ALLOW_THREADS Py_BEGIN_ALLOW_THREADS
*sipCppPtr = new TQKeySequence(key); *sipCppPtr = new TQKeySequence(key);

@ -19,6 +19,7 @@
// PyTQt; see the file LICENSE. If not, write to the Free Software Foundation, // PyTQt; see the file LICENSE. If not, write to the Free Software Foundation,
// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
%DefaultEncoding "UTF-8"
%ExportedDoc %ExportedDoc
<Sect2><Title>TQLabel</Title> <Sect2><Title>TQLabel</Title>

@ -19,6 +19,7 @@
// PyTQt; see the file LICENSE. If not, write to the Free Software Foundation, // PyTQt; see the file LICENSE. If not, write to the Free Software Foundation,
// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
%DefaultEncoding "UTF-8"
%ExportedDoc %ExportedDoc
<Sect2><Title>TQLCDNumber</Title> <Sect2><Title>TQLCDNumber</Title>

@ -56,91 +56,6 @@ call <Literal>takeItem()</Literal> and then <Literal>del()</Literal>.
%End %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 class TQListViewItem : TQt
{ {
%TypeHeaderCode %TypeHeaderCode
@ -194,9 +109,7 @@ public:
virtual const TQPixmap *pixmap(int) const; virtual const TQPixmap *pixmap(int) const;
virtual TQString key(int,bool) const; virtual TQString key(int,bool) const;
%If (TQt_3_0_0 -)
virtual int compare(TQListViewItem *,int,bool) const; virtual int compare(TQListViewItem *,int,bool) const;
%End
virtual void sortChildItems(int,bool); virtual void sortChildItems(int,bool);
int childCount() const; int childCount() const;
@ -209,13 +122,7 @@ public:
bool isSelected() const; bool isSelected() const;
virtual void paintCell(TQPainter *,const TQColorGroup &,int,int,int); 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); virtual void paintBranches(TQPainter *,const TQColorGroup &,int,int,int);
%End
virtual void paintFocus(TQPainter *,const TQColorGroup &,const TQRect &); virtual void paintFocus(TQPainter *,const TQColorGroup &,const TQRect &);
TQListViewItem *firstChild() const; TQListViewItem *firstChild() const;
@ -237,17 +144,9 @@ public:
void repaint() const; void repaint() const;
%If (TQt_2_1_0 - TQt_3_0_0)
void sort();
%End
%If (TQt_3_0_0 -)
virtual void sort(); virtual void sort();
%End
%If (TQt_2_2_0 -)
void moveItem(TQListViewItem *); void moveItem(TQListViewItem *);
%End
%If (TQt_3_0_0 -)
virtual void setDragEnabled(bool); virtual void setDragEnabled(bool);
virtual void setDropEnabled(bool); virtual void setDropEnabled(bool);
bool dragEnabled() const; bool dragEnabled() const;
@ -268,17 +167,13 @@ public:
virtual void setMultiLinesEnabled(bool); virtual void setMultiLinesEnabled(bool);
bool multiLinesEnabled() const; bool multiLinesEnabled() const;
%End
protected: protected:
virtual void enforceSortOrder() const; virtual void enforceSortOrder() const;
virtual void setHeight(int); virtual void setHeight(int);
virtual void activate(); virtual void activate();
%If (TQt_2_1_0 -)
bool activatedPos(TQPoint &); bool activatedPos(TQPoint &);
%End
%If (TQt_3_0_0 -)
virtual void dropped(TQDropEvent *); virtual void dropped(TQDropEvent *);
virtual void dragEntered(); virtual void dragEntered();
virtual void dragLeft(); virtual void dragLeft();
@ -286,11 +181,8 @@ protected:
virtual void cancelRename(int); virtual void cancelRename(int);
void ignoreDoubleClick(); void ignoreDoubleClick();
%End
}; };
%End
class TQListView : TQScrollView class TQListView : TQScrollView
{ {
@ -299,44 +191,22 @@ class TQListView : TQScrollView
%End %End
public: 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); TQListView(TQWidget * /TransferThis/ = 0,const char * = 0,WFlags = 0);
%End
int treeStepSize() const; int treeStepSize() const;
virtual void setTreeStepSize(int); virtual void setTreeStepSize(int);
virtual void insertItem(TQListViewItem * /Transfer/); virtual void insertItem(TQListViewItem * /Transfer/);
%If (TQt_2_00 -)
virtual void takeItem(TQListViewItem * /TransferBack/); virtual void takeItem(TQListViewItem * /TransferBack/);
%End
%If (- TQt_3_0_0)
virtual void clear();
%End
TQHeader *header() const; 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 TQString &,int = -1);
virtual int addColumn(const TQIconSet &,const TQString &,int = -1); virtual int addColumn(const TQIconSet &,const TQString &,int = -1);
%If (TQt_2_1_0 -)
void removeColumn(int); void removeColumn(int);
%End
virtual void setColumnText(int,const TQString &); virtual void setColumnText(int,const TQString &);
virtual void setColumnText(int,const TQIconSet &,const TQString &); virtual void setColumnText(int,const TQIconSet &,const TQString &);
TQString columnText(int) const; TQString columnText(int) const;
%End
virtual void setColumnWidth(int,int); virtual void setColumnWidth(int,int);
int columnWidth(int) const; int columnWidth(int) const;
@ -348,9 +218,7 @@ public:
virtual void setColumnWidthMode(int,WidthMode); virtual void setColumnWidthMode(int,WidthMode);
WidthMode columnWidthMode(int) const; WidthMode columnWidthMode(int) const;
%If (TQt_2_1_0 -)
int columns() const; int columns() const;
%End
virtual void setColumnAlignment(int,int); virtual void setColumnAlignment(int,int);
int columnAlignment(int) const; int columnAlignment(int) const;
@ -368,7 +236,6 @@ public:
virtual void setMultiSelection(bool); virtual void setMultiSelection(bool);
bool isMultiSelection() const; bool isMultiSelection() const;
%If (TQt_2_1_0 -)
enum SelectionMode { enum SelectionMode {
Single, Single,
Multi, Multi,
@ -378,19 +245,12 @@ public:
void setSelectionMode(SelectionMode); void setSelectionMode(SelectionMode);
SelectionMode selectionMode() const; SelectionMode selectionMode() const;
%End
%If (TQt_2_1_0 -)
virtual void clearSelection(); virtual void clearSelection();
%End
virtual void setSelected(TQListViewItem *,bool); virtual void setSelected(TQListViewItem *,bool);
%If (TQt_3_2_0 -)
void setSelectionAnchor(TQListViewItem *); void setSelectionAnchor(TQListViewItem *);
%End
bool isSelected(TQListViewItem *) const; bool isSelected(TQListViewItem *) const;
%If (TQt_2_1_0 -)
TQListViewItem *selectedItem() const; TQListViewItem *selectedItem() const;
%End
virtual void setOpen(TQListViewItem *,bool); virtual void setOpen(TQListViewItem *,bool);
bool isOpen(TQListViewItem *) const; bool isOpen(TQListViewItem *) const;
@ -398,9 +258,7 @@ public:
TQListViewItem *currentItem() const; TQListViewItem *currentItem() const;
TQListViewItem *firstChild() const; TQListViewItem *firstChild() const;
%If (TQt_3_0_0 -)
TQListViewItem *lastItem() const; TQListViewItem *lastItem() const;
%End
int childCount() const; int childCount() const;
@ -414,43 +272,22 @@ public:
bool rootIsDecorated() const; bool rootIsDecorated() const;
virtual void setSorting(int,bool = 1); virtual void setSorting(int,bool = 1);
%If (TQt_3_1_0 -)
int sortColumn() const; int sortColumn() const;
%End
%If (TQt_3_2_0 -)
void setSortColumn(int); void setSortColumn(int);
SortOrder sortOrder() const; SortOrder sortOrder() const;
void setSortOrder(SortOrder); void setSortOrder(SortOrder);
%End
%If (TQt_3_0_0 -)
virtual void sort(); 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 setFont(const TQFont &);
virtual void setPalette(const TQPalette &); virtual void setPalette(const TQPalette &);
%End
bool eventFilter(TQObject *,TQEvent *); bool eventFilter(TQObject *,TQEvent *);
TQSize sizeHint() const; TQSize sizeHint() const;
%If (TQt_2_00 -)
TQSize minimumSizeHint() const; TQSize minimumSizeHint() const;
%End
%If (TQt_2_1_0 -)
void setShowSortIndicator(bool); void setShowSortIndicator(bool);
bool showSortIndicator() const; bool showSortIndicator() const;
%End
%If (TQt_3_0_0 -)
virtual void setShowToolTips(bool); virtual void setShowToolTips(bool);
bool showToolTips() const; bool showToolTips() const;
@ -474,83 +311,51 @@ public:
virtual void setDefaultRenameAction(RenameAction); virtual void setDefaultRenameAction(RenameAction);
RenameAction defaultRenameAction() const; RenameAction defaultRenameAction() const;
bool isRenaming() const; bool isRenaming() const;
%End
%If (TQt_3_2_0 -)
void hideColumn(int); void hideColumn(int);
%End
public slots: public slots:
%If (TQt_3_0_0 -)
virtual void clear(); virtual void clear();
%End
%If (TQt_2_1_0 -)
void invertSelection(); void invertSelection();
void selectAll(bool); void selectAll(bool);
void setContentsPos(int,int); void setContentsPos(int,int);
%End
void triggerUpdate(); void triggerUpdate();
%If (TQt_3_2_0 -)
void adjustColumn(int); void adjustColumn(int);
%End
signals: signals:
void selectionChanged(); void selectionChanged();
void selectionChanged(TQListViewItem *); void selectionChanged(TQListViewItem *);
void currentChanged(TQListViewItem *); void currentChanged(TQListViewItem *);
%If (TQt_2_1_0 -)
void clicked(TQListViewItem *); void clicked(TQListViewItem *);
void clicked(TQListViewItem *,const TQPoint &,int); void clicked(TQListViewItem *,const TQPoint &,int);
void pressed(TQListViewItem *); void pressed(TQListViewItem *);
void pressed(TQListViewItem *,const TQPoint &,int); void pressed(TQListViewItem *,const TQPoint &,int);
%End
void doubleClicked(TQListViewItem *); void doubleClicked(TQListViewItem *);
%If (TQt_3_2_0 -)
void doubleClicked(TQListViewItem *,const TQPoint &,int); void doubleClicked(TQListViewItem *,const TQPoint &,int);
%End
void returnPressed(TQListViewItem *); void returnPressed(TQListViewItem *);
%If (TQt_3_0_0 -)
void spacePressed(TQListViewItem *); void spacePressed(TQListViewItem *);
%End
void rightButtonClicked(TQListViewItem *,const TQPoint &,int); void rightButtonClicked(TQListViewItem *,const TQPoint &,int);
void rightButtonPressed(TQListViewItem *,const TQPoint &,int); void rightButtonPressed(TQListViewItem *,const TQPoint &,int);
%If (TQt_2_1_0 -)
void mouseButtonPressed(int,TQListViewItem *,const TQPoint &,int); void mouseButtonPressed(int,TQListViewItem *,const TQPoint &,int);
void mouseButtonClicked(int,TQListViewItem *,const TQPoint &,int); void mouseButtonClicked(int,TQListViewItem *,const TQPoint &,int);
%End
%If (TQt_3_0_0 -)
void contextMenuRequested(TQListViewItem *,const TQPoint &,int); void contextMenuRequested(TQListViewItem *,const TQPoint &,int);
%End
%If (TQt_2_1_0 -)
void onItem(TQListViewItem *); void onItem(TQListViewItem *);
void onViewport(); void onViewport();
void expanded(TQListViewItem *); void expanded(TQListViewItem *);
void collapsed(TQListViewItem *); void collapsed(TQListViewItem *);
%End
%If (TQt_3_0_0 -)
void dropped(TQDropEvent *); void dropped(TQDropEvent *);
void itemRenamed(TQListViewItem *,int,const TQString &); void itemRenamed(TQListViewItem *,int,const TQString &);
void itemRenamed(TQListViewItem *,int); void itemRenamed(TQListViewItem *,int);
%End
protected: 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 contentsMousePressEvent(TQMouseEvent *);
void contentsMouseReleaseEvent(TQMouseEvent *); void contentsMouseReleaseEvent(TQMouseEvent *);
void contentsMouseMoveEvent(TQMouseEvent *); void contentsMouseMoveEvent(TQMouseEvent *);
void contentsMouseDoubleClickEvent(TQMouseEvent *); void contentsMouseDoubleClickEvent(TQMouseEvent *);
%End
%If (TQt_3_0_0 -)
void contentsContextMenuEvent(TQContextMenuEvent *); void contentsContextMenuEvent(TQContextMenuEvent *);
void contentsDragEnterEvent(TQDragEnterEvent *); void contentsDragEnterEvent(TQDragEnterEvent *);
void contentsDragMoveEvent(TQDragMoveEvent *); void contentsDragMoveEvent(TQDragMoveEvent *);
@ -558,7 +363,6 @@ protected:
void contentsDropEvent(TQDropEvent *); void contentsDropEvent(TQDropEvent *);
virtual TQDragObject *dragObject(); virtual TQDragObject *dragObject();
virtual void startDrag(); virtual void startDrag();
%End
void focusInEvent(TQFocusEvent *); void focusInEvent(TQFocusEvent *);
void focusOutEvent(TQFocusEvent *); void focusOutEvent(TQFocusEvent *);
@ -566,37 +370,22 @@ protected:
void keyPressEvent(TQKeyEvent *); void keyPressEvent(TQKeyEvent *);
void resizeEvent(TQResizeEvent *); void resizeEvent(TQResizeEvent *);
%If (TQt_3_0_0 -)
void viewportResizeEvent(TQResizeEvent *); void viewportResizeEvent(TQResizeEvent *);
%End
%If (TQt_2_00 -)
void showEvent(TQShowEvent *); void showEvent(TQShowEvent *);
%End
void drawContentsOffset(TQPainter *,int,int,int,int,int,int); void drawContentsOffset(TQPainter *,int,int,int,int,int,int);
virtual void paintEmptyArea(TQPainter *,const TQRect &); virtual void paintEmptyArea(TQPainter *,const TQRect &);
%If (TQt_2_00 -)
void styleChange(TQStyle &); void styleChange(TQStyle &);
%End
%If (- TQt_3_0_0)
void enabledChange(bool);
%End
%If (TQt_3_0_0 -)
void windowActivationChange(bool); void windowActivationChange(bool);
%End
protected slots: protected slots:
void updateContents(); void updateContents();
%If (TQt_2_00 -)
void doAutoScroll(); void doAutoScroll();
%End
private: private:
%If (TQt_2_1_0 -)
TQListView(const TQWidget &); TQListView(const TQWidget &);
%End
}; };
@ -611,21 +400,16 @@ public:
RadioButton, RadioButton,
CheckBox, CheckBox,
Controller, Controller,
%If (TQt_3_2_0 -)
RadioButtonController, RadioButtonController,
CheckBoxController, CheckBoxController,
%End
}; };
%If (TQt_3_2_0 -)
enum ToggleState { enum ToggleState {
Off, Off,
NoChange, NoChange,
On On
}; };
%End
%If (TQt_3_2_0 -)
TQCheckListItem(TQCheckListItem * /TransferThis/,const TQString &, TQCheckListItem(TQCheckListItem * /TransferThis/,const TQString &,
Type = RadioButtonController); Type = RadioButtonController);
TQCheckListItem(TQCheckListItem * /TransferThis/,TQListViewItem *, TQCheckListItem(TQCheckListItem * /TransferThis/,TQListViewItem *,
@ -638,91 +422,36 @@ public:
Type = RadioButtonController); Type = RadioButtonController);
TQCheckListItem(TQListView * /TransferThis/,TQListViewItem *, TQCheckListItem(TQListView * /TransferThis/,TQListViewItem *,
const TQString &,Type = RadioButtonController); 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 &, TQCheckListItem(TQListViewItem * /TransferThis/,const TQString &,
const TQPixmap &); const TQPixmap &);
TQCheckListItem(TQListView * /TransferThis/,const TQString &, TQCheckListItem(TQListView * /TransferThis/,const TQString &,
const TQPixmap &); 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); void paintCell(TQPainter *,const TQColorGroup &,int,int,int);
%If (TQt_2_00 -)
virtual void paintFocus(TQPainter *,const TQColorGroup &,const TQRect &); virtual void paintFocus(TQPainter *,const TQColorGroup &,const TQRect &);
%End
int width(const TQFontMetrics &,const TQListView *,int) const; int width(const TQFontMetrics &,const TQListView *,int) const;
void setup(); void setup();
%If (- TQt_2_00)
void setOn(bool);
%End
%If (TQt_2_00 -)
virtual void setOn(bool); virtual void setOn(bool);
%End
bool isOn() const; bool isOn() const;
Type type() 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() const;
TQString text(int) const; TQString text(int) const;
%End
%If (TQt_3_2_0 -)
void setTristate(bool); void setTristate(bool);
bool isTristate() const; bool isTristate() const;
ToggleState state() const; ToggleState state() const;
void setState(ToggleState); void setState(ToggleState);
%End
%If (TQt_3_0_0 -)
int rtti() const; int rtti() const;
%End
protected: protected:
%If (- TQt_3_0_0)
void paintBranches(TQPainter *,const TQColorGroup &,int,int,int,GUIStyle);
%End
void activate(); void activate();
void turnOffChild(); void turnOffChild();
virtual void stateChange(bool); virtual void stateChange(bool);
}; };
%If (TQt_2_00 -)
class TQListViewItemIterator class TQListViewItemIterator
{ {
%TypeHeaderCode %TypeHeaderCode
@ -730,7 +459,6 @@ class TQListViewItemIterator
%End %End
public: public:
%If (TQt_3_2_0 -)
enum IteratorFlag { enum IteratorFlag {
Visible, Visible,
Invisible, Invisible,
@ -747,24 +475,17 @@ public:
Checked, Checked,
NotChecked NotChecked
}; };
%End
TQListViewItemIterator(); TQListViewItemIterator();
TQListViewItemIterator(TQListViewItem *); TQListViewItemIterator(TQListViewItem *);
%If (TQt_3_2_0 -)
TQListViewItemIterator(TQListViewItem *,int); TQListViewItemIterator(TQListViewItem *,int);
%End
TQListViewItemIterator(const TQListViewItemIterator &); TQListViewItemIterator(const TQListViewItemIterator &);
TQListViewItemIterator(TQListView *); TQListViewItemIterator(TQListView *);
%If (TQt_3_2_0 -)
TQListViewItemIterator(TQListView *,int); TQListViewItemIterator(TQListView *,int);
%End
TQListViewItemIterator &operator+=(int); TQListViewItemIterator &operator+=(int);
TQListViewItemIterator &operator-=(int); TQListViewItemIterator &operator-=(int);
TQListViewItem *current() const; TQListViewItem *current() const;
}; };
%End

@ -19,6 +19,7 @@
// PyTQt; see the file LICENSE. If not, write to the Free Software Foundation, // PyTQt; see the file LICENSE. If not, write to the Free Software Foundation,
// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
%DefaultEncoding "UTF-8"
%ExportedDoc %ExportedDoc
<Sect2><Title>TQMainWindow</Title> <Sect2><Title>TQMainWindow</Title>

@ -50,7 +50,7 @@ converted to and from Python lists of the type.
// Get it. // Get it.
for (uint i = 0; i < sipCpp -> size(); ++i) 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); 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) 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) if (PyErr_Occurred() != NULL)
{ {

@ -403,7 +403,11 @@ public:
// the true (Python) class name. // the true (Python) class name.
SIP_PYOBJECT className() const; SIP_PYOBJECT className() const;
%MethodCode %MethodCode
#if PY_MAJOR_VERSION >= 3
sipRes = PyUnicode_FromString(sipSelf->ob_type->tp_name);
#else
sipRes = sipClassName(sipSelf); sipRes = sipClassName(sipSelf);
#endif
%End %End
%If (- TQt_3_0_0) %If (- TQt_3_0_0)
@ -425,49 +429,69 @@ public:
// trUtf8() methods for a Python sub-class instance in the sub-class's // trUtf8() methods for a Python sub-class instance in the sub-class's
// ctor. // ctor.
TQString tr(const char *,const char * = 0); TQString tr(SIP_PYOBJECT sourceText /TypeHint="str"/,const char * = 0);
%MethodCode %MethodCode
PyObject *nmobj; if (tqApp)
{
const char *source = PyTQt_qt_encode(&a0, TQApplication::DefaultCodec);
if ((nmobj = sipClassName(sipSelf)) == NULL) if (source)
sipIsErr = 1; {
sipRes = new TQString(tqApp->translate(Py_TYPE(sipSelf)->tp_name, source,
a1, TQApplication::DefaultCodec));
Py_DECREF(a0);
}
else
{
sipIsErr = 1;
}
}
else else
{ {
char *cname = PyString_AsString(nmobj); const char *source = sipString_AsLatin1String(&a0);
Py_BEGIN_ALLOW_THREADS if (source)
{
if (cname && tqApp) sipRes = new TQString(QString::fromLatin1(source));
sipRes = new TQString(tqApp -> translate(cname,a0,a1,TQApplication::DefaultCodec)); Py_DECREF(a0);
}
else else
sipRes = new TQString(TQString::fromLatin1(a0)); {
sipIsErr = 1;
Py_END_ALLOW_THREADS }
Py_DECREF(nmobj);
} }
%End %End
TQString trUtf8(const char *,const char * = 0); TQString trUtf8(SIP_PYOBJECT sourceText /TypeHint="str"/,const char * = 0);
%MethodCode %MethodCode
PyObject *nmobj; if (tqApp)
{
const char *source = PyTQt_qt_encode(&a0, TQApplication::DefaultCodec);
if ((nmobj = sipClassName(sipSelf)) == NULL) if (source)
sipIsErr = 1; {
sipRes = new TQString(tqApp->translate(Py_TYPE(sipSelf)->tp_name, source,
a1, TQApplication::UnicodeUTF8));
Py_DECREF(a0);
}
else
{
sipIsErr = 1;
}
}
else else
{ {
char *cname = PyString_AsString(nmobj); const char *source = sipString_AsLatin1String(&a0);
Py_BEGIN_ALLOW_THREADS
if (cname && tqApp) if (source)
sipRes = new TQString(tqApp -> translate(cname,a0,a1,TQApplication::UnicodeUTF8)); {
sipRes = new TQString(TQString::fromLatin1(source));
Py_DECREF(a0);
}
else else
sipRes = new TQString(TQString::fromUtf8(a0)); {
sipIsErr = 1;
Py_END_ALLOW_THREADS }
Py_DECREF(nmobj);
} }
%End %End
%End %End
@ -811,7 +835,11 @@ public:
// it we can ignore it. // it we can ignore it.
SIP_PYOBJECT className() const; SIP_PYOBJECT className() const;
%MethodCode %MethodCode
#if PY_MAJOR_VERSION >= 3
sipRes = PyUnicode_FromString(sipSelf->ob_type->tp_name);
#else
sipRes = sipClassName(sipSelf); sipRes = sipClassName(sipSelf);
#endif
%End %End
bool isA(const char *) const; bool isA(const char *) const;
@ -866,7 +894,7 @@ private:
%End %End
SIP_PYOBJECT SLOT(const char *); SIP_PYOBJECT SLOT(const char * /Encoding="ASCII"/) /TypeHint="QT_SLOT"/;
%MethodCode %MethodCode
if (!a0) if (!a0)
{ {
@ -877,11 +905,11 @@ SIP_PYOBJECT SLOT(const char *);
{ {
int len = strlen(a0); int len = strlen(a0);
if ((sipRes = PyString_FromStringAndSize(NULL,1 + len)) == NULL) if ((sipRes = SIPBytes_FromStringAndSize(NULL,1 + len)) == NULL)
sipIsErr = 1; sipIsErr = 1;
else else
{ {
char *dp = PyString_AS_STRING(sipRes); char *dp = SIPBytes_AS_STRING(sipRes);
*dp++ = '1'; *dp++ = '1';
@ -891,7 +919,7 @@ SIP_PYOBJECT SLOT(const char *);
%End %End
SIP_PYOBJECT SIGNAL(const char *); SIP_PYOBJECT SIGNAL(const char * /Encoding="ASCII"/) /TypeHint="QT_SIGNAL"/;
%MethodCode %MethodCode
if (!a0) if (!a0)
{ {
@ -902,11 +930,11 @@ SIP_PYOBJECT SIGNAL(const char *);
{ {
int len = strlen(a0); int len = strlen(a0);
if ((sipRes = PyString_FromStringAndSize(NULL,1 + len)) == NULL) if ((sipRes = SIPBytes_FromStringAndSize(NULL,1 + len)) == NULL)
sipIsErr = 1; sipIsErr = 1;
else else
{ {
char *dp = PyString_AS_STRING(sipRes); char *dp = SIPBytes_AS_STRING(sipRes);
*dp++ = '2'; *dp++ = '2';
@ -916,7 +944,7 @@ SIP_PYOBJECT SIGNAL(const char *);
%End %End
SIP_PYOBJECT PYSIGNAL(const char *); SIP_PYOBJECT PYSIGNAL(const char * /Encoding="ASCII"/);
%MethodCode %MethodCode
if (!a0) if (!a0)
{ {
@ -927,11 +955,11 @@ SIP_PYOBJECT PYSIGNAL(const char *);
{ {
int len = strlen(a0); int len = strlen(a0);
if ((sipRes = PyString_FromStringAndSize(NULL,1 + len)) == NULL) if ((sipRes = SIPBytes_FromStringAndSize(NULL,1 + len)) == NULL)
sipIsErr = 1; sipIsErr = 1;
else else
{ {
char *dp = PyString_AS_STRING(sipRes); char *dp = SIPBytes_AS_STRING(sipRes);
*dp++ = '9'; *dp++ = '9';
@ -992,16 +1020,30 @@ extern "C" {
// The meta-type for PyTQt classes. It is just a marker type so that we can // 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. // safely cast to get access to PyTQt3-specific data structures.
PyTypeObject pyqtWrapperType_Type = { PyTypeObject pyqtWrapperType_Type = {
#if PY_MAJOR_VERSION >= 3
PyVarObject_HEAD_INIT(NULL, 0)
#else
PyObject_HEAD_INIT(NULL) PyObject_HEAD_INIT(NULL)
0, /* ob_size */ 0, /* ob_size */
#endif
"qt.pyqtWrapperType", /* tp_name */ "qt.pyqtWrapperType", /* tp_name */
sizeof (sipWrapperType), /* tp_basicsize */ sizeof (sipWrapperType), /* tp_basicsize */
0, /* tp_itemsize */ 0, /* tp_itemsize */
0, /* tp_dealloc */ 0, /* tp_dealloc */
#if PY_VERSION_HEX >= 0x03080000
0, /* tp_vectorcall_offset */
#else
0, /* tp_print */ 0, /* tp_print */
#endif
0, /* tp_getattr */ 0, /* tp_getattr */
0, /* tp_setattr */ 0, /* tp_setattr */
#if PY_VERSION_HEX >= 0x03050000
0, /* tp_as_async */
#elif PY_VERSION_HEX >= 0x03010000
0, /* tp_reserved */
#else
0, /* tp_compare */ 0, /* tp_compare */
#endif
0, /* tp_repr */ 0, /* tp_repr */
0, /* tp_as_number */ 0, /* tp_as_number */
0, /* tp_as_sequence */ 0, /* tp_as_sequence */
@ -1042,6 +1084,15 @@ PyTypeObject pyqtWrapperType_Type = {
#if PY_VERSION_HEX >= 0x02060000 #if PY_VERSION_HEX >= 0x02060000
0, /* tp_version_tag */ 0, /* tp_version_tag */
#endif #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 #endif
{ {
#if PY_MAJOR_VERSION >= 3
PyVarObject_HEAD_INIT(&pyqtWrapperType_Type, 0)
#else
PyObject_HEAD_INIT(&pyqtWrapperType_Type) PyObject_HEAD_INIT(&pyqtWrapperType_Type)
0, /* ob_size */ 0, /* ob_size */
#endif
"qt.pyqtWrapper", /* tp_name */ "qt.pyqtWrapper", /* tp_name */
sizeof (pyqtWrapper), /* tp_basicsize */ sizeof (pyqtWrapper), /* tp_basicsize */
0, /* tp_itemsize */ 0, /* tp_itemsize */
(destructor)pyqtWrapper_dealloc, /* tp_dealloc */ (destructor)pyqtWrapper_dealloc, /* tp_dealloc */
#if PY_VERSION_HEX >= 0x03080000
0, /* tp_vectorcall_offset */
#else
0, /* tp_print */ 0, /* tp_print */
#endif
0, /* tp_getattr */ 0, /* tp_getattr */
0, /* tp_setattr */ 0, /* tp_setattr */
#if PY_VERSION_HEX >= 0x03050000
0, /* tp_as_async */
#elif PY_VERSION_HEX >= 0x03010000
0, /* tp_reserved */
#else
0, /* tp_compare */ 0, /* tp_compare */
#endif
0, /* tp_repr */ 0, /* tp_repr */
0, /* tp_as_number */ 0, /* tp_as_number */
0, /* tp_as_sequence */ 0, /* tp_as_sequence */
@ -1245,6 +1310,15 @@ static sipWrapperType pyqtWrapper_Type = {
0, /* tp_del */ 0, /* tp_del */
#if PY_VERSION_HEX >= 0x02060000 #if PY_VERSION_HEX >= 0x02060000
0, /* tp_version_tag */ 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 #endif
}, },
#if !defined(STACKLESS) #if !defined(STACKLESS)
@ -1500,17 +1574,17 @@ bool UniversalSlot::tqt_invoke(int id, TQUObject *qargs)
case char_sat: case char_sat:
case schar_sat: case schar_sat:
case uchar_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; break;
case string_sat: case string_sat:
case sstring_sat: case sstring_sat:
case ustring_sat: case ustring_sat:
arg = PyString_FromString((char *)static_QUType_ptr.get(qargs)); arg = SIPBytes_FromString((char *)static_QUType_ptr.get(qargs));
break; break;
case short_sat: case short_sat:
arg = PyInt_FromLong(*(short *)static_QUType_ptr.get(qargs)); arg = PyLong_FromLong(*(short *)static_QUType_ptr.get(qargs));
break; break;
case ushort_sat: case ushort_sat:
@ -1519,9 +1593,9 @@ bool UniversalSlot::tqt_invoke(int id, TQUObject *qargs)
case int_sat: case int_sat:
if (qv) if (qv)
arg = PyInt_FromLong(qv -> asInt()); arg = PyLong_FromLong(qv -> asInt());
else else
arg = PyInt_FromLong(static_QUType_int.get(qargs)); arg = PyLong_FromLong(static_QUType_int.get(qargs));
break; break;
case uint_sat: case uint_sat:
@ -1557,7 +1631,7 @@ bool UniversalSlot::tqt_invoke(int id, TQUObject *qargs)
break; break;
case bool_sat: case bool_sat:
arg = PyInt_FromLong(static_QUType_bool.get(qargs)); arg = PyLong_FromLong(static_QUType_bool.get(qargs));
break; break;
case void_sat: case void_sat:
@ -1628,7 +1702,14 @@ static void *sipTQtCreateUniversalSlot(sipWrapper *tx, const char *sig,
pyqt3SlotConnection conn; pyqt3SlotConnection conn;
/* Initialise the connection. */ /* 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. */ /* Save the real slot. */
if (sipSaveSlot(&conn.sc_slot, rxObj, slot) < 0) if (sipSaveSlot(&conn.sc_slot, rxObj, slot) < 0)

@ -289,7 +289,7 @@ public:
do do
{ {
if (PyList_SetItem(sipRes,len,PyInt_FromLong((long)*tp)) < 0) if (PyList_SetItem(sipRes,len,PyLong_FromLong((long)*tp)) < 0)
{ {
Py_DECREF(sipRes); Py_DECREF(sipRes);
sipIsErr = 1; sipIsErr = 1;
@ -316,11 +316,11 @@ public:
{ {
// Convert the list. // Convert the list.
int *tp = tabs; long *tp = tabs;
for (int i = 0; i < len; ++i) 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) if (PyErr_Occurred() != NULL)
{ {
@ -612,7 +612,7 @@ public:
do do
{ {
if (PyList_SetItem(sipRes,len,PyInt_FromLong((long)*tp)) < 0) if (PyList_SetItem(sipRes,len,PyLong_FromLong((long)*tp)) < 0)
{ {
Py_DECREF(sipRes); Py_DECREF(sipRes);
sipIsErr = 1; sipIsErr = 1;
@ -643,7 +643,7 @@ public:
for (int i = 0; i < len; ++i) 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) if (PyErr_Occurred() != NULL)
{ {

@ -51,8 +51,8 @@ converted to and from Python tuples of two elements.
// Fill it. // Fill it.
PyTuple_SET_ITEM(t,0,PyInt_FromLong((long)sipCpp -> first)); PyTuple_SET_ITEM(t,0,PyLong_FromLong((long)sipCpp -> first));
PyTuple_SET_ITEM(t,1,PyInt_FromLong((long)sipCpp -> second)); PyTuple_SET_ITEM(t,1,PyLong_FromLong((long)sipCpp -> second));
return t; return t;
%End %End
@ -65,8 +65,8 @@ converted to and from Python tuples of two elements.
PyErr_Clear(); PyErr_Clear();
int fst = (int)PyInt_AsLong(PyTuple_GET_ITEM(sipPy,0)); int fst = (int)PyLong_AsLong(PyTuple_GET_ITEM(sipPy,0));
int sec = (int)PyInt_AsLong(PyTuple_GET_ITEM(sipPy,1)); int sec = (int)PyLong_AsLong(PyTuple_GET_ITEM(sipPy,1));
if (PyErr_Occurred() != NULL) if (PyErr_Occurred() != NULL)
{ {

@ -109,7 +109,7 @@ static TQCOORD *getPoints(int nrpnts,PyObject *pntlist)
for (int i = 0; i < nrpnts; ++i) 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) if (PyErr_Occurred() != NULL)
{ {

@ -19,6 +19,7 @@
// PyTQt; see the file LICENSE. If not, write to the Free Software Foundation, // PyTQt; see the file LICENSE. If not, write to the Free Software Foundation,
// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
%DefaultEncoding "UTF-8"
%ExportedDoc %ExportedDoc
<Sect2><Title>TQPushButton</Title> <Sect2><Title>TQPushButton</Title>

@ -195,53 +195,8 @@ public:
static const TQChar replacement; static const TQChar replacement;
static const TQChar byteOrderMark; static const TQChar byteOrderMark;
static const TQChar byteOrderSwapped; static const TQChar byteOrderSwapped;
%If (TQt_2_2_0 -)
static const TQChar nbsp; 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 { enum Category {
NoCategory, NoCategory,
@ -282,24 +237,7 @@ public:
Symbol_Modifier, Symbol_Modifier,
Symbol_Other 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 { enum Direction {
DirL, DirL,
DirR, DirR,
@ -321,7 +259,6 @@ public:
DirNSM, DirNSM,
DirBN DirBN
}; };
%End
enum Decomposition { enum Decomposition {
Single, Single,
@ -351,7 +288,6 @@ public:
Center Center
}; };
%If (TQt_3_0_0 -)
enum CombiningClass { enum CombiningClass {
Combining_BelowLeftAttached, Combining_BelowLeftAttached,
Combining_BelowAttached, Combining_BelowAttached,
@ -375,7 +311,6 @@ public:
Combining_DoubleAbove, Combining_DoubleAbove,
Combining_IotaSubscript Combining_IotaSubscript
}; };
%End
int digitValue() const; int digitValue() const;
TQChar lower() const; TQChar lower() const;
@ -385,19 +320,10 @@ public:
Direction direction() const; Direction direction() const;
Joining joining() const; Joining joining() const;
bool mirrored() const; bool mirrored() const;
%If (TQt_2_1_0 -)
TQChar mirroredChar() const; TQChar mirroredChar() const;
%End
%If (- TQt_3_0_0)
TQString decomposition() const;
%End
%If (TQt_3_0_0 -)
const TQString &decomposition() const; const TQString &decomposition() const;
%End
Decomposition decompositionTag() const; Decomposition decompositionTag() const;
%If (TQt_3_0_0 -)
unsigned char combiningClass() const; unsigned char combiningClass() const;
%End
char latin1() const; char latin1() const;
ushort unicode() const; ushort unicode() const;
@ -409,22 +335,16 @@ public:
bool isMark() const; bool isMark() const;
bool isLetter() const; bool isLetter() const;
bool isNumber() const; bool isNumber() const;
%If (TQt_2_1_0 -)
bool isLetterOrNumber() const; bool isLetterOrNumber() const;
%End
bool isDigit() const; bool isDigit() const;
%If (TQt_3_0_0 -)
bool isSymbol() const; bool isSymbol() const;
%End
// uchar& cell(); // uchar& cell();
// uchar& row(); // uchar& row();
uchar cell() const; uchar cell() const;
uchar row() const; uchar row() const;
%If (TQt_3_0_0 -)
void setCell(uchar); void setCell(uchar);
void setRow(uchar); void setRow(uchar);
%End
static bool networkOrdered(); static bool networkOrdered();
}; };
@ -447,6 +367,7 @@ class TQString
{ {
%TypeHeaderCode %TypeHeaderCode
#include <tqstring.h> #include <tqstring.h>
#include <tqtextcodec.h>
%End %End
public: public:
@ -457,18 +378,14 @@ public:
// TQString(const TQChar *,uint); // TQString(const TQChar *,uint);
// TQString(const char *); // TQString(const char *);
%If (TQt_2_1_0 -)
// This is how we implement TQUrl::operator TQString() const. // This is how we implement TQUrl::operator TQString() const.
TQString(const TQUrl &); TQString(const TQUrl &);
%End
%If (TQt_3_0_0 -)
// This is how we implement TQKeySequence::operator TQString() const. // This is how we implement TQKeySequence::operator TQString() const.
TQString(const TQKeySequence &); TQString(const TQKeySequence &);
// This is how we implement TQUuid::operator TQString() const. // This is how we implement TQUuid::operator TQString() const.
TQString(const TQUuid &); TQString(const TQUuid &);
%End
static const TQString null; static const TQString null;
@ -476,20 +393,13 @@ public:
bool isEmpty() const; bool isEmpty() const;
uint length() const; uint length() const;
void truncate(uint); void truncate(uint);
%If (- TQt_3_0_0)
void fill(TQChar,int = -1);
%End
%If (TQt_3_0_0 -)
TQString &fill(TQChar,int = -1); TQString &fill(TQChar,int = -1);
%End
TQString copy() const; TQString copy() const;
TQString arg(int /Constrained/,int = 0,int = 10) const; TQString arg(int /Constrained/,int = 0,int = 10) const;
TQString arg(double /Constrained/,int = 0,char = 'g',int = -1) 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_LLONG,int = 0,int = 10) const;
// TQString arg(TQ_ULLONG,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(long,int = 0,int = 10) const;
TQString arg(ulong,int = 0,int = 10) const; TQString arg(ulong,int = 0,int = 10) const;
// TQString arg(uint,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(char,int = 0) const;
TQString arg(TQChar,int = 0) const; TQString arg(TQChar,int = 0) const;
TQString arg(const TQString&,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 arg(const TQString &,const TQString &,const TQString &) const; TQString arg(const TQString &,const TQString &,const TQString &) const;
TQString arg(const TQString &,const TQString &,const TQString &, TQString arg(const TQString &,const TQString &,const TQString &,
const TQString &) const; const TQString &) const;
%End
// TQString &sprintf(const char *,...); // TQString &sprintf(const char *,...);
@ -523,7 +431,6 @@ public:
int contains(const TQString &,bool = 1) const; int contains(const TQString &,bool = 1) const;
int contains(const TQRegExp &) const; int contains(const TQRegExp &) const;
%If (TQt_3_0_0 -)
enum SectionFlags { enum SectionFlags {
SectionDefault, SectionDefault,
SectionSkipEmpty, SectionSkipEmpty,
@ -540,7 +447,6 @@ public:
int = SectionDefault) const; int = SectionDefault) const;
TQString section(const TQRegExp &,int,int = 0xffffffff, TQString section(const TQRegExp &,int,int = 0xffffffff,
int = SectionDefault) const; int = SectionDefault) const;
%End
TQString left(uint) const; TQString left(uint) const;
TQString right(uint) const; TQString right(uint) const;
@ -553,56 +459,36 @@ public:
TQString simplifyWhiteSpace() const; TQString simplifyWhiteSpace() const;
TQString &insert(uint,const TQString &); TQString &insert(uint,const TQString &);
%If (TQt_3_2_0 -)
TQString &insert(uint,const TQByteArray &); TQString &insert(uint,const TQByteArray &);
// TQString &insert(uint,const char *); // TQString &insert(uint,const char *);
%End
TQString &insert(uint,TQChar *,uint); TQString &insert(uint,TQChar *,uint);
TQString &insert(uint,TQChar); TQString &insert(uint,TQChar);
TQString &insert(uint,char); TQString &insert(uint,char);
TQString &append(char); TQString &append(char);
%If (TQt_2_2_0 -)
TQString &append(TQChar); TQString &append(TQChar);
%End
TQString &append(const TQString &); TQString &append(const TQString &);
TQString &prepend(char); TQString &prepend(char);
%If (TQt_2_2_0 -)
TQString &prepend(TQChar); TQString &prepend(TQChar);
%End
TQString &prepend(const TQString &); TQString &prepend(const TQString &);
TQString &remove(uint,uint); TQString &remove(uint,uint);
%If (TQt_3_1_0 -)
TQString &remove(const TQString &); TQString &remove(const TQString &);
%If (TQt_3_2_0 -)
TQString &remove(const TQString &,bool); TQString &remove(const TQString &,bool);
%End
TQString &remove(TQChar); TQString &remove(TQChar);
TQString &remove(char); TQString &remove(char);
TQString &remove(const TQRegExp &); TQString &remove(const TQRegExp &);
%End
TQString &replace(uint,uint,const TQString &); TQString &replace(uint,uint,const TQString &);
TQString &replace(uint,uint,const TQChar *,uint); TQString &replace(uint,uint,const TQChar *,uint);
%If (TQt_3_1_0 -)
TQString &replace(uint,uint,TQChar); TQString &replace(uint,uint,TQChar);
TQString &replace(uint,uint,char); TQString &replace(uint,uint,char);
TQString &replace(TQChar,const TQString &); TQString &replace(TQChar,const TQString &);
%If (TQt_3_2_0 -)
TQString &replace(TQChar,const TQString &,bool); TQString &replace(TQChar,const TQString &,bool);
%End
TQString &replace(char,const TQString &); TQString &replace(char,const TQString &);
%If (TQt_3_2_0 -)
TQString &replace(char,const TQString &,bool); TQString &replace(char,const TQString &,bool);
%End
TQString &replace(const TQString &,const TQString &); TQString &replace(const TQString &,const TQString &);
%If (TQt_3_2_0 -)
TQString &replace(const TQString &,const TQString &,bool); TQString &replace(const TQString &,const TQString &,bool);
%End
%End
TQString &replace(const TQRegExp &,const TQString &); TQString &replace(const TQRegExp &,const TQString &);
%If (TQt_3_1_0 -)
TQString &replace(TQChar,TQChar); TQString &replace(TQChar,TQChar);
%End
short toShort(bool * = 0,int = 10) const; short toShort(bool * = 0,int = 10) const;
ushort toUShort(bool * = 0,int = 10) const; ushort toUShort(bool * = 0,int = 10) const;
@ -610,10 +496,8 @@ public:
uint toUInt(bool * = 0,int = 10) const; uint toUInt(bool * = 0,int = 10) const;
long toLong(bool * = 0,int = 10) const; long toLong(bool * = 0,int = 10) const;
ulong toULong(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_LLONG toLongLong(bool * = 0,int = 10) const;
// TQ_ULLONG toULongLong(bool * = 0,int = 10) const; // TQ_ULLONG toULongLong(bool * = 0,int = 10) const;
%End
float toFloat(bool * = 0) const; float toFloat(bool * = 0) const;
double toDouble(bool * = 0) const; double toDouble(bool * = 0) const;
@ -624,28 +508,22 @@ public:
// TQString &setNum(uint,int = 10); // TQString &setNum(uint,int = 10);
TQString &setNum(long,int = 10); TQString &setNum(long,int = 10);
TQString &setNum(ulong,int = 10); TQString &setNum(ulong,int = 10);
%If (TQt_3_2_0 -)
// TQString &setNum(TQ_LLONG,int = 10); // TQString &setNum(TQ_LLONG,int = 10);
// TQString &setNum(TQ_ULLONG,int = 10); // TQString &setNum(TQ_ULLONG,int = 10);
%End
// TQString &setNum(float,char = 'g',int = 6); // TQString &setNum(float,char = 'g',int = 6);
static TQString number(int /Constrained/,int = 10); static TQString number(int /Constrained/,int = 10);
static TQString number(double /Constrained/,char = 'g',int = 6); static TQString number(double /Constrained/,char = 'g',int = 6);
static TQString number(long,int = 10); static TQString number(long,int = 10);
static TQString number(ulong,int = 10); static TQString number(ulong,int = 10);
%If (TQt_3_2_0 -)
// static TQString number(TQ_LLONG,int = 10); // static TQString number(TQ_LLONG,int = 10);
// static TQString number(TQ_ULLONG,int = 10); // static TQString number(TQ_ULLONG,int = 10);
%End
// static TQString number(uint,int = 10); // static TQString number(uint,int = 10);
void setExpand(uint,TQChar); void setExpand(uint,TQChar);
TQString &operator+=(const TQString &); TQString &operator+=(const TQString &);
%If (TQt_3_3_0 -)
TQString &operator+=(const TQByteArray &); TQString &operator+=(const TQByteArray &);
%End
TQString &operator+=(TQChar); TQString &operator+=(TQChar);
//TQString &operator+=(char); //TQString &operator+=(char);
@ -673,9 +551,7 @@ public:
// TQChar &ref(uint); // TQChar &ref(uint);
// const TQChar *unicode() const; // const TQChar *unicode() const;
const char *ascii() const; const char *ascii() const;
%If (TQt_3_1_0 -)
static TQString fromAscii(const char *,int = -1); static TQString fromAscii(const char *,int = -1);
%End
const char *latin1() const; const char *latin1() const;
static TQString fromLatin1(const char *,int = -1); static TQString fromLatin1(const char *,int = -1);
TQCString utf8() const; TQCString utf8() const;
@ -683,62 +559,34 @@ public:
TQCString local8Bit() const; TQCString local8Bit() const;
static TQString fromLocal8Bit(const char *,int = -1); static TQString fromLocal8Bit(const char *,int = -1);
%If (TQt_3_1_0 -)
// static TQString fromUcs2(const unsigned short *); // static TQString fromUcs2(const unsigned short *);
// const unsigned short *ucs2() const; // const unsigned short *ucs2() const;
%End
%If (TQt_2_1_0 -)
// TQString &setUnicode(const TQChar *,uint); // TQString &setUnicode(const TQChar *,uint);
// TQString &setUnicodeCodes(const ushort *,uint); // TQString &setUnicodeCodes(const ushort *,uint);
%End
%If (TQt_3_1_0 -)
TQString &setAscii(const char *,int = -1); TQString &setAscii(const char *,int = -1);
%End
%If (TQt_2_1_0 -)
TQString &setLatin1(const char *,int = -1); TQString &setLatin1(const char *,int = -1);
%End
int compare(const TQString &) const; int compare(const TQString &) const;
static int compare(const TQString &,const TQString &); static int compare(const TQString &,const TQString &);
%If (TQt_3_0_0 -)
int localeAwareCompare(const TQString &) const; int localeAwareCompare(const TQString &) const;
static int localeAwareCompare(const TQString &,const TQString &); static int localeAwareCompare(const TQString &,const TQString &);
%End
void compose(); 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; bool startsWith(const TQString &) const;
%End
%If (TQt_3_2_0 -)
bool startsWith(const TQString &,bool) const; bool startsWith(const TQString &,bool) const;
%End
%If (TQt_3_0_0 -)
bool endsWith(const TQString &) const; bool endsWith(const TQString &) const;
%End
%If (TQt_3_2_0 -)
bool endsWith(const TQString &,bool) const; bool endsWith(const TQString &,bool) const;
%End
%If (TQt_3_0_0 -)
void setLength(uint); void setLength(uint);
%End
%If (TQt_3_2_0 -)
uint capacity() const; uint capacity() const;
void reserve(uint); void reserve(uint);
void squeeze(); void squeeze();
%End
%If (TQt_3_0_0 -)
bool simpleText() const; bool simpleText() const;
bool isRightToLeft() const; bool isRightToLeft() const;
%End
// Force the numeric interpretation so that str + TQString gets handled // Force the numeric interpretation so that str + TQString gets handled
// as we want. // as we want.
@ -792,81 +640,12 @@ public:
SIP_PYOBJECT __unicode__(); SIP_PYOBJECT __unicode__();
%MethodCode %MethodCode
#if PY_VERSION_HEX >= 0x01060000 sipRes = PyTQt_qt_PyObject_FromTQString(sipCpp);
sipRes = TQStringToPyUnicode(sipCpp);
#else
Py_INCREF(Py_None);
sipRes = Py_None;
#endif
%End %End
SIP_PYOBJECT __str__(); SIP_PYOBJECT __str__();
%MethodCode %MethodCode
#if PY_VERSION_HEX >= 0x01060000 sipRes = PyTQt_qt_PyObject_FromTQString(sipCpp);
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;
}
%End %End
%ConvertToTypeCode %ConvertToTypeCode
@ -874,13 +653,11 @@ static TQString *PyUnicodeStringToTQString(PyObject *py)
// expected. // expected.
if (sipIsErr == NULL) if (sipIsErr == NULL)
return (PyString_Check(sipPy) || return (SIPBytes_Check(sipPy) ||
#if PY_VERSION_HEX >= 0x01060000
PyUnicode_Check(sipPy) || PyUnicode_Check(sipPy) ||
#endif
sipCanConvertToInstance(sipPy,sipClass_TQString,SIP_NO_CONVERTORS)); sipCanConvertToInstance(sipPy,sipClass_TQString,SIP_NO_CONVERTORS));
*sipCppPtr = PyUnicodeStringToTQString(sipPy); *sipCppPtr = PyTQt_qt_PyObject_AsTQString(sipPy);
if (*sipCppPtr) if (*sipCppPtr)
return sipGetState(sipTransferObj); return sipGetState(sipTransferObj);
@ -942,7 +719,7 @@ static TQString *PyUnicodeStringToTQString(PyObject *py)
enc = codec->fromUnicode(*sipCpp); enc = codec->fromUnicode(*sipCpp);
if ((encobj = PyString_FromString(enc.data())) != NULL) if ((encobj = SIPBytes_FromString(enc.data())) != NULL)
{ {
*sipPtrPtr = (void *)PyString_AS_STRING(encobj); *sipPtrPtr = (void *)PyString_AS_STRING(encobj);
sipRes = PyString_GET_SIZE(encobj); sipRes = PyString_GET_SIZE(encobj);
@ -973,107 +750,227 @@ bool operator>=(const TQString &,const TQString &);
%End %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 PyObject *obj;
#include <tqstring.h>
#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 %End
public:
TQString();
TQString(int);
TQString(const TQString &);
TQString(const char *);
TQString(const char *,uint);
bool isNull() const; %ModuleHeaderCode
bool isEmpty() const; extern TQString *PyTQt_qt_PyObject_AsTQString(PyObject *obj);
uint length() const; %End
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;
TQString &setStr(const char *); %ModuleCode
// TQString &setNum(short); // Convert a Python Unicode object to a QString.
// TQString &setNum(ushort); TQString *PyTQt_qt_PyObject_AsTQString(PyObject *obj)
TQString &setNum(int /Constrained/); {
// TQString &setNum(uint); if (PyUnicode_Check(obj))
// TQString &setNum(long); {
// TQString &setNum(ulong); #if PY_VERSION_HEX >= 0x03030000
// TQString &setNum(float,char = 'g',int = 6); SIP_SSIZE_T len = PyUnicode_GET_LENGTH(obj);
TQString &setNum(double,char = 'g',int = 6);
bool setExpand(uint,char);
SIP_PYOBJECT __str__(); switch (PyUnicode_KIND(obj))
%MethodCode {
const char *s; case PyUnicode_1BYTE_KIND:
return new TQString(TQString::fromLatin1((char *)PyUnicode_1BYTE_DATA(obj), len));
Py_BEGIN_ALLOW_THREADS case PyUnicode_2BYTE_KIND:
s = *sipCpp; // The (TQChar *) cast should be safe.
Py_END_ALLOW_THREADS return new TQString((TQChar *)PyUnicode_2BYTE_DATA(obj), len);
if (s == NULL) case PyUnicode_4BYTE_KIND:
s = ""; // 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); TQString *qstr = new TQString;
%End
%ConvertToTypeCode Py_UCS4 *ucode = PyUnicode_4BYTE_DATA(obj);
// Allow a Python string whenever a TQString is expected.
if (sipIsErr == NULL) for (SIP_SSIZE_T i = 0; i < len; ++i)
return (PyString_Check(sipPy) || qstr->append(TQChar((uint)ucode[i]));
sipCanConvertToInstance(sipPy,sipClass_TQString,SIP_NO_CONVERTORS));
if (PyString_Check(sipPy)) return qstr;
{ }
*sipCppPtr = new TQString(PyString_AS_STRING(sipPy));
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 %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 %End

@ -188,7 +188,7 @@ public:
sipRes = new TQString((*sipCpp)[a0]); sipRes = new TQString((*sipCpp)[a0]);
%End %End
TQStringList operator[](SIP_PYSLICE); TQStringList operator[](SIP_PYSLICE slice);
%MethodCode %MethodCode
#if PY_VERSION_HEX >= 0x02050000 #if PY_VERSION_HEX >= 0x02050000
Py_ssize_t len, start, stop, step, slicelength, i; Py_ssize_t len, start, stop, step, slicelength, i;

@ -57,7 +57,7 @@ is used instead.
{ {
PyObject *ps; 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_XDECREF(ps);
Py_DECREF(l); Py_DECREF(l);
@ -80,13 +80,17 @@ is used instead.
for (int i = 0; i < PyList_GET_SIZE(sipPy); ++i) for (int i = 0; i < PyList_GET_SIZE(sipPy); ++i)
{ {
PyObject *object = PyList_GET_ITEM(sipPy, i);
char *s; 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; *sipIsErr = 1;
delete qsl; delete qsl;
return 0; return 0;
} }

@ -139,7 +139,7 @@ template<Type>
// Get it. // Get it.
for (uint i = 0; i < sipCpp -> count(); ++i) 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); Py_DECREF(l);
@ -161,7 +161,7 @@ template<Type>
for (int i = 0; i < PyList_GET_SIZE(sipPy); ++i) 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) if (PyErr_Occurred() != NULL)
{ {

@ -130,7 +130,7 @@ public:
Py_INCREF(Py_None); Py_INCREF(Py_None);
sipRes = Py_None; sipRes = Py_None;
} }
else if ((sipRes = PyString_FromStringAndSize(buf,actlen)) == NULL) else if ((sipRes = SIPBytes_FromStringAndSize(buf,actlen)) == NULL)
sipIsErr = 1; sipIsErr = 1;
sipFree((void *)buf); sipFree((void *)buf);

@ -226,7 +226,7 @@ public:
Py_INCREF(Py_None); Py_INCREF(Py_None);
sipRes = Py_None; sipRes = Py_None;
} }
else if ((sipRes = PyString_FromStringAndSize(buf,actlen)) == NULL) else if ((sipRes = SIPBytes_FromStringAndSize(buf,actlen)) == NULL)
sipIsErr = 1; sipIsErr = 1;
sipFree((void *)buf); sipFree((void *)buf);

@ -194,7 +194,7 @@ public:
} }
else else
{ {
sipRes = PyString_FromStringAndSize(buf,actlen); sipRes = SIPBytes_FromStringAndSize(buf,actlen);
sipFree((void *)buf); sipFree((void *)buf);
@ -229,7 +229,7 @@ public:
} }
else else
{ {
sipRes = PyString_FromStringAndSize(buf,actlen); sipRes = SIPBytes_FromStringAndSize(buf,actlen);
sipFree((void *)buf); sipFree((void *)buf);
@ -263,7 +263,7 @@ public:
} }
else else
{ {
sipRes = PyString_FromStringAndSize(buf,actlen); sipRes = SIPBytes_FromStringAndSize(buf,actlen);
sipFree((void *)buf); sipFree((void *)buf);
@ -299,7 +299,7 @@ public:
} }
else else
{ {
sipRes = PyString_FromStringAndSize(buf,actlen); sipRes = SIPBytes_FromStringAndSize(buf,actlen);
sipFree((void *)buf); sipFree((void *)buf);

@ -145,7 +145,7 @@ public:
Py_INCREF(Py_None); Py_INCREF(Py_None);
sipRes = Py_None; sipRes = Py_None;
} }
else if ((sipRes = PyString_FromStringAndSize(buf,actlen)) == NULL) else if ((sipRes = SIPBytes_FromStringAndSize(buf,actlen)) == NULL)
sipIsErr = 1; sipIsErr = 1;
sipFree((void *)buf); sipFree((void *)buf);
@ -176,7 +176,7 @@ public:
Py_INCREF(Py_None); Py_INCREF(Py_None);
sipRes = Py_None; sipRes = Py_None;
} }
else if ((sipRes = PyString_FromStringAndSize(buf,actlen)) == NULL) else if ((sipRes = SIPBytes_FromStringAndSize(buf,actlen)) == NULL)
sipIsErr = 1; sipIsErr = 1;
sipFree((void *)buf); sipFree((void *)buf);

@ -186,7 +186,7 @@ static char **pyArgvToC(PyObject *argvlist,int *argcp)
char *arg; char *arg;
// Get the argument and allocate memory for it. // 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) (argv[a] = (char *)sipMalloc(strlen(arg) + 1)) == NULL)
return NULL; return NULL;

Loading…
Cancel
Save