diff options
Diffstat (limited to 'examples3/tut12.py')
-rwxr-xr-x | examples3/tut12.py | 90 |
1 files changed, 45 insertions, 45 deletions
diff --git a/examples3/tut12.py b/examples3/tut12.py index 818afd3..a16b088 100755 --- a/examples3/tut12.py +++ b/examples3/tut12.py @@ -1,6 +1,6 @@ #!/usr/bin/env python -# Qt tutorial 12. +# TQt tutorial 12. import sys import math @@ -8,17 +8,17 @@ import random import qt -class LCDRange(qt.QVBox): +class LCDRange(qt.TQVBox): def __init__(self, s=None, parent=None, name=None): - qt.QVBox.__init__(self, parent, name) + qt.TQVBox.__init__(self, parent, name) - lcd = qt.QLCDNumber(2, self, "lcd") - self.slider = qt.QSlider(qt.Qt.Horizontal, self, "slider") + lcd = qt.TQLCDNumber(2, self, "lcd") + self.slider = qt.TQSlider(qt.TQt.Horizontal, self, "slider") self.slider.setRange(0, 99) self.slider.setValue(0) - self.label = qt.QLabel(" ", self, "label") - self.label.setAlignment(qt.Qt.AlignCenter) + self.label = qt.TQLabel(" ", self, "label") + self.label.setAlignment(qt.TQt.AlignCenter) self.connect(self.slider, qt.SIGNAL("valueChanged(int)"), lcd, qt.SLOT("display(int)")) self.connect(self.slider, qt.SIGNAL("valueChanged(int)"), self, qt.PYSIGNAL("valueChanged(int)")) @@ -47,24 +47,24 @@ class LCDRange(qt.QVBox): self.label.setText(s) -class CannonField(qt.QWidget): +class CannonField(qt.TQWidget): def __init__(self, parent=None, name=None): - qt.QWidget.__init__(self, parent, name) + qt.TQWidget.__init__(self, parent, name) self.ang = 45 self.f = 0 self.timerCount = 0 - self.autoShootTimer = qt.QTimer(self, "movement handler") + self.autoShootTimer = qt.TQTimer(self, "movement handler") self.connect(self.autoShootTimer, qt.SIGNAL("timeout()"), self.moveShot) self.shoot_ang = 0 self.shoot_f = 0 - self.target = qt.QPoint(0, 0) + self.target = qt.TQPoint(0, 0) - self.setPalette(qt.QPalette(qt.QColor(250, 250, 200))) + self.setPalette(qt.TQPalette(qt.TQColor(250, 250, 200))) - self.barrelRect = qt.QRect(33, -4, 15, 8) + self.barrelRect = qt.TQRect(33, -4, 15, 8) self.newTarget() @@ -103,12 +103,12 @@ class CannonField(qt.QWidget): self.autoShootTimer.start(50) def newTarget(self): - r = qt.QRegion(self.targetRect()) - self.target = qt.QPoint(random.randint(200, 390), random.randint(10, 265)) - self.repaint(r.unite(qt.QRegion(self.targetRect()))) + r = qt.TQRegion(self.targetRect()) + self.target = qt.TQPoint(random.randint(200, 390), random.randint(10, 265)) + self.repaint(r.unite(qt.TQRegion(self.targetRect()))) def moveShot(self): - r = qt.QRegion(self.shotRect()) + r = qt.TQRegion(self.shotRect()) self.timerCount = self.timerCount + 1 shotR = self.shotRect() @@ -120,13 +120,13 @@ class CannonField(qt.QWidget): self.autoShootTimer.stop() self.emit(qt.PYSIGNAL("missed()"), ()) else: - r = r.unite(qt.QRegion(shotR)) + r = r.unite(qt.TQRegion(shotR)) self.repaint(r) def paintEvent(self, ev): updateR = ev.rect() - p = qt.QPainter(self) + p = qt.TQPainter(self) if updateR.intersects(self.cannonRect()): self.paintCannon(p) @@ -138,26 +138,26 @@ class CannonField(qt.QWidget): self.paintTarget(p) def paintShot(self, p): - p.setBrush(qt.Qt.black) - p.setPen(qt.Qt.NoPen) + p.setBrush(qt.TQt.black) + p.setPen(qt.TQt.NoPen) p.drawRect(self.shotRect()) def paintTarget(self, p): - p.setBrush(qt.Qt.red) - p.setPen(qt.Qt.black) + p.setBrush(qt.TQt.red) + p.setPen(qt.TQt.black) p.drawRect(self.targetRect()) def paintCannon(self, p): cr = self.cannonRect() - pix = qt.QPixmap(cr.size()) + pix = qt.TQPixmap(cr.size()) pix.fill(self, cr.topLeft()) - tmp = qt.QPainter(pix) - tmp.setBrush(qt.Qt.blue) - tmp.setPen(qt.Qt.NoPen) + tmp = qt.TQPainter(pix) + tmp.setBrush(qt.TQt.blue) + tmp.setPen(qt.TQt.NoPen) tmp.translate(0, pix.height() - 1) - tmp.drawPie(qt.QRect(-35, -35, 70, 70), 0, 90 * 16) + tmp.drawPie(qt.TQRect(-35, -35, 70, 70), 0, 90 * 16) tmp.rotate(-self.ang) tmp.drawRect(self.barrelRect) tmp.end() @@ -165,7 +165,7 @@ class CannonField(qt.QWidget): p.drawPixmap(cr.topLeft(), pix) def cannonRect(self): - r = qt.QRect(0, 0, 50, 50) + r = qt.TQRect(0, 0, 50, 50) r.moveBottomLeft(self.rect().bottomLeft()) return r @@ -183,25 +183,25 @@ class CannonField(qt.QWidget): x = x0 + velx * time y = y0 + vely * time - 0.5 * gravity * time * time - r = qt.QRect(0, 0, 6, 6) - r.moveCenter(qt.QPoint(x, self.height() - 1 - y)) + r = qt.TQRect(0, 0, 6, 6) + r.moveCenter(qt.TQPoint(x, self.height() - 1 - y)) return r def targetRect(self): - r = qt.QRect(0, 0, 20, 10) - r.moveCenter(qt.QPoint(self.target.x(), self.height() - 1 - self.target.y())) + r = qt.TQRect(0, 0, 20, 10) + r.moveCenter(qt.TQPoint(self.target.x(), self.height() - 1 - self.target.y())) return r def sizePolicy(self): - return qt.QSizePolicy(qt.QSizePolicy.Expanding, qt.QSizePolicy.Expanding) + return qt.TQSizePolicy(qt.TQSizePolicy.Expanding, qt.TQSizePolicy.Expanding) -class MyWidget(qt.QWidget): +class MyWidget(qt.TQWidget): def __init__(self, parent=None, name=None): - qt.QWidget.__init__(self, parent, name) + qt.TQWidget.__init__(self, parent, name) - quit = qt.QPushButton("&Quit", self, "quit") - quit.setFont(qt.QFont("Times", 18, qt.QFont.Bold)) + quit = qt.TQPushButton("&Quit", self, "quit") + quit.setFont(qt.TQFont("Times", 18, qt.TQFont.Bold)) self.connect(quit, qt.SIGNAL("clicked()"), qt.qApp, qt.SLOT("quit()")) self.angle = LCDRange("ANGLE", self, "angle") @@ -218,22 +218,22 @@ class MyWidget(qt.QWidget): self.connect(self.force, qt.PYSIGNAL("valueChanged(int)"), self.cannonField.setForce) self.connect(self.cannonField, qt.PYSIGNAL("forceChanged(int)"), self.force.setValue) - shoot = qt.QPushButton("&Shoot", self, "shoot") - shoot.setFont(qt.QFont("Times", 18, qt.QFont.Bold)) + shoot = qt.TQPushButton("&Shoot", self, "shoot") + shoot.setFont(qt.TQFont("Times", 18, qt.TQFont.Bold)) self.connect(shoot, qt.SIGNAL("clicked()"), self.cannonField.shoot) - grid = qt.QGridLayout(self, 2, 2, 10) + grid = qt.TQGridLayout(self, 2, 2, 10) grid.addWidget(quit, 0, 0) grid.addWidget(self.cannonField, 1, 1) grid.setColStretch(1, 10) - leftBox = qt.QVBoxLayout() + leftBox = qt.TQVBoxLayout() grid.addLayout(leftBox, 1, 0) leftBox.addWidget(self.angle) leftBox.addWidget(self.force) - topBox = qt.QHBoxLayout() + topBox = qt.TQHBoxLayout() grid.addLayout(topBox, 0, 1) topBox.addWidget(shoot) topBox.addStretch(1) @@ -243,8 +243,8 @@ class MyWidget(qt.QWidget): self.angle.setFocus() -qt.QApplication.setColorSpec(qt.QApplication.CustomColor) -a = qt.QApplication(sys.argv) +qt.TQApplication.setColorSpec(qt.TQApplication.CustomColor) +a = qt.TQApplication(sys.argv) w = MyWidget() w.setGeometry(100, 100, 500, 355) |