summaryrefslogtreecommitdiffstats
path: root/lib/kross
diff options
context:
space:
mode:
Diffstat (limited to 'lib/kross')
-rw-r--r--lib/kross/python/scripts/RestrictedPython/Eval.py6
-rw-r--r--lib/kross/python/scripts/RestrictedPython/Guards.py2
-rw-r--r--lib/kross/python/scripts/RestrictedPython/Limits.py12
-rw-r--r--lib/kross/python/scripts/RestrictedPython/MutatingWalker.py2
-rw-r--r--lib/kross/python/scripts/RestrictedPython/RCompile.py4
-rw-r--r--lib/kross/python/scripts/RestrictedPython/RestrictionMutator.py2
-rwxr-xr-xlib/kross/python/scripts/gui.py96
-rw-r--r--lib/kross/test/testcase.py88
-rw-r--r--lib/kross/test/testgui.py42
-rw-r--r--lib/kross/test/testkexidb.py52
-rwxr-xr-xlib/kross/test/testperformance.py4
11 files changed, 155 insertions, 155 deletions
diff --git a/lib/kross/python/scripts/RestrictedPython/Eval.py b/lib/kross/python/scripts/RestrictedPython/Eval.py
index 841067a13..858025221 100644
--- a/lib/kross/python/scripts/RestrictedPython/Eval.py
+++ b/lib/kross/python/scripts/RestrictedPython/Eval.py
@@ -62,10 +62,10 @@ class RestrictionCapableEval:
self.expr, '<string>')
if PROFILE:
end = clock()
- print 'prepRestrictedCode: %d ms for %s' % (
- (end - start) * 1000, `self.expr`)
+ print('prepRestrictedCode: %d ms for %s' % (
+ (end - start) * 1000, repr(self.expr)))
if err:
- raise SyntaxError, err[0]
+ raise SyntaxError(err[0])
self.used = tuple(used.keys())
self.rcode = co
diff --git a/lib/kross/python/scripts/RestrictedPython/Guards.py b/lib/kross/python/scripts/RestrictedPython/Guards.py
index 4fbdcad1c..2338518fd 100644
--- a/lib/kross/python/scripts/RestrictedPython/Guards.py
+++ b/lib/kross/python/scripts/RestrictedPython/Guards.py
@@ -93,7 +93,7 @@ def _write_wrapper():
try:
f = getattr(self.ob, secattr)
except AttributeError:
- raise TypeError, error_msg
+ raise TypeError(error_msg)
f(*args)
return handler
class Wrapper:
diff --git a/lib/kross/python/scripts/RestrictedPython/Limits.py b/lib/kross/python/scripts/RestrictedPython/Limits.py
index 3b782e658..4e4511f1e 100644
--- a/lib/kross/python/scripts/RestrictedPython/Limits.py
+++ b/lib/kross/python/scripts/RestrictedPython/Limits.py
@@ -25,22 +25,22 @@ def limited_range(iFirst, *args):
elif len(args) == 2:
iStart, iEnd, iStep = iFirst, args[0], args[1]
else:
- raise AttributeError, 'range() requires 1-3 int arguments'
- if iStep == 0: raise ValueError, 'zero step for range()'
+ raise AttributeError('range() requires 1-3 int arguments')
+ if iStep == 0: raise ValueError('zero step for range()')
iLen = int((iEnd - iStart) / iStep)
if iLen < 0: iLen = 0
- if iLen >= RANGELIMIT: raise ValueError, 'range() too large'
- return range(iStart, iEnd, iStep)
+ if iLen >= RANGELIMIT: raise ValueError('range() too large')
+ return list(range(iStart, iEnd, iStep))
limited_builtins['range'] = limited_range
def limited_list(seq):
if isinstance(seq, str):
- raise TypeError, 'cannot convert string to list'
+ raise TypeError('cannot convert string to list')
return list(seq)
limited_builtins['list'] = limited_list
def limited_tuple(seq):
if isinstance(seq, str):
- raise TypeError, 'cannot convert string to tuple'
+ raise TypeError('cannot convert string to tuple')
return tuple(seq)
limited_builtins['tuple'] = limited_tuple
diff --git a/lib/kross/python/scripts/RestrictedPython/MutatingWalker.py b/lib/kross/python/scripts/RestrictedPython/MutatingWalker.py
index b0b8c9cea..7cde295dd 100644
--- a/lib/kross/python/scripts/RestrictedPython/MutatingWalker.py
+++ b/lib/kross/python/scripts/RestrictedPython/MutatingWalker.py
@@ -26,7 +26,7 @@ class MutatingWalker:
self._cache = {}
def defaultVisitNode(self, node, walker=None, exclude=None):
- for name, child in node.__dict__.items():
+ for name, child in list(node.__dict__.items()):
if exclude is not None and name in exclude:
continue
v = self.dispatchObject(child)
diff --git a/lib/kross/python/scripts/RestrictedPython/RCompile.py b/lib/kross/python/scripts/RestrictedPython/RCompile.py
index 0a538657f..dc5f8d4e4 100644
--- a/lib/kross/python/scripts/RestrictedPython/RCompile.py
+++ b/lib/kross/python/scripts/RestrictedPython/RCompile.py
@@ -52,7 +52,7 @@ class RestrictedCompileMode(AbstractCompileMode):
tree = self.parse()
MutatingWalker.walk(tree, self.rm)
if self.rm.errors:
- raise SyntaxError, self.rm.errors[0]
+ raise SyntaxError(self.rm.errors[0])
misc.set_filename(self.filename, tree)
syntax.check(tree)
return tree
@@ -66,7 +66,7 @@ class RestrictedCompileMode(AbstractCompileMode):
def compileAndTuplize(gen):
try:
gen.compile()
- except SyntaxError, v:
+ except SyntaxError as v:
return None, (str(v),), gen.rm.warnings, gen.rm.used_names
return gen.getCode(), (), gen.rm.warnings, gen.rm.used_names
diff --git a/lib/kross/python/scripts/RestrictedPython/RestrictionMutator.py b/lib/kross/python/scripts/RestrictedPython/RestrictionMutator.py
index a8b3850e0..d5f4bac02 100644
--- a/lib/kross/python/scripts/RestrictedPython/RestrictionMutator.py
+++ b/lib/kross/python/scripts/RestrictedPython/RestrictionMutator.py
@@ -26,7 +26,7 @@ from SelectCompiler import ast, parse, OP_ASSIGN, OP_DELETE, OP_APPLY
# trees without affecting line numbers shown in tracebacks, etc.
def rmLineno(node):
"""Strip lineno attributes from a code tree."""
- if node.__dict__.has_key('lineno'):
+ if 'lineno' in node.__dict__:
del node.lineno
for child in node.getChildren():
if isinstance(child, ast.Node):
diff --git a/lib/kross/python/scripts/gui.py b/lib/kross/python/scripts/gui.py
index 487a58627..693261dd5 100755
--- a/lib/kross/python/scripts/gui.py
+++ b/lib/kross/python/scripts/gui.py
@@ -34,8 +34,8 @@ class TkDialog:
""" This class is used to wrap Tkinter into a more abstract interface."""
def __init__(self, title):
- import Tkinter
- self.root = Tkinter.Tk()
+ import tkinter
+ self.root = tkinter.Tk()
self.root.title(title)
self.root.deiconify()
@@ -52,42 +52,42 @@ class TkDialog:
class Frame(Widget):
def __init__(self, dialog, parent):
#TkDialog.Widget.__init__(self, dialog, parent)
- import Tkinter
- self.widget = Tkinter.Frame(parent)
+ import tkinter
+ self.widget = tkinter.Frame(parent)
self.widget.pack()
class Label(Widget):
def __init__(self, dialog, parent, caption):
#TkDialog.Widget.__init__(self, dialog, parent)
- import Tkinter
- self.widget = Tkinter.Label(parent, text=caption)
- self.widget.pack(side=Tkinter.TOP)
+ import tkinter
+ self.widget = tkinter.Label(parent, text=caption)
+ self.widget.pack(side=tkinter.TOP)
class CheckBox(Widget):
def __init__(self, dialog, parent, caption, checked = True):
#TkDialog.Widget.__init__(self, dialog, parent)
- import Tkinter
- self.checkstate = Tkinter.IntVar()
+ import tkinter
+ self.checkstate = tkinter.IntVar()
self.checkstate.set(checked)
- self.widget = Tkinter.Checkbutton(parent, text=caption, variable=self.checkstate)
- self.widget.pack(side=Tkinter.TOP)
+ self.widget = tkinter.Checkbutton(parent, text=caption, variable=self.checkstate)
+ self.widget.pack(side=tkinter.TOP)
def isChecked(self):
return self.checkstate.get()
class List(Widget):
def __init__(self, dialog, parent, caption, items):
#TkDialog.Widget.__init__(self, dialog, parent)
- import Tkinter
+ import tkinter
- listframe = Tkinter.Frame(parent)
+ listframe = tkinter.Frame(parent)
listframe.pack()
- Tkinter.Label(listframe, text=caption).pack(side=Tkinter.LEFT)
+ tkinter.Label(listframe, text=caption).pack(side=tkinter.LEFT)
self.items = items
- self.variable = Tkinter.StringVar()
- itemlist = apply(Tkinter.OptionMenu, (listframe, self.variable) + tuple( items ))
- itemlist.pack(side=Tkinter.LEFT)
+ self.variable = tkinter.StringVar()
+ itemlist = tkinter.OptionMenu(*(listframe, self.variable) + tuple( items ))
+ itemlist.pack(side=tkinter.LEFT)
def get(self):
return self.variable.get()
def set(self, index):
@@ -96,48 +96,48 @@ class TkDialog:
class Button(Widget):
def __init__(self, dialog, parent, caption, commandmethod):
#TkDialog.Widget.__init__(self, dialog, parent)
- import Tkinter
- self.widget = Tkinter.Button(parent, text=caption, command=self.doCommand)
+ import tkinter
+ self.widget = tkinter.Button(parent, text=caption, command=self.doCommand)
self.commandmethod = commandmethod
- self.widget.pack(side=Tkinter.LEFT)
+ self.widget.pack(side=tkinter.LEFT)
def doCommand(self):
try:
self.commandmethod()
except:
#TODO why the heck we arn't able to redirect exceptions?
import traceback
- import StringIO
- fp = StringIO.StringIO()
+ import io
+ fp = io.StringIO()
traceback.print_exc(file=fp)
- import tkMessageBox
- tkMessageBox.showerror("Exception", fp.getvalue())
+ import tkinter.messagebox
+ tkinter.messagebox.showerror("Exception", fp.getvalue())
#self.dialog.root.destroy()
class Edit(Widget):
def __init__(self, dialog, parent, caption, text):
#TkDialog.Widget.__init__(self, dialog, parent)
- import Tkinter
- self.widget = Tkinter.Frame(parent)
+ import tkinter
+ self.widget = tkinter.Frame(parent)
self.widget.pack()
- label = Tkinter.Label(self.widget, text=caption)
- label.pack(side=Tkinter.LEFT)
- self.entrytext = Tkinter.StringVar()
+ label = tkinter.Label(self.widget, text=caption)
+ label.pack(side=tkinter.LEFT)
+ self.entrytext = tkinter.StringVar()
self.entrytext.set(text)
- self.entry = Tkinter.Entry(self.widget, width=36, textvariable=self.entrytext)
- self.entry.pack(side=Tkinter.LEFT)
+ self.entry = tkinter.Entry(self.widget, width=36, textvariable=self.entrytext)
+ self.entry.pack(side=tkinter.LEFT)
def get(self):
return self.entrytext.get()
class FileChooser(Edit):
def __init__(self, dialog, parent, caption, initialfile = None, filetypes = None):
TkDialog.Edit.__init__(self, dialog, parent, caption, initialfile)
- import Tkinter
+ import tkinter
self.initialfile = initialfile
self.entrytext.set(initialfile)
- btn = Tkinter.Button(self.widget, text="...", command=self.browse)
- btn.pack(side=Tkinter.LEFT)
+ btn = tkinter.Button(self.widget, text="...", command=self.browse)
+ btn.pack(side=tkinter.LEFT)
if filetypes:
self.filetypes = filetypes
@@ -150,8 +150,8 @@ class TkDialog:
d = os.path.dirname(text) or os.path.dirname(self.initialfile)
f = os.path.basename(text) or os.path.basename(self.initialfile)
- import tkFileDialog
- file = tkFileDialog.asksaveasfilename(
+ import tkinter.filedialog
+ file = tkinter.filedialog.asksaveasfilename(
initialdir=d,
initialfile=f,
#defaultextension='.html',
@@ -167,11 +167,11 @@ class TkDialog:
self.caption = str(caption)
self.message = str(message)
def show(self):
- import tkMessageBox
+ import tkinter.messagebox
if self.typename == "okcancel":
- return tkMessageBox.askokcancel(self.caption, self.message,icon=tkmessageBox.QESTION)
+ return tkinter.messagebox.askokcancel(self.caption, self.message,icon=tkmessageBox.QESTION)
else:
- tkMessageBox.showinfo(self.caption, self.message)
+ tkinter.messagebox.showinfo(self.caption, self.message)
return True
def show(self):
@@ -276,7 +276,7 @@ class TQtDialog:
def browseButtonClicked(self):
filtermask = ""
import types
- if isinstance(self.filetypes, types.TupleType):
+ if isinstance(self.filetypes, tuple):
for ft in self.filetypes:
if len(ft) == 1:
filtermask += "%s\n" % (ft[0])
@@ -289,12 +289,12 @@ class TQtDialog:
filename = None
try:
- print "TQtDialog.FileChooser.browseButtonClicked() tdefile.KFileDialog"
+ print("TQtDialog.FileChooser.browseButtonClicked() tdefile.KFileDialog")
# try to use the tdefile module included in pytde
import tdefile
filename = tdefile.KFileDialog.getOpenFileName(self.initialfile, filtermask, self, "Save to file")
except:
- print "TQtDialog.FileChooser.browseButtonClicked() qt.TQFileDialog"
+ print("TQtDialog.FileChooser.browseButtonClicked() qt.TQFileDialog")
# fallback to TQt filedialog
filename = qt.TQFileDialog.getOpenFileName(self.initialfile, filtermask, self, "Save to file")
if filename != None and filename != "":
@@ -341,7 +341,7 @@ class TQtDialog:
qt.TQApplication.restoreOverrideCursor()
def close(self):
- print "TQtDialog.close()"
+ print("TQtDialog.close()")
self.dialog.close()
#self.dialog.deleteLater()
@@ -352,16 +352,16 @@ class Dialog:
self.dialog = None
try:
- print "Trying to import PyTQt..."
+ print("Trying to import PyTQt...")
self.dialog = TQtDialog(title)
- print "PyTQt is our toolkit!"
+ print("PyTQt is our toolkit!")
except:
try:
- print "Failed to import PyTQt. Trying to import TkInter..."
+ print("Failed to import PyTQt. Trying to import TkInter...")
self.dialog = TkDialog(title)
- print "Falling back to TkInter as our toolkit!"
+ print("Falling back to TkInter as our toolkit!")
except:
- raise "Failed to import GUI-toolkit. Please install the PyTQt or the Tkinter python module."
+ raise Exception("Failed to import GUI-toolkit. Please install the PyTQt or the Tkinter python module.")
self.widget = self.dialog.widget
def show(self):
diff --git a/lib/kross/test/testcase.py b/lib/kross/test/testcase.py
index 28917f874..6db6d980a 100644
--- a/lib/kross/test/testcase.py
+++ b/lib/kross/test/testcase.py
@@ -59,84 +59,84 @@ class TestPlugin(unittest.TestCase):
def setUp(self):
import krosstestpluginmodule
self.pluginobject1 = krosstestpluginmodule.testpluginobject1()
- self.assert_( self.pluginobject1 )
+ self.assertTrue( self.pluginobject1 )
self.pluginobject2 = krosstestpluginmodule.testpluginobject2()
- self.assert_( self.pluginobject2 )
+ self.assertTrue( self.pluginobject2 )
self.testqobject1 = krosstestpluginmodule.testqobject1()
- self.assert_( self.testqobject1 )
+ self.assertTrue( self.testqobject1 )
def testBasicDataTypes(self):
- self.assert_( self.pluginobject1.uintfunc(177321) == 177321 )
- self.assert_( self.pluginobject1.intfunc(93675) == 93675 )
- self.assert_( self.pluginobject1.intfunc(-73673) == -73673 )
- self.assert_( self.pluginobject1.boolfunc(True) == True )
- self.assert_( self.pluginobject1.boolfunc(False) == False )
- self.assert_( self.pluginobject1.doublefunc(4265.3723) == 4265.3723 )
- self.assert_( self.pluginobject1.doublefunc(-4265.68) == -4265.68 )
- self.assert_( self.pluginobject1.cstringfunc(" This is a Test! ") == " This is a Test! " )
- self.assert_( self.pluginobject1.stringfunc(" Another \n\r Test! $%&\"") == " Another \n\r Test! $%&\"" )
+ self.assertTrue( self.pluginobject1.uintfunc(177321) == 177321 )
+ self.assertTrue( self.pluginobject1.intfunc(93675) == 93675 )
+ self.assertTrue( self.pluginobject1.intfunc(-73673) == -73673 )
+ self.assertTrue( self.pluginobject1.boolfunc(True) == True )
+ self.assertTrue( self.pluginobject1.boolfunc(False) == False )
+ self.assertTrue( self.pluginobject1.doublefunc(4265.3723) == 4265.3723 )
+ self.assertTrue( self.pluginobject1.doublefunc(-4265.68) == -4265.68 )
+ self.assertTrue( self.pluginobject1.cstringfunc(" This is a Test! ") == " This is a Test! " )
+ self.assertTrue( self.pluginobject1.stringfunc(" Another \n\r Test! $%&\"") == " Another \n\r Test! $%&\"" )
#TODO
#self.assert_( self.pluginobject1.stringfunc( unicode(" Unicode test ") ) == " Unicode test " )
#self.assert_( self.pluginobject1.stringfunc(unicode(" Another Test! ")) == unicode(" Another Test! ") )
- self.assert_( self.pluginobject1.stringstringfunc("MyString1", "MyString2") == "MyString1" )
- self.assert_( self.pluginobject1.uintdoublestringfunc(8529,285.246,"String") == 8529 )
- self.assert_( self.pluginobject1.stringlistbooluintdouble(["s1","s2"],True,6,7.0,"String") == ["s1","s2"] )
+ self.assertTrue( self.pluginobject1.stringstringfunc("MyString1", "MyString2") == "MyString1" )
+ self.assertTrue( self.pluginobject1.uintdoublestringfunc(8529,285.246,"String") == 8529 )
+ self.assertTrue( self.pluginobject1.stringlistbooluintdouble(["s1","s2"],True,6,7.0,"String") == ["s1","s2"] )
def testStringList(self):
- self.assert_( self.pluginobject1.stringlistfunc( [] ) == [] )
- self.assert_( self.pluginobject1.stringlistfunc( ["First Item"," Second Item "] ) == ["First Item"," Second Item "] )
- self.assert_( self.pluginobject1.stringlistfunc( ("Theird Item"," Forth Item ","Fifth Item") ) == ["Theird Item"," Forth Item ","Fifth Item"] )
+ self.assertTrue( self.pluginobject1.stringlistfunc( [] ) == [] )
+ self.assertTrue( self.pluginobject1.stringlistfunc( ["First Item"," Second Item "] ) == ["First Item"," Second Item "] )
+ self.assertTrue( self.pluginobject1.stringlistfunc( ("Theird Item"," Forth Item ","Fifth Item") ) == ["Theird Item"," Forth Item ","Fifth Item"] )
def testVariant(self):
- self.assert_( self.pluginobject1.variantfunc(True) == True )
- self.assert_( self.pluginobject1.variantfunc(False) == False )
- self.assert_( self.pluginobject1.variantfunc(187937) == 187937 )
- self.assert_( self.pluginobject1.variantfunc(-69825) == -69825 )
- self.assert_( self.pluginobject1.variantfunc(8632.274) == 8632.274 )
- self.assert_( self.pluginobject1.variantfunc(-8632.351) == -8632.351 )
- self.assert_( self.pluginobject1.variantfunc(" Test \n\r This String $%&\"") == " Test \n\r This String $%&\"")
+ self.assertTrue( self.pluginobject1.variantfunc(True) == True )
+ self.assertTrue( self.pluginobject1.variantfunc(False) == False )
+ self.assertTrue( self.pluginobject1.variantfunc(187937) == 187937 )
+ self.assertTrue( self.pluginobject1.variantfunc(-69825) == -69825 )
+ self.assertTrue( self.pluginobject1.variantfunc(8632.274) == 8632.274 )
+ self.assertTrue( self.pluginobject1.variantfunc(-8632.351) == -8632.351 )
+ self.assertTrue( self.pluginobject1.variantfunc(" Test \n\r This String $%&\"") == " Test \n\r This String $%&\"")
def testObjects(self):
- print "-----------------1"
+ print("-----------------1")
newobjref = self.pluginobject1.objectfunc(self.pluginobject2)
- print "-----------------2"
- print str(newobjref)
+ print("-----------------2")
+ print(str(newobjref))
#self.assert_( newobjref.myuniqueid == self.pluginobject2.myuniqueid )
#print "===========> %s" % self.pluginobject2.myName()
- print "testqobject1 properties=%s" % self.testqobject1.propertyNames()
- print "testqobject1 Q_SLOTS=%s" % self.testqobject1.slotNames()
- print "testqobject1 Q_SIGNALS=%s" % self.testqobject1.signalNames()
- print "-----------------3"
- print "DIR=>%s" % dir(self.testqobject1)
+ print("testqobject1 properties=%s" % self.testqobject1.propertyNames())
+ print("testqobject1 Q_SLOTS=%s" % self.testqobject1.slotNames())
+ print("testqobject1 Q_SIGNALS=%s" % self.testqobject1.signalNames())
+ print("-----------------3")
+ print("DIR=>%s" % dir(self.testqobject1))
- print "===================> slotcall-result: %s" % self.testqobject1.slot("self()")
+ print("===================> slotcall-result: %s" % self.testqobject1.slot("self()"))
#testobject = newobjref.get("TestObject")
#print testobject
- print "-----------------9"
+ print("-----------------9")
def testDefaultArguments(self):
- self.assert_( self.pluginobject1.uintfunc_defarg(98765) == 98765 )
- self.assert_( self.pluginobject1.uintfunc_defarg() == 12345 )
- self.assert_( self.pluginobject1.stringfunc_defarg("MyString") == "MyString" )
- self.assert_( self.pluginobject1.stringfunc_defarg() == "MyDefaultString" )
- self.assert_( self.pluginobject1.stringlistfunc_defarg(["s1","s2","s3"]) == ["s1","s2","s3"] )
- self.assert_( self.pluginobject1.stringlistfunc_defarg() == ["Default1","Default2"] )
- self.assert_( self.pluginobject1.variantfunc_defarg(822.75173) == 822.75173 )
- self.assert_( self.pluginobject1.variantfunc_defarg() == "MyDefaultVariantString" )
+ self.assertTrue( self.pluginobject1.uintfunc_defarg(98765) == 98765 )
+ self.assertTrue( self.pluginobject1.uintfunc_defarg() == 12345 )
+ self.assertTrue( self.pluginobject1.stringfunc_defarg("MyString") == "MyString" )
+ self.assertTrue( self.pluginobject1.stringfunc_defarg() == "MyDefaultString" )
+ self.assertTrue( self.pluginobject1.stringlistfunc_defarg(["s1","s2","s3"]) == ["s1","s2","s3"] )
+ self.assertTrue( self.pluginobject1.stringlistfunc_defarg() == ["Default1","Default2"] )
+ self.assertTrue( self.pluginobject1.variantfunc_defarg(822.75173) == 822.75173 )
+ self.assertTrue( self.pluginobject1.variantfunc_defarg() == "MyDefaultVariantString" )
#def testExpectedFailures(self):
# to less arguments
#self.assertRaises(ValueError, self.pluginobject1.uintfunc)
#self.assert_( self.pluginobject1.uintfunc() != 8465 )
-print "__name__ = %s" % __name__
+print("__name__ = %s" % __name__)
#print "self = %s" % self
#print self.get("TestObject")
diff --git a/lib/kross/test/testgui.py b/lib/kross/test/testgui.py
index b5efb8dc4..0a3cf822d 100644
--- a/lib/kross/test/testgui.py
+++ b/lib/kross/test/testgui.py
@@ -8,32 +8,32 @@
class TkTest:
def __init__(self):
- import Tkinter
- self.root = Tkinter.Tk()
+ import tkinter
+ self.root = tkinter.Tk()
self.root.title("TkTest")
self.root.deiconify()
- self.mainframe = Tkinter.Frame(self.root)
+ self.mainframe = tkinter.Frame(self.root)
self.mainframe.pack()
- self.button1 = Tkinter.Button(self.mainframe, text="Button1", command=self.callback1)
- self.button1.pack(side=Tkinter.LEFT)
+ self.button1 = tkinter.Button(self.mainframe, text="Button1", command=self.callback1)
+ self.button1.pack(side=tkinter.LEFT)
- self.button2 = Tkinter.Button(self.mainframe, text="Button2", command=self.callback2)
- self.button2.pack(side=Tkinter.LEFT)
+ self.button2 = tkinter.Button(self.mainframe, text="Button2", command=self.callback2)
+ self.button2.pack(side=tkinter.LEFT)
- self.exitbutton = Tkinter.Button(self.mainframe, text="Exit", command=self.root.destroy)
- self.exitbutton.pack(side=Tkinter.LEFT)
+ self.exitbutton = tkinter.Button(self.mainframe, text="Exit", command=self.root.destroy)
+ self.exitbutton.pack(side=tkinter.LEFT)
self.root.mainloop()
def callback1(self):
- import tkMessageBox
- tkMessageBox.showinfo("Callback1", "Callback1 called.")
+ import tkinter.messagebox
+ tkinter.messagebox.showinfo("Callback1", "Callback1 called.")
def callback2(self):
- import tkMessageBox
- tkMessageBox.showinfo("Callback2", "Callback2 called.")
+ import tkinter.messagebox
+ tkinter.messagebox.showinfo("Callback2", "Callback2 called.")
class TQtTest:
def __init__(self):
@@ -41,7 +41,7 @@ class TQtTest:
class Button(qt.TQPushButton):
def __init__(self, *args):
- apply(qt.TQPushButton.__init__, (self,) + args)
+ qt.TQPushButton.__init__(*(self,) + args)
class ComboBox(qt.TQHBox):
def __init__(self, parent, caption, items = []):
@@ -56,7 +56,7 @@ class TQtTest:
class FileChooser(qt.TQHBox):
def __init__(self, *args):
- apply(qt.TQHBox.__init__, (self,) + args)
+ qt.TQHBox.__init__(*(self,) + args)
self.defaultfilename = "~/output.html"
self.setSpacing(6)
@@ -119,7 +119,7 @@ class TQtTest:
qt.TQObject.connect(cancelbutton, qt.SIGNAL("clicked()"), self, qt.SLOT("close()"))
def accept(self):
- print "ACCEPTTTTTTTT !!!!!!!!!!!!!!!!!!!!!!!!!!!!"
+ print("ACCEPTTTTTTTT !!!!!!!!!!!!!!!!!!!!!!!!!!!!")
file = qt.TQFile( self.filechooser.file() )
#if not file.exists():
@@ -128,13 +128,13 @@ class TQtTest:
# print "File '%s' does exist." % self.filechooser.file()
def exportButtonClicked(self):
- print "Export to HTML !!!!!!!!!!!!!!!!!!!!!!!!!!!!"
+ print("Export to HTML !!!!!!!!!!!!!!!!!!!!!!!!!!!!")
def __getattr__(self, attr):
- print "=> Dialog.__getattr__(self,attr)"
+ print("=> Dialog.__getattr__(self,attr)")
#def closeEvent(self, ev): pass
def event(self, e):
- print "=> Dialog.event %s" % e
+ print("=> Dialog.event %s" % e)
#self.deleteLater()
#support.swapThreadState() # calls appropriate c-function
return qt.TQDialog.event(self, e)
@@ -143,7 +143,7 @@ class TQtTest:
dialog = Dialog(app.mainWidget(), "Dialog", 1)
dialog.show()
-print "################## BEGIN"
+print("################## BEGIN")
#TkTest()
TQtTest()
-print "################## END"
+print("################## END")
diff --git a/lib/kross/test/testkexidb.py b/lib/kross/test/testkexidb.py
index 803d65486..c85f98067 100644
--- a/lib/kross/test/testkexidb.py
+++ b/lib/kross/test/testkexidb.py
@@ -15,36 +15,36 @@ class KexiDBClass:
#import KexiDB
import krosskexidb
self.kexidbmodule = krosskexidb
- print "KrossKexiDB version=%s" % self.kexidbmodule.version()
+ print("KrossKexiDB version=%s" % self.kexidbmodule.version())
# Create and remember the drivermanager.
self.drivermanager = self.kexidbmodule.DriverManager()
# Print informations about the KexiDB module.
def printKexiDB(self):
- print "KexiDB = %s %s" % (str(self.kexidbmodule),dir(self.kexidbmodule))
+ print("KexiDB = %s %s" % (str(self.kexidbmodule),dir(self.kexidbmodule)))
# Each object has __name__ and __doc__
#print "KexiDB.__name__ = %s" % self.kexidbmodule.__name__
#print "KexiDB.__doc__ = %s" % self.kexidbmodule.__doc__
# Print some infos about the drivermanager.
- print "drivermanager = %s %s" % (self.drivermanager,dir(self.drivermanager))
+ print("drivermanager = %s %s" % (self.drivermanager,dir(self.drivermanager)))
# The drivermanager holds a list of drivers he supports.
- print "drivermanager.driverNames() = %s" % self.driverNames()
+ print("drivermanager.driverNames() = %s" % self.driverNames())
# Print informations about a driver.
def printDriverManger(self, driver):
- print "driver = %s %s" % (driver,dir(driver))
+ print("driver = %s %s" % (driver,dir(driver)))
# Each driver has a version to be able to determinate with what release we are working.
- print "driver.versionMajor() = %s" % driver.versionMajor()
- print "driver.versionMinor() = %s" % driver.versionMinor()
+ print("driver.versionMajor() = %s" % driver.versionMajor())
+ print("driver.versionMinor() = %s" % driver.versionMinor())
# Show us what connections are opened right now.
- print "driver.connectionsList() = %s" % str(driver.connectionsList())
+ print("driver.connectionsList() = %s" % str(driver.connectionsList()))
# Print informations about a connection.
def printConnection(self, connection):
- print "connection = %s %s" % (str(connection),dir(connection))
+ print("connection = %s %s" % (str(connection),dir(connection)))
# Print a list of all avaible databasenames this connection has.
- print "connection.databaseNames() = %s" % connection.databaseNames()
+ print("connection.databaseNames() = %s" % connection.databaseNames())
# Return a list of drivernames.
def driverNames(self):
@@ -65,7 +65,7 @@ class KexiDBClass:
# Fill the new connectiondata object with what we need to connect.
connectiondata.setCaption("myFileConnection")
connectiondata.setFileName(filename)
- print "connectiondata.serverInfoString = %s" % connectiondata.serverInfoString()
+ print("connectiondata.serverInfoString = %s" % connectiondata.serverInfoString())
# Create the connection now.
connection = driver.createConnection(connectiondata)
# Establish the connection.
@@ -98,23 +98,23 @@ class KexiDBClass:
def testParser(self, connection, sqlstatement):
parser = connection.parser()
if not parser:
- raise "ERROR in testParser(): Failed to create parser!"
- print "parser.parse = %s" % parser.parse(sqlstatement)
- print "parser.statement = %s" % parser.statement()
- print "parser.operation = %s" % parser.operation()
- print "parser.table = %s" % parser.table()
- print "parser.query = %s" % parser.query()
- print "parser.connection = %s" % parser.connection()
+ raise("ERROR in testParser(): Failed to create parser!")
+ print("parser.parse = %s" % parser.parse(sqlstatement))
+ print("parser.statement = %s" % parser.statement())
+ print("parser.operation = %s" % parser.operation())
+ print("parser.table = %s" % parser.table())
+ print("parser.query = %s" % parser.query())
+ print("parser.connection = %s" % parser.connection())
# Execute the sql query statement and print the single string result.
def printQuerySingleString(self, connection, sqlstatement):
query = myfileconnection.querySingleString("SELECT * FROM table1", 0)
- print "querySingleString = %s" % query
+ print("querySingleString = %s" % query)
# Execute the sql query statement and print the single stringlist result.
def printQueryStringList(self, connection, sqlstatement):
query = myfileconnection.queryStringList("SELECT * FROM table1", 0)
- print "queryStringList = %s" % query
+ print("queryStringList = %s" % query)
# Walk through the KexiDBCursor and print all item values.
def printQueryCursor(self, cursor):
@@ -130,7 +130,7 @@ class KexiDBClass:
while(not cursor.eof()):
# Print for each item some infos about the fields and there content.
for i in range( cursor.fieldCount() ):
- print "Item='%s' Field='%s' Value='%s'" % (cursor.at(), i, cursor.value(i))
+ print("Item='%s' Field='%s' Value='%s'" % (cursor.at(), i, cursor.value(i)))
# Move to the next item
cursor.moveNext()
@@ -148,7 +148,7 @@ class KexiDBClass:
field.setType("Text")
field.setName(name)
tableschema.fieldlist().addField(field)
- print "tableschema.fieldlist().fieldCount() = %s" % tableschema.fieldlist().fieldCount()
+ print("tableschema.fieldlist().fieldCount() = %s" % tableschema.fieldlist().fieldCount())
return field
# Create a table.
@@ -156,7 +156,7 @@ class KexiDBClass:
# First we need a new tableschema.
tableschema = self.drivermanager.tableSchema(tablename)
self.addField(tableschema, "myfield")
- print "connection.createTable = %s" % connection.createTable(tableschema, True)
+ print("connection.createTable = %s" % connection.createTable(tableschema, True))
return tableschema
# Drop a table.
@@ -166,7 +166,7 @@ class KexiDBClass:
# Alter the name of a table.
def alterTableName(self, connection, tablename, newtablename):
tableschema = connection.tableSchema(tablename)
- print "alterTableName from=%s to=%s tableschema=%s" % (tablename, newtablename, tableschema)
+ print("alterTableName from=%s to=%s tableschema=%s" % (tablename, newtablename, tableschema))
connection.alterTableName(tableschema, newtablename)
def testKexiDB():
@@ -209,6 +209,6 @@ def testKexiDB():
#del(mydriver)
#del(mykexidbclass)
-print "########## BEGIN TEST: KexiDB ##########"
+print("########## BEGIN TEST: KexiDB ##########")
testKexiDB()
-print "########## END TEST: KexiDB ##########"
+print("########## END TEST: KexiDB ##########")
diff --git a/lib/kross/test/testperformance.py b/lib/kross/test/testperformance.py
index a76453ed8..bd9c6d2c8 100755
--- a/lib/kross/test/testperformance.py
+++ b/lib/kross/test/testperformance.py
@@ -10,7 +10,7 @@ def runner():
testobject1 = krosstestpluginmodule.testpluginobject1()
def testKexiDB(kexidbfile,drivername,sqlstring):
- print "test kexidb"
+ print("test kexidb")
import krosskexidb
drivermanager = krosskexidb.DriverManager()
connectiondata = drivermanager.createConnectionData()
@@ -29,7 +29,7 @@ def runner():
cursor.moveNext()
def test1():
- print "test1"
+ print("test1")
for i in range(100000):
testobject1.func1()
testobject1.func1()