summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/kformula/prototype/engine.py263
-rwxr-xr-xlib/kformula/prototype/main.py4
-rwxr-xr-xlib/kformula/prototype/unicode.py84
-rwxr-xr-xlib/kformula/scripts/bycodes.py14
-rwxr-xr-xlib/kross/python/scripts/gui.py125
-rw-r--r--lib/kross/test/testcase.py4
-rw-r--r--lib/kross/test/testgui.py72
7 files changed, 282 insertions, 284 deletions
diff --git a/lib/kformula/prototype/engine.py b/lib/kformula/prototype/engine.py
index f1391069..4ad207f9 100644
--- a/lib/kformula/prototype/engine.py
+++ b/lib/kformula/prototype/engine.py
@@ -1,33 +1,33 @@
"""This file is part of the KDE project
Copyright (C) 2001 Andrea Rizzi <[email protected]>
- Ulrich Kuettler <[email protected]>
+ Ulrich Kuettler <[email protected]>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
-
+
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
-
+
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
"""
-from qt import *
+from PyTQt.qt import *
class BasicElement:
"""The interface for every element."""
-
+
def __init__(self, parent):
self.parent = parent
- self.size = QSize()
- self.pos = QPoint()
+ self.size = TQSize()
+ self.pos = TQPoint()
def x(self): return self.pos.x()
@@ -48,7 +48,7 @@ class BasicElement:
x += element.x()
y += element.y()
element = element.parent
- return QPoint(x, y)
+ return TQPoint(x, y)
def elementAt(self, point, startPoint):
"""Returns the element that is at position point.
@@ -58,13 +58,13 @@ class BasicElement:
y = point.y() - startPoint.y()
if y >= 0 and y < self.height():
return self
-
+
def moveLeft(self, cursor, fromElement):
"""Enters this element while moving to the left from
the element `fromElement'. Searched for cursor position inside
this element of left of it."""
pass
-
+
def moveRight(self, cursor, fromElement):
"""Enters this element while moving to the right from
the element `fromElement'. Searched for cursor position inside
@@ -76,7 +76,7 @@ class BasicElement:
def moveDown(self, cursor, fromElement):
pass
-
+
def formula(self):
"""Returns the FormulaElement we are a child of."""
return self.parent.formula()
@@ -118,7 +118,7 @@ class BasicElement:
class SequenceElement (BasicElement):
"""The element that contains a number of children.
The children are aligned in one line."""
-
+
def __init__(self, parent):
BasicElement.__init__(self, parent)
self.children = []
@@ -127,18 +127,18 @@ class SequenceElement (BasicElement):
"""Returns the element before the cursor."""
if cursor.pos() > 0:
return self.children[cursor.pos()-1]
-
+
def elementAt(self, point, startPoint):
r = BasicElement.elementAt(self, point, startPoint)
if r != None:
for child in self.children:
- r = child.elementAt(point, QPoint(startPoint.x()+child.x(),
- startPoint.y()+child.y()))
+ r = child.elementAt(point, TQPoint(startPoint.x()+child.x(),
+ startPoint.y()+child.y()))
if r != None:
return r
return self
-
+
def moveLeft(self, cursor, fromElement):
# Our parent asks us for a cursor position. Found.
@@ -166,7 +166,7 @@ class SequenceElement (BasicElement):
if not cursor.mouseMark():
cursor.setMarkPos(fromPos+1)
-
+
def moveRight(self, cursor, fromElement):
# Our parent asks us for a cursor position. Found.
@@ -193,7 +193,7 @@ class SequenceElement (BasicElement):
if cursor.isSelection():
if not cursor.mouseMark():
cursor.setMarkPos(fromPos)
-
+
def moveUp(self, cursor, fromElement):
if fromElement == self.parent:
@@ -209,7 +209,7 @@ class SequenceElement (BasicElement):
else:
if self.parent != None:
self.parent.moveDown(cursor, self)
-
+
def moveHome(self, cursor):
if cursor.isSelection():
@@ -229,20 +229,20 @@ class SequenceElement (BasicElement):
cursor.setMarkPos(self.children.index(element))
cursor.set(self, len(self.children))
-
+
def draw(self, painter, styleContext, startPoint):
x, y = startPoint.x(), startPoint.y()
if len(self.children) > 0:
for child in self.children:
cX = child.x()
cY = child.y()
- child.draw(painter, styleContext, QPoint(x+cX, y+cY))
+ child.draw(painter, styleContext, TQPoint(x+cX, y+cY))
# Debug
- #painter.setPen(Qt.green)
+ #painter.setPen(TQt.green)
#painter.drawRect(x, y, self.width(), self.height())
else:
- painter.setPen(Qt.blue)
+ painter.setPen(TQt.blue)
painter.drawRect(x, y, self.width(), self.height())
def calcSizes(self, styleContext):
@@ -295,7 +295,7 @@ class SequenceElement (BasicElement):
# it is essential to set up the parent pointer for
# the notification to work.
element.parent = self
-
+
seq = element.makeSequence()
if cursor.isSelection():
f = min(cursor.pos(), cursor.markPos())
@@ -312,7 +312,7 @@ class SequenceElement (BasicElement):
self.replaceChild(cursor, element)
else:
self.insertChild(cursor, element)
-
+
element.setMainChild(seq)
@@ -321,7 +321,7 @@ class SequenceElement (BasicElement):
(The main child is always a SequenceElement.)"""
assert element.parent == self
self.formula().elementRemoved(element)
-
+
seq = element.mainChild()
pos = self.children.index(element)
self.children.remove(element)
@@ -346,7 +346,7 @@ class SequenceElement (BasicElement):
element.parent = self
cursor.set(self, pos+1)
self.formula().changed()
-
+
def replaceChild(self, cursor, element):
"""Replaces the element before the cursor with the new one.
No range checking. Be careful."""
@@ -363,7 +363,7 @@ class SequenceElement (BasicElement):
self.parent.removeChild(cursor, self)
return
self.formula().changed()
-
+
def removeChildAt(self, cursor):
pos = cursor.pos()
if cursor.isSelection():
@@ -382,7 +382,7 @@ class SequenceElement (BasicElement):
if len(self.children) == 0:
if self.parent != None:
self.parent.removeChild(cursor, self)
-
+
def removeChildBefore(self, cursor):
pos = cursor.pos()-1
if cursor.isSelection():
@@ -402,8 +402,8 @@ class SequenceElement (BasicElement):
if len(self.children) == 0:
if self.parent != None:
self.parent.removeChild(cursor, self)
-
-
+
+
def globalCursorPos(self, pos):
"""Returns the position after the child at the position
in global Coords."""
@@ -415,13 +415,13 @@ class SequenceElement (BasicElement):
d = self.width()
else:
d = 2
-
+
point.setX(point.x()+d)
return point
def countChildren(self):
return len(self.children)
-
+
class FormulaElement (SequenceElement):
"""The main element.
@@ -447,18 +447,18 @@ class FormulaElement (SequenceElement):
Caution! The object tree must still contain the element by the time
you call this methode."""
self.document.elementRemoved(element)
-
+
class TextElement (BasicElement):
"""One char."""
-
+
def __init__(self, parent, char):
BasicElement.__init__(self, parent)
self.char = char
def moveLeft(self, cursor, fromElement):
self.parent.moveLeft(cursor, self)
-
+
def moveRight(self, cursor, fromElement):
self.parent.moveRight(cursor, self)
@@ -484,7 +484,7 @@ class IndexElement (BasicElement):
contentElement.parent = self
else:
BasicElement.__init__(self, None)
-
+
self.content = contentElement
self.upperLeft = self.upperRight = None
self.lowerLeft = self.lowerRight = None
@@ -494,39 +494,39 @@ class IndexElement (BasicElement):
r = BasicElement.elementAt(self, point, startPoint)
if r != None:
x, y = startPoint.x(), startPoint.y()
- r = self.content.elementAt(point, QPoint(x+self.content.x(),
- y+self.content.y()))
+ r = self.content.elementAt(point, TQPoint(x+self.content.x(),
+ y+self.content.y()))
if r != None: return r
if self.upperRight != None:
- r = self.upperRight.elementAt(point, QPoint(x+self.upperRight.x(),
- y+self.upperRight.y()))
+ r = self.upperRight.elementAt(point, TQPoint(x+self.upperRight.x(),
+ y+self.upperRight.y()))
if r != None: return r
if self.upperLeft != None:
- r = self.upperLeft.elementAt(point, QPoint(x+self.upperLeft.x(),
- y+self.upperLeft.y()))
+ r = self.upperLeft.elementAt(point, TQPoint(x+self.upperLeft.x(),
+ y+self.upperLeft.y()))
if r != None: return r
if self.lowerRight != None:
- r = self.lowerRight.elementAt(point, QPoint(x+self.lowerRight.x(),
- y+self.lowerRight.y()))
+ r = self.lowerRight.elementAt(point, TQPoint(x+self.lowerRight.x(),
+ y+self.lowerRight.y()))
if r != None: return r
if self.lowerLeft != None:
- r = self.lowerLeft.elementAt(point, QPoint(x+self.lowerLeft.x(),
- y+self.lowerLeft.y()))
+ r = self.lowerLeft.elementAt(point, TQPoint(x+self.lowerLeft.x(),
+ y+self.lowerLeft.y()))
if r != None: return r
return self
-
-
+
+
def moveLeft(self, cursor, fromElement):
assert fromElement != None
if cursor.isSelection():
self.parent.moveLeft(cursor, self)
-
+
elif fromElement == self.parent:
if self.lowerRight != None:
self.lowerRight.moveLeft(cursor, self)
@@ -557,11 +557,11 @@ class IndexElement (BasicElement):
self.upperLeft.moveLeft(cursor, self)
else:
self.parent.moveLeft(cursor, self)
-
+
else:
self.parent.moveLeft(cursor, self)
-
-
+
+
def moveRight(self, cursor, fromElement):
assert fromElement != None
@@ -598,7 +598,7 @@ class IndexElement (BasicElement):
self.lowerRight.moveRight(cursor, self)
else:
self.parent.moveRight(cursor, self)
-
+
else:
self.parent.moveRight(cursor, self)
@@ -629,7 +629,7 @@ class IndexElement (BasicElement):
else: # should never happen.
self.parent.moveUp(cursor, self)
-
+
def moveDown(self, cursor, fromElement):
assert fromElement != None
@@ -654,35 +654,35 @@ class IndexElement (BasicElement):
elif fromElement == self.upperRight:
self.content.moveLeft(cursor, self)
-
+
else: # should never happen.
self.parent.moveDown(cursor, self)
-
+
def draw(self, painter, styleContext, startPoint):
x, y = startPoint.x(), startPoint.y()
self.content.draw(painter, styleContext,
- QPoint(x+self.content.x(),
- y+self.content.y()))
+ TQPoint(x+self.content.x(),
+ y+self.content.y()))
if self.upperLeft != None:
self.upperLeft.draw(painter, styleContext,
- QPoint(x+self.upperLeft.x(),
- y+self.upperLeft.y()))
+ TQPoint(x+self.upperLeft.x(),
+ y+self.upperLeft.y()))
if self.upperRight != None:
self.upperRight.draw(painter, styleContext,
- QPoint(x+self.upperRight.x(),
- y+self.upperRight.y()))
+ TQPoint(x+self.upperRight.x(),
+ y+self.upperRight.y()))
if self.lowerLeft != None:
self.lowerLeft.draw(painter, styleContext,
- QPoint(x+self.lowerLeft.x(),
- y+self.lowerLeft.y()))
+ TQPoint(x+self.lowerLeft.x(),
+ y+self.lowerLeft.y()))
if self.lowerRight != None:
self.lowerRight.draw(painter, styleContext,
- QPoint(x+self.lowerRight.x(),
- y+self.lowerRight.y()))
+ TQPoint(x+self.lowerRight.x(),
+ y+self.lowerRight.y()))
# Debug
- painter.setPen(Qt.red)
+ painter.setPen(TQt.red)
painter.drawRect(x, y, self.width(), self.height())
@@ -748,7 +748,7 @@ class IndexElement (BasicElement):
self.lowerRight.setX(width)
width += max(urWidth, lrWidth)
-
+
# calculate the y offsets
if ulHeight > urHeight:
self.upperLeft.setY(0)
@@ -812,7 +812,7 @@ class IndexElement (BasicElement):
self.parent.replaceElementByMainChild(cursor, self)
else:
self.formula().changed()
-
+
def requireUpperLeft(self):
if self.upperLeft == None:
@@ -837,15 +837,15 @@ class IndexElement (BasicElement):
self.lowerRight = SequenceElement(self)
self.formula().changed()
return self.lowerRight
-
-
+
+
class Cursor:
"""The selection. This might be a one position selection or
an area. Handles user input and object creation.
-
+
Note that it is up to the elements to actually move the cursor.
(The cursor has no chance to know how.)"""
-
+
def __init__(self, formulaElement):
self.sequenceElement = formulaElement
self.currentPos = 0
@@ -868,25 +868,25 @@ class Cursor:
self.selectionFlag = 0
else:
self.currentMarkPos = -1
-
+
self.sequenceElement = sequenceElement
self.currentPos = pos
def markPos(self):
return self.currentMarkPos
-
+
def setMarkPos(self, markPos):
"""Gets called by elements if the cursor moves up to the parent."""
self.selectionFlag = (markPos != -1)
self.currentMarkPos = markPos
-
+
def pos(self):
return self.currentPos
def element(self):
return self.sequenceElement
-
+
def draw(self, painter):
point = self.sequenceElement.globalCursorPos(self.pos())
height = self.sequenceElement.height()
@@ -896,18 +896,18 @@ class Cursor:
x = min(point.x(), markPoint.x())
width = abs(point.x() - markPoint.x())
- painter.setRasterOp(Qt.XorROP)
- #painter.setRasterOp(Qt.OrROP)
- painter.fillRect(x, point.y(), width, height, QBrush(Qt.white))
+ painter.setRasterOp(TQt.XorROP)
+ #painter.setRasterOp(TQt.OrROP)
+ painter.fillRect(x, point.y(), width, height, TQBrush(TQt.white))
#painter.drawLine(point.x(), point.y()-2,
# point.x(), point.y()+height+2)
- painter.setRasterOp(Qt.CopyROP)
+ painter.setRasterOp(TQt.CopyROP)
else:
- painter.setPen(Qt.blue)
+ painter.setPen(TQt.blue)
painter.drawLine(point.x(), point.y()-2,
point.x(), point.y()+height+2)
-
+
def findIndexElement(self):
"""Looks if we are just behind an IndexElement or at the last
@@ -921,7 +921,7 @@ class Cursor:
if self.sequenceElement == parent.mainChild():
return parent
-
+
def addUpperRightIndex(self):
indexElement = self.findIndexElement()
if indexElement == None:
@@ -931,7 +931,7 @@ class Cursor:
index.moveRight(self, index.parent)
-
+
def addLowerRightIndex(self):
indexElement = self.findIndexElement()
if indexElement == None:
@@ -940,20 +940,20 @@ class Cursor:
index = indexElement.requireLowerRight()
index.moveRight(self, index.parent)
-
+
def addTextElement(self, char):
- textElement = TextElement(self.sequenceElement, QString(char))
+ textElement = TextElement(self.sequenceElement, TQString(char))
self.sequenceElement.insertChild(self, textElement)
-
+
def handleKey(self, keyEvent):
action = keyEvent.key()
state = keyEvent.state()
char = keyEvent.text().at(0)
-
+
self.mouseMarkFlag = 0
-
+
if char.isPrint():
#self.sequenceElement.handleKey(self, char)
latin1 = char.latin1()
@@ -981,42 +981,42 @@ class Cursor:
pass
else:
self.addTextElement(char)
-
+
else:
- if Qt.Key_BackSpace == action:
+ if TQt.Key_BackSpace == action:
self.sequenceElement.removeChildBefore(self)
return
- elif Qt.Key_Delete == action:
+ elif TQt.Key_Delete == action:
self.sequenceElement.removeChildAt(self)
return
- self.selectionFlag = state & Qt.ShiftButton
- if Qt.Key_Left == action:
- if state & Qt.ControlButton:
+ self.selectionFlag = state & TQt.ShiftButton
+ if TQt.Key_Left == action:
+ if state & TQt.ControlButton:
self.sequenceElement.moveHome(self)
else:
self.sequenceElement.moveLeft(self, self.sequenceElement)
- elif Qt.Key_Right == action:
- if state & Qt.ControlButton:
+ elif TQt.Key_Right == action:
+ if state & TQt.ControlButton:
self.sequenceElement.moveEnd(self)
else:
self.sequenceElement.moveRight(self, self.sequenceElement)
- elif Qt.Key_Up == action:
+ elif TQt.Key_Up == action:
self.sequenceElement.moveUp(self, self.sequenceElement)
- elif Qt.Key_Down == action:
+ elif TQt.Key_Down == action:
self.sequenceElement.moveDown(self, self.sequenceElement)
- elif Qt.Key_Home == action:
+ elif TQt.Key_Home == action:
self.sequenceElement.formula().moveHome(self)
- elif Qt.Key_End == action:
+ elif TQt.Key_End == action:
self.sequenceElement.formula().moveEnd(self)
- # Qt.Key_PageUp, Qt.Key_PageDown,
-
+ # TQt.Key_PageUp, TQt.Key_PageDown,
+
def handleMousePress(self, mouseEvent):
formula = self.sequenceElement.formula()
- element = formula.elementAt(mouseEvent.pos(), QPoint(0, 0))
+ element = formula.elementAt(mouseEvent.pos(), TQPoint(0, 0))
if element != None:
if element.parent != None:
element.moveLeft(self, element.parent)
@@ -1028,15 +1028,15 @@ class Cursor:
def handleMouseRelease(self, mouseEvent):
self.mouseMarkFlag = 0
-
+
def handleMouseMove(self, mouseEvent):
self.selectionFlag = 1
formula = self.sequenceElement.formula()
- element = formula.elementAt(mouseEvent.pos(), QPoint(0, 0))
+ element = formula.elementAt(mouseEvent.pos(), TQPoint(0, 0))
if element != None:
if element.parent != None:
element.parent.moveLeft(self, element)
-
+
def elementRemoved(self, element):
"""The cursor must not be inside a leaf which gets cut off.
@@ -1050,28 +1050,28 @@ class Cursor:
self.sequenceElement.moveHome(self)
return
e = e.parent
-
+
class StyleContext:
"""Contains all variable information that are needed to
draw a formula."""
def __init__(self):
- self.font = QFont("helvetica", 18)
+ self.font = TQFont("helvetica", 18)
def setupPainter(self, painter):
painter.setFont(self.font)
- painter.setPen(Qt.black)
+ painter.setPen(TQt.black)
def fontMetrics(self):
- return QFontMetrics(self.font)
-
-
-class Widget(QWidget):
+ return TQFontMetrics(self.font)
+
+
+class Widget(TQWidget):
"""The widget that contains a formula."""
-
+
def __init__(self):
- QWidget.__init__(self)
+ TQWidget.__init__(self)
f = self.formula = FormulaElement(self)
self.cursor = Cursor(self.formula)
self.styleContext = StyleContext()
@@ -1105,13 +1105,13 @@ class Widget(QWidget):
s3.addChild(TextElement(s3, "f"))
s3.addChild(TextElement(s3, "u"))
s3.addChild(TextElement(s3, "n"))
-
+
i2 = IndexElement(s3)
i2.requireUpperLeft()
i2.requireUpperRight()
i2.requireLowerLeft()
i2.requireLowerRight()
-
+
f.addChild(i2)
f.addChild(TextElement(f, ":"))
@@ -1132,28 +1132,28 @@ class Widget(QWidget):
self.changedFlag = 1
-
+
def changed(self):
"""Gets called each time the formula changes."""
self.changedFlag = 1
-
-
+
+
def elementRemoved(self, element):
"""The element is going to go real soon."""
self.cursor.elementRemoved(element)
-
-
+
+
def paintEvent (self, e):
if self.changedFlag:
# You need to use the same StyleContext you use for drawing.
self.formula.calcSizes(self.styleContext)
self.changedFlag = 0
-
- painter = QPainter()
+
+ painter = TQPainter()
painter.begin(self)
try:
- self.formula.draw(painter, self.styleContext, QPoint(0, 0))
+ self.formula.draw(painter, self.styleContext, TQPoint(0, 0))
self.cursor.draw(painter)
finally:
painter.end()
@@ -1162,19 +1162,18 @@ class Widget(QWidget):
def keyPressEvent(self, e):
self.cursor.handleKey(e)
self.update()
-
+
def mousePressEvent(self, e):
self.cursor.handleMousePress(e)
self.update()
-
+
def mouseReleaseEvent(self, e):
self.cursor.handleMouseRelease(e)
self.update()
-
+
def mouseDoubleClickEvent(self, e):
pass
def mouseMoveEvent(self, e):
self.cursor.handleMouseMove(e)
self.update()
-
diff --git a/lib/kformula/prototype/main.py b/lib/kformula/prototype/main.py
index 49425b92..953bc060 100755
--- a/lib/kformula/prototype/main.py
+++ b/lib/kformula/prototype/main.py
@@ -1,11 +1,11 @@
#!/usr/bin/env python
import sys
-from qt import *
+from TQt.qt import *
from engine import Widget
-a = QApplication(sys.argv)
+a = TQApplication(sys.argv)
mw = Widget()
mw.setCaption('Prototype of the formula engine')
mw.show()
diff --git a/lib/kformula/prototype/unicode.py b/lib/kformula/prototype/unicode.py
index 3559711d..cee5ea6c 100755
--- a/lib/kformula/prototype/unicode.py
+++ b/lib/kformula/prototype/unicode.py
@@ -1,18 +1,18 @@
#!/usr/bin/env python
import sys
-from qt import *
+from TQt.qt import *
from xml.sax import saxutils, handler, make_parser
-class Form1(QWidget):
+class Form1(TQWidget):
def __init__(self,parent = None,name = None,fl = 0):
- QWidget.__init__(self,parent,name,fl)
+ TQWidget.__init__(self,parent,name,fl)
if name == None:
self.setName('Form1')
self.setCaption(self.tr('Form1'))
- grid = QGridLayout(self)
+ grid = TQGridLayout(self)
grid.setSpacing(6)
grid.setMargin(11)
@@ -23,20 +23,20 @@ class Form1(QWidget):
end = 256
for i in range(begin, end):
- charLabel = QLabel(self,'charLabel' + chr(i))
- charLabel.setFont(QFont("symbol", 16))
+ charLabel = TQLabel(self,'charLabel' + chr(i))
+ charLabel.setFont(TQFont("symbol", 16))
charLabel.setText(self.tr(chr(i)))
grid.addWidget(charLabel, i-begin, 0)
-
- number = QLineEdit(self,'Number' + chr(i))
+
+ number = TQLineEdit(self,'Number' + chr(i))
grid.addWidget(number, i-begin, 1)
- latexName = QLineEdit(self,'latexName' + chr(i))
+ latexName = TQLineEdit(self,'latexName' + chr(i))
grid.addWidget(latexName, i-begin, 2)
- charClass = QLineEdit(self,'charClass' + chr(i))
+ charClass = TQLineEdit(self,'charClass' + chr(i))
grid.addWidget(charClass, i-begin, 3)
-
+
self.chars[i] = (charLabel, number, latexName, charClass)
def fontList(self):
@@ -46,13 +46,13 @@ class Form1(QWidget):
if str(number.text()) != "" or str(latexName.text()) != "" or str(charClass.text()) != "":
list.append((i, str(number.text()), str(latexName.text()), str(charClass.text())))
return list
-
+
def setFont(self, fontName, font):
fontName = fontName.replace("%20", " ")
self.fontName = fontName
for i in self.chars:
charLabel, number, latexName, charClass = self.chars[i]
- charLabel.setFont(QFont(fontName, 16))
+ charLabel.setFont(TQFont(fontName, 16))
number.setText("")
latexName.setText("")
charClass.setText("")
@@ -63,54 +63,54 @@ class Form1(QWidget):
numberWidget.setText(number)
latexNameWidget.setText(latexName)
charClassWidget.setText(charClass)
-
-class Widget(QWidget):
+
+class Widget(TQWidget):
def __init__(self):
- QWidget.__init__(self)
+ TQWidget.__init__(self)
- vbox = QVBoxLayout(self)
+ vbox = TQVBoxLayout(self)
vbox.setSpacing(6)
vbox.setMargin(0)
- hbox = QHBoxLayout()
+ hbox = TQHBoxLayout()
hbox.setSpacing(6)
hbox.setMargin(0)
- loadButton = QPushButton("load", self)
- saveButton = QPushButton("save", self)
+ loadButton = TQPushButton("load", self)
+ saveButton = TQPushButton("save", self)
+
+ TQObject.connect(loadButton, SIGNAL("pressed()"), self.load)
+ TQObject.connect(saveButton, SIGNAL("pressed()"), self.save)
- QObject.connect(loadButton, SIGNAL("pressed()"), self.load)
- QObject.connect(saveButton, SIGNAL("pressed()"), self.save)
-
hbox.addWidget(loadButton)
hbox.addWidget(saveButton)
-
+
vbox.addLayout(hbox)
-
- splitter = QSplitter(self)
- splitter.setOrientation(Qt.Vertical)
-
- self.listbox = QListBox(splitter)
-
- sv = QScrollView(splitter)
- big_box = QVBox(sv.viewport())
+
+ splitter = TQSplitter(self)
+ splitter.setOrientation(TQt.Vertical)
+
+ self.listbox = TQListBox(splitter)
+
+ sv = TQScrollView(splitter)
+ big_box = TQVBox(sv.viewport())
sv.addChild(big_box, 0, 0)
self.child = Form1(big_box)
vbox.addWidget(splitter)
- self.connect(self.listbox, SIGNAL('highlighted( const QString& )'),
+ self.connect(self.listbox, SIGNAL('highlighted( const TQString& )'),
self.fontHighlighted)
def fontHighlighted(self, fontStr):
if self.child.fontName:
self.fonts[self.child.fontName] = self.child.fontList()
-
+
font = str(fontStr)
self.child.setFont(font, self.fonts[font])
-
+
def load(self):
self.fonts = {}
parser = make_parser()
@@ -121,11 +121,11 @@ class Widget(QWidget):
for font in self.fonts:
self.listbox.insertItem(font)
self.listbox.sort()
-
+
def save(self):
if self.child.fontName:
self.fonts[self.child.fontName] = self.child.fontList()
-
+
f = open("symbol.xml", "w")
print >> f, '<?xml version="1.0" encoding="iso-8859-1"?>'
print >> f, '<table>'
@@ -139,13 +139,13 @@ class Widget(QWidget):
'" name="' + str(latexName) + \
'" class="' + str(charClass) + \
'"/>'
-
+
print >> f, ' </unicodetable>'
print >> f, '</table>'
f.close()
-class ContentGenerator(handler.ContentHandler):
+class ContentGenerator(handler.ContentHandler):
def __init__(self, fonts):
handler.ContentHandler.__init__(self)
self.fonts = fonts
@@ -175,10 +175,10 @@ class ContentGenerator(handler.ContentHandler):
#numberWidget.setText(number)
#latexNameWidget.setText(latexName)
#charClassWidget.setText(charClass)
-
-
+
+
def main():
- a = QApplication(sys.argv)
+ a = TQApplication(sys.argv)
mw = Widget()
mw.setCaption('Unicode mapping util')
diff --git a/lib/kformula/scripts/bycodes.py b/lib/kformula/scripts/bycodes.py
index 16d71959..45b787a0 100755
--- a/lib/kformula/scripts/bycodes.py
+++ b/lib/kformula/scripts/bycodes.py
@@ -7,12 +7,12 @@
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
-
+
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
-
+
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
@@ -20,7 +20,7 @@
"""
import sys
import string
-import qt
+from TQt import qt
def decode( fd, font, line ):
begin = string.find( line, '"' )
@@ -39,10 +39,10 @@ def decode( fd, font, line ):
char_list.append( string.atoi( second, 16 ) )
else:
char_list.append( string.atoi ( unicode, 16 ) )
- fm = qt.QFontMetrics( qt.QFont( font ) )
+ fm = qt.TQFontMetrics( qt.TQFont( font ) )
in_font = True
for c in char_list:
- if not fm.inFont( qt.QChar( c ) ):
+ if not fm.inFont( qt.TQChar( c ) ):
in_font = False
fd.write( unicode + ' ' + str( in_font ) + '\n')
@@ -54,9 +54,9 @@ def parse( file, font ):
if string.find( line, 'name' ) != -1:
decode( fd2, font, line )
line = fd.readline()
-
+
if __name__ == '__main__':
- a = qt.QApplication( sys.argv )
+ a = qt.TQApplication( sys.argv )
if len( sys.argv ) == 2:
sys.argv.append( 'Arev Sans' )
parse ( sys.argv[1], sys.argv[2] )
diff --git a/lib/kross/python/scripts/gui.py b/lib/kross/python/scripts/gui.py
index eda671cc..487a5862 100755
--- a/lib/kross/python/scripts/gui.py
+++ b/lib/kross/python/scripts/gui.py
@@ -1,4 +1,4 @@
-"""
+"""
Python script for a GUI-dialog.
Description:
@@ -176,72 +176,72 @@ class TkDialog:
def show(self):
self.root.mainloop()
-
+
def close(self):
self.root.destroy()
-class QtDialog:
- """ This class is used to wrap pyQt/pyKDE into a more abstract interface."""
+class TQtDialog:
+ """ This class is used to wrap PyTQt/PyTDE into a more abstract interface."""
def __init__(self, title):
- import qt
-
- class Dialog(qt.QDialog):
+ from TQt import qt
+
+ class Dialog(qt.TQDialog):
def __init__(self, parent = None, name = None, modal = 0, fl = 0):
- qt.QDialog.__init__(self, parent, name, modal, fl)
- qt.QDialog.accept = self.accept
- self.layout = qt.QVBoxLayout(self)
+ qt.TQDialog.__init__(self, parent, name, modal, fl)
+ qt.TQDialog.accept = self.accept
+ self.layout = qt.TQVBoxLayout(self)
self.layout.setSpacing(6)
self.layout.setMargin(11)
-
- class Label(qt.QLabel):
+
+ class Label(qt.TQLabel):
def __init__(self, dialog, parent, caption):
- qt.QLabel.__init__(self, parent)
+ qt.TQLabel.__init__(self, parent)
self.setText("<qt>%s</qt>" % caption.replace("\n","<br>"))
-
- class Frame(qt.QHBox):
+
+ class Frame(qt.TQHBox):
def __init__(self, dialog, parent):
- qt.QHBox.__init__(self, parent)
+ qt.TQHBox.__init__(self, parent)
self.widget = self
self.setSpacing(6)
- class Edit(qt.QHBox):
+ class Edit(qt.TQHBox):
def __init__(self, dialog, parent, caption, text):
- qt.QHBox.__init__(self, parent)
+ qt.TQHBox.__init__(self, parent)
self.setSpacing(6)
- label = qt.QLabel(caption, self)
- self.edit = qt.QLineEdit(self)
+ label = qt.TQLabel(caption, self)
+ self.edit = qt.TQLineEdit(self)
self.edit.setText( str(text) )
self.setStretchFactor(self.edit, 1)
label.setBuddy(self.edit)
def get(self):
return self.edit.text()
- class Button(qt.QPushButton):
+ class Button(qt.TQPushButton):
#def __init__(self, *args):
def __init__(self, dialog, parent, caption, commandmethod):
- #apply(qt.QPushButton.__init__, (self,) + args)
- qt.QPushButton.__init__(self, parent)
+ #apply(qt.TQPushButton.__init__, (self,) + args)
+ qt.TQPushButton.__init__(self, parent)
self.commandmethod = commandmethod
self.setText(caption)
- qt.QObject.connect(self, qt.SIGNAL("clicked()"), self.commandmethod)
+ qt.TQObject.connect(self, qt.SIGNAL("clicked()"), self.commandmethod)
- class CheckBox(qt.QCheckBox):
+ class CheckBox(qt.TQCheckBox):
def __init__(self, dialog, parent, caption, checked = True):
#TkDialog.Widget.__init__(self, dialog, parent)
- qt.QCheckBox.__init__(self, parent)
+ qt.TQCheckBox.__init__(self, parent)
self.setText(caption)
self.setChecked(checked)
#def isChecked(self):
# return self.isChecked()
- class List(qt.QHBox):
+ class List(qt.TQHBox):
def __init__(self, dialog, parent, caption, items):
- qt.QHBox.__init__(self, parent)
+ qt.TQHBox.__init__(self, parent)
self.setSpacing(6)
- label = qt.QLabel(caption, self)
- self.combo = qt.QComboBox(self)
+ label = qt.TQLabel(caption, self)
+ self.combo = qt.TQComboBox(self)
self.setStretchFactor(self.combo, 1)
label.setBuddy(self.combo)
for item in items:
@@ -251,24 +251,24 @@ class QtDialog:
def set(self, index):
self.combo.setCurrentItem(index)
- class FileChooser(qt.QHBox):
+ class FileChooser(qt.TQHBox):
def __init__(self, dialog, parent, caption, initialfile = None, filetypes = None):
- #apply(qt.QHBox.__init__, (self,) + args)
- qt.QHBox.__init__(self, parent)
+ #apply(qt.TQHBox.__init__, (self,) + args)
+ qt.TQHBox.__init__(self, parent)
self.setMinimumWidth(400)
self.initialfile = initialfile
self.filetypes = filetypes
-
- self.setSpacing(6)
- label = qt.QLabel(caption, self)
- self.edit = qt.QLineEdit(self)
+
+ self.setSpacing(6)
+ label = qt.TQLabel(caption, self)
+ self.edit = qt.TQLineEdit(self)
self.edit.setText(self.initialfile)
self.setStretchFactor(self.edit, 1)
label.setBuddy(self.edit)
-
+
browsebutton = Button(dialog, self, "...", self.browseButtonClicked)
- #qt.QObject.connect(browsebutton, qt.SIGNAL("clicked()"), self.browseButtonClicked)
+ #qt.TQObject.connect(browsebutton, qt.SIGNAL("clicked()"), self.browseButtonClicked)
def get(self):
return self.edit.text()
@@ -286,20 +286,20 @@ class QtDialog:
filtermask = "All files (*.*)"
else:
filtermask = filtermask[:-1]
-
+
filename = None
try:
- print "QtDialog.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 "QtDialog.FileChooser.browseButtonClicked() qt.QFileDialog"
- # fallback to Qt filedialog
- filename = qt.QFileDialog.getOpenFileName(self.initialfile, filtermask, self, "Save to file")
+ 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 != "":
self.edit.setText(filename)
-
+
class MessageBox:
def __init__(self, dialog, typename, caption, message):
self.widget = dialog.widget
@@ -309,19 +309,19 @@ class QtDialog:
def show(self):
result = 1
if self.typename == "okcancel":
- result = qt.QMessageBox.question(self.widget, self.caption, self.message, "&Ok", "&Cancel", "", 1)
+ result = qt.TQMessageBox.question(self.widget, self.caption, self.message, "&Ok", "&Cancel", "", 1)
else:
- qt.QMessageBox.information(self.widget, self.caption, self.message, "&Ok")
+ qt.TQMessageBox.information(self.widget, self.caption, self.message, "&Ok")
result = 0
if result == 0:
return True
return False
self.app = qt.tqApp
- self.dialog = Dialog(self.app.mainWidget(), "Dialog", 1, qt.Qt.WDestructiveClose)
+ self.dialog = Dialog(self.app.mainWidget(), "Dialog", 1, qt.TQt.WDestructiveClose)
self.dialog.setCaption(title)
- self.widget = qt.QVBox(self.dialog)
+ self.widget = qt.TQVBox(self.dialog)
self.widget.setSpacing(6)
self.dialog.layout.addWidget(self.widget)
@@ -333,15 +333,15 @@ class QtDialog:
self.List = List
self.FileChooser = FileChooser
self.MessageBox = MessageBox
-
+
def show(self):
- import qt
- qt.QApplication.setOverrideCursor(qt.Qt.arrowCursor)
+ from TQt import qt
+ qt.TQApplication.setOverrideCursor(qt.TQt.arrowCursor)
self.dialog.exec_loop()
- qt.QApplication.restoreOverrideCursor()
+ qt.TQApplication.restoreOverrideCursor()
def close(self):
- print "QtDialog.close()"
+ print "TQtDialog.close()"
self.dialog.close()
#self.dialog.deleteLater()
@@ -352,20 +352,19 @@ class Dialog:
self.dialog = None
try:
- print "Trying to import PyQt..."
- self.dialog = QtDialog(title)
- print "PyQt is our toolkit!"
+ print "Trying to import PyTQt..."
+ self.dialog = TQtDialog(title)
+ print "PyTQt is our toolkit!"
except:
try:
- print "Failed to import PyQt. 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!"
except:
- raise "Failed to import GUI-toolkit. Please install the PyQt or the Tkinter python module."
+ raise "Failed to import GUI-toolkit. Please install the PyTQt or the Tkinter python module."
+ self.widget = self.dialog.widget
- self.widget = self.dialog.widget
-
- def show(self):
+ def show(self):
self.dialog.show()
def close(self):
@@ -391,6 +390,6 @@ class Dialog:
def addList(self, parentwidget, caption, items):
return self.dialog.List(self.dialog, parentwidget.widget, caption, items)
-
+
def showMessageBox(self, typename, caption, message):
return self.dialog.MessageBox(self.dialog, typename, caption, message)
diff --git a/lib/kross/test/testcase.py b/lib/kross/test/testcase.py
index f1540201..28917f87 100644
--- a/lib/kross/test/testcase.py
+++ b/lib/kross/test/testcase.py
@@ -11,7 +11,7 @@
# print "testobjectCallbackWithParams() argument = %s" % str(argument)
# return "this is the __main__.testobjectCallbackWithParams() returnvalue!"
#def testQtObject(self):
- ## Get the QtObject instance to access the QObject.
+ ## Get the TQtObject instance to access the TQObject.
##testobject = get("TestObject")
#testobject = self.get("TestObject")
#if testobject == None: raise "Object 'TestObject' undefined !!!"
@@ -23,7 +23,7 @@
#print testobject.call("testSlot2()");
#print testobject.call("testSignal()");
##print testobject.call() #KrossTest: List::item index=0 is out of bounds. Raising TypeException.
- ## Each slot a QObject spends is a object itself.
+ ## Each slot a TQObject spends is a object itself.
#myslot = testobject.get("testSlot()")
#print "myslotevent = %s" % str(myslot)
#print myslot.call()
diff --git a/lib/kross/test/testgui.py b/lib/kross/test/testgui.py
index b6f6a28e..b5efb8dc 100644
--- a/lib/kross/test/testgui.py
+++ b/lib/kross/test/testgui.py
@@ -18,7 +18,7 @@ class TkTest:
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)
@@ -35,39 +35,39 @@ class TkTest:
import tkMessageBox
tkMessageBox.showinfo("Callback2", "Callback2 called.")
-class QtTest:
+class TQtTest:
def __init__(self):
- import qt
+ from TQt import qt
- class Button(qt.QPushButton):
+ class Button(qt.TQPushButton):
def __init__(self, *args):
- apply(qt.QPushButton.__init__, (self,) + args)
+ apply(qt.TQPushButton.__init__, (self,) + args)
- class ComboBox(qt.QHBox):
+ class ComboBox(qt.TQHBox):
def __init__(self, parent, caption, items = []):
- qt.QHBox.__init__(self, parent)
+ qt.TQHBox.__init__(self, parent)
self.setSpacing(6)
- label = qt.QLabel(str(caption), self)
- self.combobox = qt.QComboBox(self)
+ label = qt.TQLabel(str(caption), self)
+ self.combobox = qt.TQComboBox(self)
self.setStretchFactor(self.combobox, 1)
label.setBuddy(self.combobox)
for item in items:
self.combobox.insertItem( str(item) )
- class FileChooser(qt.QHBox):
+ class FileChooser(qt.TQHBox):
def __init__(self, *args):
- apply(qt.QHBox.__init__, (self,) + args)
+ apply(qt.TQHBox.__init__, (self,) + args)
self.defaultfilename = "~/output.html"
-
- self.setSpacing(6)
- label = qt.QLabel("File:", self)
- self.edit = qt.QLineEdit(self)
+
+ self.setSpacing(6)
+ label = qt.TQLabel("File:", self)
+ self.edit = qt.TQLineEdit(self)
self.edit.setText(self.defaultfilename)
self.setStretchFactor(self.edit, 1)
label.setBuddy(self.edit)
-
+
browsebutton = Button("...", self)
- qt.QObject.connect(browsebutton, qt.SIGNAL("clicked()"), self.browseButtonClicked)
+ qt.TQObject.connect(browsebutton, qt.SIGNAL("clicked()"), self.browseButtonClicked)
def file(self):
return self.edit.text()
@@ -79,23 +79,23 @@ class QtTest:
import tdefile
filename = tdefile.KFileDialog.getOpenFileName(self.defaultfilename, "*.html", self, "Save to file")
except:
- # fallback to Qt filedialog
- filename = qt.QFileDialog.getOpenFileName(self.defaultfilename, "*.html", self, "Save to file")
+ # fallback to TQt filedialog
+ filename = qt.TQFileDialog.getOpenFileName(self.defaultfilename, "*.html", self, "Save to file")
if filename != None and filename != "":
self.edit.setText(filename)
- class Dialog(qt.QDialog):
+ class Dialog(qt.TQDialog):
def __init__(self, parent = None, name = None, modal = 0, fl = 0):
- qt.QDialog.__init__(self, parent, name, modal, fl)
- qt.QDialog.accept = self.accept
+ qt.TQDialog.__init__(self, parent, name, modal, fl)
+ qt.TQDialog.accept = self.accept
self.setCaption("Export to HTML")
#self.layout()
-
- self.layout = qt.QVBoxLayout(self)
+
+ self.layout = qt.TQVBoxLayout(self)
self.layout.setSpacing(6)
self.layout.setMargin(11)
- infolabel = qt.QLabel("Export the data of a table or a query to a HTML-file.", self)
+ infolabel = qt.TQLabel("Export the data of a table or a query to a HTML-file.", self)
self.layout.addWidget(infolabel)
source = ComboBox(self, "Datasource:")
@@ -107,21 +107,21 @@ class QtTest:
self.filechooser = FileChooser(self)
self.layout.addWidget(self.filechooser)
- buttonbox = qt.QHBox(self)
+ buttonbox = qt.TQHBox(self)
buttonbox.setSpacing(6)
self.layout.addWidget(buttonbox)
savebutton = Button("Save", buttonbox)
- qt.QObject.connect(savebutton, qt.SIGNAL("clicked()"), self, qt.SLOT("accept()"))
- #qt.QObject.connect(savebutton, qt.SIGNAL("clicked()"), self.exportButtonClicked)
+ qt.TQObject.connect(savebutton, qt.SIGNAL("clicked()"), self, qt.SLOT("accept()"))
+ #qt.TQObject.connect(savebutton, qt.SIGNAL("clicked()"), self.exportButtonClicked)
cancelbutton = Button("Cancel", buttonbox)
- qt.QObject.connect(cancelbutton, qt.SIGNAL("clicked()"), self, qt.SLOT("close()"))
-
+ qt.TQObject.connect(cancelbutton, qt.SIGNAL("clicked()"), self, qt.SLOT("close()"))
+
def accept(self):
print "ACCEPTTTTTTTT !!!!!!!!!!!!!!!!!!!!!!!!!!!!"
-
- file = qt.QFile( self.filechooser.file() )
+
+ file = qt.TQFile( self.filechooser.file() )
#if not file.exists():
# print "File '%s' does not exist." % self.filechooser.file()
#else:
@@ -136,14 +136,14 @@ class QtTest:
def event(self, e):
print "=> Dialog.event %s" % e
#self.deleteLater()
- #support.swapThreadState() # calls appropriate c-function
- return qt.QDialog.event(self, e)
+ #support.swapThreadState() # calls appropriate c-function
+ return qt.TQDialog.event(self, e)
- app = qt.tqApp
+ app = qt.tqApp
dialog = Dialog(app.mainWidget(), "Dialog", 1)
dialog.show()
print "################## BEGIN"
#TkTest()
-QtTest()
+TQtTest()
print "################## END"