diff options
Diffstat (limited to 'examples3/progress.py')
-rwxr-xr-x | examples3/progress.py | 70 |
1 files changed, 35 insertions, 35 deletions
diff --git a/examples3/progress.py b/examples3/progress.py index 001be45..cb852b9 100755 --- a/examples3/progress.py +++ b/examples3/progress.py @@ -5,10 +5,10 @@ #** #** Copyright (C) 1992-2005 Trolltech AS. All rights reserved. #** -#** This file is part of an example program for Qt. This example +#** This file is part of an example program for TQt. This example #** program may be used, distributed and modified without limitation. #** -#** Converted to PyQt3 by Hans-Peter Jansen <hpj@urpla.net> +#** Converted to PyTQt3 by Hans-Peter Jansen <hpj@urpla.net> #** #*****************************************************************************/ @@ -16,11 +16,11 @@ import sys from qt import * from random import randint -class AnimatedThingy(QLabel): +class AnimatedThingy(TQLabel): def __init__(self, parent, s): - QLabel.__init__(self, parent) - self.label = QString(s) - self.setEraseColor(Qt.white) + TQLabel.__init__(self, parent) + self.label = TQString(s) + self.setEraseColor(TQt.white) self.label.append("\n... and wasting CPU\nwith this animation!\n") self.step = 0 self.nqix = 10 @@ -41,14 +41,14 @@ class AnimatedThingy(QLabel): def show(self): if not self.isVisible(): self.startTimer(self.tdelay) - QWidget.show(self) + TQWidget.show(self) def hide(self): - QWidget.hide(self) + TQWidget.hide(self) self.killTimers() def sizeHint(self): - return QSize(120, 100) + return TQSize(120, 100) def timerEvent(self, e): p, pn = self._painter() @@ -77,24 +77,24 @@ class AnimatedThingy(QLabel): self._drawtxt(p) def _painter(self): - p = QPainter(self) - # we need to create a new pen from p.pen() with QPen() in order + p = TQPainter(self) + # we need to create a new pen from p.pen() with TQPen() in order # to make it fully functional (changes are discarded otherwise) - pn = QPen(p.pen()) + pn = TQPen(p.pen()) pn.setWidth(self.lwidth) p.setPen(pn) return p, pn def _drawqix(self, p, pn, step): # rainbow effect - pn.setColor(QColor((step * 255)/self.nqix, 255, 255, QColor.Hsv)) + pn.setColor(TQColor((step * 255)/self.nqix, 255, 255, TQColor.Hsv)) p.setPen(pn) p.drawLine(self.ox[step][0], self.oy[step][0], self.ox[step][1], self.oy[step][1]) def _drawtxt(self, p): p.setPen(self.colorGroup().text()) - p.drawText(self.rect(), Qt.AlignCenter, self.label) + p.drawText(self.rect(), TQt.AlignCenter, self.label) def _inc(self, x, dx, b): x += dx @@ -107,9 +107,9 @@ class AnimatedThingy(QLabel): return x, dx -class CPUWaster(QWidget): +class CPUWaster(TQWidget): def __init__(self): - QWidget.__init__(self) + TQWidget.__init__(self) self.first_draw_item = 1000 self.last_draw_item = 1006 self.rects = 0 @@ -117,38 +117,38 @@ class CPUWaster(QWidget): self.default_label = 0 self.got_stop = False self.pb = None # non modal progress dialog - self.menubar = menubar = QMenuBar(self, "menu") - self.file_ = file_ = QPopupMenu() + self.menubar = menubar = TQMenuBar(self, "menu") + self.file_ = file_ = TQPopupMenu() menubar.insertItem("&File", file_) for i in range(self.first_draw_item, self.last_draw_item + 1): file_.insertItem(self.drawItemText(i), i) - file_.setAccel(QKeySequence( + file_.setAccel(TQKeySequence( "Ctrl+%s" % (i - self.first_draw_item)), i) self.connect(menubar, SIGNAL("activated(int)"), self.doMenuItem) file_.insertSeparator() - file_.insertItem("Quit", qApp, SLOT("quit()"), QKeySequence("Ctrl+Q")) - self.options = options = QPopupMenu() + file_.insertItem("Quit", qApp, SLOT("quit()"), TQKeySequence("Ctrl+Q")) + self.options = options = TQPopupMenu() menubar.insertItem("&Options", options) self.ld_id = options.insertItem("Loop driven", self.loopDriven, - QKeySequence("Alt+L")) + TQKeySequence("Alt+L")) self.td_id = options.insertItem("Timer driven", self.timerDriven, - QKeySequence("Alt+T")) + TQKeySequence("Alt+T")) options.insertSeparator() self.dl_id = options.insertItem("Default label", self.defaultLabel, - QKeySequence("Alt+D")) + TQKeySequence("Alt+D")) self.cl_id = options.insertItem("Custom label", self.customLabel, - QKeySequence("Alt+C")) + TQKeySequence("Alt+C")) options.insertSeparator() self.md_id = options.insertItem("No minimum duration", self.toggleMinimumDuration, - QKeySequence("Alt+M")) + TQKeySequence("Alt+M")) options.setCheckable(True) # default option settings self.timerDriven() self.customLabel() self.toggleMinimumDuration() self.resize(400, 300) - self.setEraseColor(Qt.black) + self.setEraseColor(TQt.black) def drawItemRects(self, id_): r = 100 @@ -160,7 +160,7 @@ class CPUWaster(QWidget): return r def drawItemText(self, id_): - return QString("%d Rectangles" % self.drawItemRects(id_)) + return TQString("%d Rectangles" % self.drawItemRects(id_)) def enableDrawingItems(self, yes): for i in range(self.first_draw_item, self.last_draw_item + 1): @@ -199,7 +199,7 @@ class CPUWaster(QWidget): self.got_stop = True def newProgressDialog(self, label, steps, modal): - d = QProgressDialog(label, "Cancel", steps, self, "progress", modal) + d = TQProgressDialog(label, "Cancel", steps, self, "progress", modal) if self.options.isItemChecked(self.md_id): d.setMinimumDuration(0) if not self.default_label: @@ -223,7 +223,7 @@ class CPUWaster(QWidget): else: # loop driven with modal progress dialog lpb = self.newProgressDialog("Drawing rectangles.\n" "Using loop.", n, True) - p = QPainter(self) + p = TQPainter(self) for i in range(n): lpb.setProgress(i) if lpb.wasCancelled(): @@ -237,7 +237,7 @@ class CPUWaster(QWidget): if not self.got_stop: self.pb.setProgress(self.pb.totalSteps() - self.rects) self.rects -= 1 - p = QPainter(self) + p = TQPainter(self) self._draw(p) if not self.rects or self.got_stop: @@ -254,19 +254,19 @@ class CPUWaster(QWidget): ww = self.width() wh = self.height() if ww > 8 and wh > 8: - c = QColor(randint(0, 255), randint(0, 255), randint(0, 255)) + c = TQColor(randint(0, 255), randint(0, 255), randint(0, 255)) x = randint(0, ww - 8) y = randint(0, wh - 8) w = randint(0, ww - x) h = randint(0, wh - y) - p.fillRect(x, y, w, h, QBrush(c)) + p.fillRect(x, y, w, h, TQBrush(c)) def _clear(self, p): - p.fillRect(0, 0, self.width(), self.height(), QBrush(self.eraseColor())) + p.fillRect(0, 0, self.width(), self.height(), TQBrush(self.eraseColor())) if __name__ == "__main__": - app = QApplication(sys.argv) + app = TQApplication(sys.argv) try: n = int(sys.argv[1]) except: |