本文整理汇总了Python中PyQt4.QtCore.QTimeLine.setFrameRange方法的典型用法代码示例。如果您正苦于以下问题:Python QTimeLine.setFrameRange方法的具体用法?Python QTimeLine.setFrameRange怎么用?Python QTimeLine.setFrameRange使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt4.QtCore.QTimeLine
的用法示例。
在下文中一共展示了QTimeLine.setFrameRange方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Meterbar
# 需要导入模块: from PyQt4.QtCore import QTimeLine [as 别名]
# 或者: from PyQt4.QtCore.QTimeLine import setFrameRange [as 别名]
class Meterbar(Button):
def __init__(self, max=255, filename=None, width=None, height=None, x=0, y=0, pixmap=None, group=None, pos=None, size=None, padding=None):
Button.__init__(self, filename, width, height, x, y, pixmap, group, pos, size, padding)
self.max = max
self.outer = QGraphicsRectItem(x,y,width,max + 2)
self.outer.setPen(QPen(QColor(Qt.black), 1, Qt.SolidLine))
self.outer.setBrush(Qt.green)
# self.outer.hide()
self.inner = QGraphicsRectItem(x + 1,y + 1,width - 2,max)
self.inner.setPen(QPen(QColor(Qt.green), 1, Qt.SolidLine))
self.inner.setBrush(Qt.blue)
self.items = [self.outer, self.inner]
self.current = 255
self.effect = QGraphicsDropShadowEffect()
self.effect.setOffset(0, 0)
self.effect.setBlurRadius(0)
self.effect.setColor(Qt.green)
self.item = self.outer
self.addEffect('shadow', self.effect, True)
self.addAnimation('glow', Glow(15, 300, self, maxRadius=80, minRadius=5))
# self.test(10)
def test(self, x):
self.tl = QTimeLine(10000)
self.tl.setFrameRange(0, 10000)
self.a = QGraphicsItemAnimation()
self.a.setItem(self.inner)
self.a.setTimeLine(self.tl)
# self.a.setPosAt(0, QPointF(self.getX(), self.current))
# self.a.setTranslationAt(1, self.getX(), self.getY() + self.max - x + 1)
self.a.setScaleAt(0, 1, 1)
self.a.setScaleAt(1, 1, 0.1)
self.current = x
self.tl.start()
def update(self, x):
x2 = 1 - (float(x) * 1.0 / float(self.max))
# print x
# return
self.tl = QTimeLine(10)
self.tl.setFrameRange(0, 10)
self.a = QGraphicsItemAnimation()
self.a.setItem(self.inner)
self.a.setTimeLine(self.tl)
# self.a.setPosAt(0, QPointF(self.getX(), self.current))
# self.a.setTranslationAt(1, self.getX(), self.getY() + self.max - x + 1)
self.a.setScaleAt(0, 1, self.current)
self.a.setScaleAt(1, 1, x2)
self.current = x
self.tl.start()
if x > 3 :
self.play('glow')
def setScene(self, scene):
self.scene = scene
for item in self.items :
self.scene.addItem(item)
示例2: FaceButtonsView
# 需要导入模块: from PyQt4.QtCore import QTimeLine [as 别名]
# 或者: from PyQt4.QtCore.QTimeLine import setFrameRange [as 别名]
class FaceButtonsView(QGraphicsView):
def __init__(self, *args):
QGraphicsView.__init__(self, *args)
self.move(170, 90)
self.btnSize = 40
self.padding = 5
self.setMaximumHeight(self.btnSize * 4)
self.setMaximumWidth(self.btnSize * 4)
self.setMinimumHeight(self.btnSize * 4)
self.setMinimumWidth(self.btnSize * 4)
self.adjustSize()
self.setStyleSheet('background-color:transparent; border-width: 0px; border: 0px;')
self.scene = QGraphicsScene(self)
self.psButtons = QPixmap(os.getcwd() + '/../icons/PS3_Buttons.png')
self.triangle = self.psButtons.copy(0, 0, 220, 225)
self.triangle = self.triangle.scaled(self.btnSize, self.btnSize, Qt.KeepAspectRatio)
self.square = self.psButtons.copy(220, 0, 220, 225)
self.square = self.square.scaled(self.btnSize, self.btnSize, Qt.KeepAspectRatio)
self.circle = self.psButtons.copy(440, 0, 220, 225)
self.circle = self.circle.scaled(self.btnSize, self.btnSize, Qt.KeepAspectRatio)
self.cross = self.psButtons.copy(660, 0, 220, 225)
self.cross = self.cross.scaled(self.btnSize, self.btnSize, Qt.KeepAspectRatio)
self.triangleItem = QGraphicsPixmapItem(self.triangle)
self.triangleItem.setOffset(QPointF(self.btnSize + self.padding, 0))
self.scene.addItem(self.triangleItem)
self.squareItem = QGraphicsPixmapItem(self.square)
self.squareItem.setOffset(QPointF(0, self.btnSize + self.padding))
self.scene.addItem(self.squareItem)
self.circleItem = QGraphicsPixmapItem(self.circle)
self.circleItem.setOffset(QPointF(self.btnSize * 2 + self.padding * 2, self.btnSize + self.padding))
self.scene.addItem(self.circleItem)
self.crossItem = QGraphicsPixmapItem(self.cross)
self.crossItem.setOffset(QPointF(self.btnSize + self.padding, self.btnSize * 2 + self.padding * 2))
self.scene.addItem(self.crossItem)
self.effect = QGraphicsDropShadowEffect()
self.effect.setOffset(0, 0)
self.effect.setBlurRadius(20)
self.effect.setColor(Qt.green)
self.triangleItem.setGraphicsEffect(self.effect)
self.setScene(self.scene)
self.tl2 = QTimeLine(10000)
self.tl2.setFrameRange(0, 10000)
self.t = QGraphicsItemAnimation()
self.t.setItem(self.triangleItem)
self.t.setTimeLine(self.tl2)
self.tl2.connect(self.tl2, SIGNAL('frameChanged(int)'), self.updateEffect)
self.effectd = 3
self.tl2.start()
def updateEffect(self):
if self.effect.blurRadius() > 50:
self.effectd = -3
elif self.effect.blurRadius() < 5:
self.effectd = 3
self.effect.setBlurRadius(self.effect.blurRadius() + self.effectd)
示例3: DpadView
# 需要导入模块: from PyQt4.QtCore import QTimeLine [as 别名]
# 或者: from PyQt4.QtCore.QTimeLine import setFrameRange [as 别名]
class DpadView(QGraphicsView):
def __init__(self, *args):
QGraphicsView.__init__(self, *args)
self.move(2, 90)
self.btnSize = 75
self.padding = -35
self.setMaximumHeight(self.btnSize * 2 + 20)
self.setMaximumWidth(self.btnSize * 2 + 20)
self.setMinimumHeight(self.btnSize * 2 + 20)
self.setMinimumWidth(self.btnSize * 2 + 20)
self.adjustSize()
self.setStyleSheet('background-color:transparent; border-width: 0px; border: 0px;')
self.scene = QGraphicsScene(self)
self.left = QPixmap(os.getcwd() + '/../icons/left.png')
self.left = self.left.scaled(self.btnSize, self.btnSize, Qt.KeepAspectRatio)
self.right = QPixmap(os.getcwd() + '/../icons/right.png')
self.right = self.right.scaled(self.btnSize, self.btnSize, Qt.KeepAspectRatio)
self.up = QPixmap(os.getcwd() + '/../icons/up.png')
self.up = self.up.scaled(self.btnSize, self.btnSize, Qt.KeepAspectRatio)
self.down = QPixmap(os.getcwd() + '/../icons/down.png')
self.down = self.down.scaled(self.btnSize, self.btnSize, Qt.KeepAspectRatio)
self.leftItem = QGraphicsPixmapItem(self.left)
self.leftItem.setOffset(QPointF(0, self.btnSize + self.padding))
self.scene.addItem(self.leftItem)
self.rightItem = QGraphicsPixmapItem(self.right)
self.rightItem.setOffset(QPointF(self.btnSize * 2 + self.padding * 2, self.btnSize + self.padding))
self.scene.addItem(self.rightItem)
self.upItem = QGraphicsPixmapItem(self.up)
self.upItem.setOffset(QPointF(self.btnSize + self.padding, 0))
self.scene.addItem(self.upItem)
self.downItem = QGraphicsPixmapItem(self.down)
self.downItem.setOffset(QPointF(self.btnSize + self.padding, self.btnSize * 2 + self.padding * 2))
self.scene.addItem(self.downItem)
self.effect = QGraphicsDropShadowEffect()
self.effect.setOffset(0, 0)
self.effect.setBlurRadius(20)
self.effect.setColor(Qt.green)
self.downItem.setGraphicsEffect(self.effect)
self.setScene(self.scene)
self.tl2 = QTimeLine(10000)
self.tl2.setFrameRange(0, 10000)
self.t = QGraphicsItemAnimation()
self.t.setItem(self.downItem)
self.t.setTimeLine(self.tl2)
self.tl2.connect(self.tl2, SIGNAL('frameChanged(int)'), self.updateEffect)
self.effectd = 3
self.tl2.start()
def updateEffect(self):
if self.effect.blurRadius() > 50:
self.effectd = -3
elif self.effect.blurRadius() < 5:
self.effectd = 3
self.effect.setBlurRadius(self.effect.blurRadius() + self.effectd)
示例4: Joystick
# 需要导入模块: from PyQt4.QtCore import QTimeLine [as 别名]
# 或者: from PyQt4.QtCore.QTimeLine import setFrameRange [as 别名]
class Joystick(Button):
def __init__(self, outer, inner, filename=None, width=None, height=None, x=0, y=0, pixmap=None, group=None, pos=None, size=None, padding=None):
Button.__init__(self, filename, width, height, x, y, pixmap, group, pos, size, padding)
self.outer = outer
self.inner = inner
self.innerRange = 48
self.inputRange = 256
self.thresh = 5
self.outerCircle = QGraphicsEllipseItem(self.getX(), self.getY(), self.outer, self.outer)
self.outerCircle.setPen(QPen(QColor(Qt.darkGray), 1, Qt.SolidLine))
self.outerCircle.setBrush(Qt.gray)
self.innerCircle = QGraphicsEllipseItem(self.getX() + self.outer / 2 - self.inner / 2, self.getY() + self.outer / 2 - self.inner / 2, self.inner, self.inner)
self.innerCircle.setPen(QPen(QColor(Qt.darkGray), 1, Qt.SolidLine))
self.innerCircle.setBrush(Qt.lightGray)
self.currentX = 0
self.currentY = 0
self.items = [self.outerCircle, self.innerCircle]
def getItems(self):
return self.items
def setScene(self, scene):
self.scene = scene
for item in self.items :
self.scene.addItem(item)
def update(self,x,y,z):
# y = y - sqrt(x + y) if x > 0 else y
# x = x - sqrt(x + y) if y > 0 else x
x2 = x * self.innerRange / self.inputRange - self.innerRange / 2
y2 = y * self.innerRange / self.inputRange - self.innerRange / 2
x2 = x2 - sqrt(abs(y2)) if x2 >= 0 else x2 + sqrt(abs(y2))
y2 = y2 - sqrt(abs(x2)) if y2 >= 0 else y2 + sqrt(abs(x2))
if self.inputRange / 2 - self.thresh <= x <= self.inputRange / 2 + self.thresh:
x2 = 0
if self.inputRange / 2 - self.thresh <= y <= self.inputRange / 2 + self.thresh:
y2 = 0
self.tl = QTimeLine(10)
self.tl.setFrameRange(0, 10)
self.a = QGraphicsItemAnimation()
self.a.setItem(self.innerCircle)
self.a.setTimeLine(self.tl)
self.a.setPosAt(0, QPointF(self.currentX, self.currentY))
self.a.setTranslationAt(1, x2, y2)
if z:
self.innerCircle.setPen(QPen(QColor(Qt.white), 1, Qt.SolidLine))
self.innerCircle.setBrush(QColor(200, 225, 3))
else:
self.innerCircle.setPen(QPen(QColor(Qt.darkGray), 1, Qt.SolidLine))
self.innerCircle.setBrush(Qt.lightGray)
self.currentX = x2
self.currentY = y2
self.tl.start()
示例5: SingleJoystickView
# 需要导入模块: from PyQt4.QtCore import QTimeLine [as 别名]
# 或者: from PyQt4.QtCore.QTimeLine import setFrameRange [as 别名]
class SingleJoystickView(QGraphicsView):
def __init__(self, *args):
QGraphicsView.__init__(self, *args)
self.outerD = 125
self.innerD = 25
self.innerRange = 50
self.inputRange = 256
self.thresh = 3
self.worker = JoystickThread()
self.worker.valueUpdated.connect(self.moveJoystick)
self.worker.start()
self.move(30, 100)
self.setContentsMargins(0, 0, 0, 0)
self.setMaximumHeight(140)
self.setMaximumWidth(140)
self.adjustSize()
self.scene = QGraphicsScene(self)
self.outerCircle = QGraphicsEllipseItem(0, 0, self.outerD, self.outerD)
self.outerCircle.setPen(QPen(QColor(Qt.darkGray), 1, Qt.SolidLine))
self.outerCircle.setBrush(Qt.gray)
self.innerCircle = QGraphicsEllipseItem(self.outerD / 2 - self.innerD / 2, self.outerD / 2 - self.innerD / 2, self.innerD, self.innerD)
self.innerCircle.setPen(QPen(QColor(Qt.darkGray), 1, Qt.SolidLine))
self.innerCircle.setBrush(Qt.lightGray)
self.scene.addItem(self.outerCircle)
self.scene.addItem(self.innerCircle)
self.setScene(self.scene)
self.setStyleSheet('background-color:transparent;color:red')
self.currentX = 0
self.currentY = 0
def moveJoystick(self, x, y):
x2 = x * self.innerRange / self.inputRange - self.innerRange / 2
y2 = y * self.innerRange / self.inputRange - self.innerRange / 2
if -self.thresh <= x2 <= self.thresh:
x2 = 0
if -self.thresh <= y2 <= self.thresh:
y2 = 0
self.tl = QTimeLine(10)
self.tl.setFrameRange(0, 10)
self.a = QGraphicsItemAnimation()
self.a.setItem(self.innerCircle)
self.a.setTimeLine(self.tl)
self.a.setPosAt(0, QPointF(self.currentX, self.currentY))
self.a.setTranslationAt(1, x2, y2)
self.currentX = x2
self.currentY = y2
self.tl.start()
print 'x:%d y:%d' % (x2, y2)
示例6: __init__
# 需要导入模块: from PyQt4.QtCore import QTimeLine [as 别名]
# 或者: from PyQt4.QtCore.QTimeLine import setFrameRange [as 别名]
class Animation:
def __init__(self, duration, component):
self.tl = QTimeLine(duration)
self.tl.setFrameRange(0, duration)
self.component = component
self.t = QGraphicsItemAnimation()
self.t.setItem(self.component.item)
self.t.setTimeLine(self.tl)
self.tl.connect(self.tl, SIGNAL('frameChanged(int)'), self.update)
self.tl.connect(self.tl, SIGNAL('finished()'), self.finished)
def start(self):
self.tl.stop()
self.tl.start()
def update(self):
pass
def finished(self):
pass
示例7: TimedProgressBar
# 需要导入模块: from PyQt4.QtCore import QTimeLine [as 别名]
# 或者: from PyQt4.QtCore.QTimeLine import setFrameRange [as 别名]
class TimedProgressBar(QProgressBar):
"""A QProgressBar showing a certain time elapse."""
hideOnTimeout = True
def __init__(self, parent=None):
super(TimedProgressBar, self).__init__(parent, minimum=0, maximum=100)
self._timeline = QTimeLine(updateInterval=100, frameChanged=self.setValue)
self._timeline.setFrameRange(0, 100)
self._hideTimer = QTimer(timeout=self._done, singleShot=True, interval=3000)
def start(self, total, elapsed=0.0):
"""Starts showing progress.
total is the number of seconds (maybe float) the timeline will last,
elapsed (defaulting to 0) is the value to start with.
"""
self._hideTimer.stop()
self._timeline.stop()
self._timeline.setDuration(total * 1000)
self._timeline.setCurrentTime(elapsed * 1000)
self.setValue(self._timeline.currentFrame())
self._timeline.resume()
if self.hideOnTimeout:
self.show()
def stop(self, showFinished=True):
"""Ends the progress display.
If showFinished is True (the default), 100% is shown for a few
seconds and then the progress is reset.
The progressbar is hidden if the hideOnTimeout attribute is True.
"""
self._hideTimer.stop()
self._timeline.stop()
if showFinished:
self.setValue(100)
self._hideTimer.start()
else:
self._done()
def _done(self):
if self.hideOnTimeout:
self.hide()
self.reset()
示例8: RotatingIcon
# 需要导入模块: from PyQt4.QtCore import QTimeLine [as 别名]
# 或者: from PyQt4.QtCore.QTimeLine import setFrameRange [as 别名]
class RotatingIcon(QLabel):
def __init__(self,resource,parent=None,steps=20,width=15,height=15):
QLabel.__init__(self,parent)
self._resource=resource
self._steps=steps
self._width=width
self._height=height
self._progressTimeLine = QTimeLine(1000, self)
self._progressTimeLine.setFrameRange(0, self._steps)
self._progressTimeLine.setLoopCount(0)
self.connect(self._progressTimeLine, SIGNAL("frameChanged(int)"), self.setProgress)
self._renderPixmaps()
self.setProgress(0)
def _renderPixmaps(self):
self._pixmaps=[]
for i in range(self._steps+1):
angle = int(i * 360.0 / self._steps)
pixmap = QPixmap(self._resource)
# if problem with loading png
if pixmap.size().width()==0:
self._pixmaps=None
return
rotate_matrix = QMatrix()
rotate_matrix.rotate(angle)
pixmap_rotated = pixmap.transformed(rotate_matrix)
pixmap_moved = QPixmap(pixmap.size())
pixmap_moved.fill(Qt.transparent)
painter = QPainter()
painter.begin(pixmap_moved)
painter.drawPixmap((pixmap_moved.width() - pixmap_rotated.width()) / 2.0, (pixmap_moved.height() - pixmap_rotated.height()) / 2.0, pixmap_rotated)
painter.end()
self._pixmaps+=[pixmap_moved.scaled(self._width, self._height)]
def setProgress(self, progress):
if self._pixmaps!=None:
self.setPixmap(self._pixmaps[progress])
def start(self):
self.setProgress(0)
self._progressTimeLine.start()
def stop(self):
self._progressTimeLine.stop()
示例9: ProgressDialog
# 需要导入模块: from PyQt4.QtCore import QTimeLine [as 别名]
# 或者: from PyQt4.QtCore.QTimeLine import setFrameRange [as 别名]
class ProgressDialog(Ui_ProgressDialog, DialogBase):
def __init__(self, publisher, plugin, parentWidget=None):
DialogBase.__init__(self, parentWidget)
self.setupUi(self)
self.setObjectName("ProgressDialog")
self.viewButton_.setEnabled(False)
self._publisher = publisher
self._plugin = plugin
self._parent = parentWidget
self._cancelled = False
self._timeline = QTimeLine(1000*60, self)
self._timeline.setFrameRange(0, 2*60)
self._timeline.setLoopCount(0)
self.progressBar_.setRange(0, 60)
self.connect(self._timeline, QtCore.SIGNAL("frameChanged(int)"),
self.updateProgressBar)
self.outputGroupBox_ = QGroupBox("Script output", None)
self.outputTextEdit_ = QTextEdit()
self.outputTextEdit_.setTextInteractionFlags(Qt.TextSelectableByKeyboard
| Qt.TextSelectableByMouse)
self.outputTextEdit_.setReadOnly(True)
self.outputTextEdit_.setTabChangesFocus(True)
self.outputTextEdit_.setAcceptRichText(False)
groupBoxLayout = QVBoxLayout()
groupBoxLayout.setObjectName("groupBoxLayout")
groupBoxLayout.setMargin(0)
groupBoxLayout.addWidget(self.outputTextEdit_)
self.outputGroupBox_.setLayout(groupBoxLayout)
gridLayout = QGridLayout()
gridLayout.setSizeConstraint(gridLayout.SetFixedSize)
gridLayout.addWidget(self.progressLabel_, 0, 0, 1, 4)
gridLayout.addWidget(self.progressBar_, 1, 0, 1, 4)
gridLayout.addWidget(self.detailsCheckBox_, 2, 0)
hSpacer = QSpacerItem(250, 10, QSizePolicy.Expanding)
gridLayout.addItem(hSpacer, 2, 1)
gridLayout.addWidget(self.viewButton_, 2, 2)
gridLayout.addWidget(self.cancelButton_, 2, 3)
gridLayout.addWidget(self.outputGroupBox_, 3, 0, 1, 4)
self.setLayout(gridLayout)
self.outputGroupBox_.setVisible(False)
def updateProgressBar(self, frame):
self.progressBar_.setValue(self.progressBar_.value() + 1)
def on_detailsCheckBox__stateChanged(self, state):
self.outputGroupBox_.setVisible(Qt.Checked == state)
gridLayout = self.layout()
if Qt.Checked == state:
gridLayout.setSizeConstraint(gridLayout.SetMaximumSize)
self.setSizeGripEnabled(True)
else:
gridLayout.setSizeConstraint(gridLayout.SetFixedSize)
self.setSizeGripEnabled(False)
def on_cancelButton__clicked(self, released=True):
if not released:
return
if self._cancelled:
self.reject()
return
self.cancelButton_.setEnabled(False)
self.progressLabel_.setText("Cancelling...")
self._publisher.cancel()
self._cancelled = True
QTimer.singleShot(5*1000, self, QtCore.SLOT("_kill()"))
@QtCore.pyqtSignature("_kill()")
def _cancel(self):
self._parent.update()
self._publisher.cancel(True)
self.reject()
def updatePublisherOutput(self, data):
self.outputTextEdit_.append(data)
def publishComplete(self, exitCode, exitStatus):
self.progressBar_.setValue(self.progressBar_.maximum())
self._timeline.stop()
if self._cancelled:
self.reject()
self._cancelled = True
publishSuccess = (0 == exitCode and QProcess.NormalExit == exitStatus)
output_exists = self.__findOutput()
self.viewButton_.setEnabled(publishSuccess and \
output_exists)
if not publishSuccess:
self.progressLabel_.setText("Publishing failed, see script output"
" for more details")
else:
self.progressLabel_.setText("Publishing completed")
#.........这里部分代码省略.........
示例10: CanvasProps
# 需要导入模块: from PyQt4.QtCore import QTimeLine [as 别名]
# 或者: from PyQt4.QtCore.QTimeLine import setFrameRange [as 别名]
class CanvasProps (QGraphicsItem):
def __init__(self, parent=None, scene=None):
QGraphicsItem.__init__ (self)
self.parent = parent
self.helper = self.parent.getHelper()
#self.setFlags (QGraphicsItem.ItemIsSelectable)
self.setAcceptsHoverEvents (True)
self.pen_color = QPen (Qt.black, 2)
self.color = QColor (Qt.white).dark (150)
# init Canvas Animation Tweening
self.timeline = QTimeLine (200)
self.timeline.setFrameRange (0, 100)
self.anim = QGraphicsItemAnimation ()
self.anim.setItem (self)
self.anim.setTimeLine (self.timeline)
self.helper.connect (self.timeline, SIGNAL("finished()"), self.moveFurtherUp)
self.anim_active = False
#self._nodename = QGraphicsTextItem ('text '+str(self.node_id), self)
self._nodename = QGraphicsTextItem ('', self)
self._nodename.setPos (QPointF (18, 20))
self._nodename.setDefaultTextColor (QColor (Qt.white).light (255))
self._nodename.setFont (QFont ("Helvetica", 11, QFont.Bold, False))
self._nodename.setTextWidth(120)
self._nodename.setToolTip (self._nodename.toPlainText ())
#self._nodename.setHtml("<h2 align=\"center\">hello</h2><h2 align=\"center\">world 1234345345</h2>123");
self.props_list = []
self.props_textItem_value_list = []
self.FACTOR = 4.0
self._canvas_height = 0
def boundingRect (self): return QRectF (0, 0, 122, 150)
def shape (self):
path = QPainterPath ()
path.addRect (0, 0, 122, 20)
return path
def paint (self, painter, option, unused_widget):
if option.state & QStyle.State_Selected:
fillColor = self.color.dark (100)
else:
fillColor = self.color
if option.state & QStyle.State_MouseOver:
fillColor = fillColor.light (120)
if option.levelOfDetail < 0.2:
if option.levelOfDetail < 0.125:
painter.fillRect (QRectF (0, 0, 110, 70), fillColor)
return
painter.setPen (QPen (Qt.black, 0))
painter.setBrush (fillColor)
painter.drawRect (0, 0, 120, 20)
return
oldPen = painter.pen ()
pen = oldPen
width = 0
if option.state & QStyle.State_Selected:
width += 2
pen.setWidth (width)
if option.state & QStyle.State_Sunken:
level = 120
else:
level = 100
painter.setBrush (QBrush (fillColor.dark (level)))
#painter.drawRoundRect (QRect (0, 0, 80, 34+self.height), 20)
painter.drawRect (QRect (0, 20, 120, 30+9*self._canvas_height))
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
def addProp (self, prop_name, prop_value):
i = len (self.props_list)
self.props_list.append (QGraphicsTextItem (prop_name + ' : ', self))
self.props_textItem_value_list.append (CustomFloatingText (prop_value, self))
# (1) adding the prop's name.
self.props_list[i].setPos (QPointF (7, 35+i*10))
self.props_list[i].setDefaultTextColor (QColor (Qt.white).light (255))
self.props_list[i].setFont (QFont ("Helvetica", 9, QFont.StyleItalic, False))
#.........这里部分代码省略.........
示例11: MainManager
# 需要导入模块: from PyQt4.QtCore import QTimeLine [as 别名]
# 或者: from PyQt4.QtCore.QTimeLine import setFrameRange [as 别名]
#.........这里部分代码省略.........
# Anime Naruto depends on GUI
def animate(self, height):
self.ui.editBox.setMaximumHeight(height)
self.ui.profileList.setMaximumHeight(self.baseWidget.height()-height)
self.update()
def animateFinished(self):
if self.lastAnimation == SHOW:
self.ui.lineConnectionName.setFocus()
self.ui.editBox.setMaximumHeight(DEFAULT_HEIGHT)
self.ui.profileList.setMaximumHeight(TARGET_HEIGHT)
self.ui.editBox.setVerticalScrollBarPolicy(Qt.ScrollBarAsNeeded)
self.ui.buttonCreate.setEnabled(False)
self.ui.filterBox.setEnabled(False)
elif self.lastAnimation == HIDE:
self.ui.profileList.setFocus()
self.ui.profileList.setMaximumHeight(DEFAULT_HEIGHT)
self.ui.editBox.setMaximumHeight(TARGET_HEIGHT)
self.ui.profileList.setVerticalScrollBarPolicy(Qt.ScrollBarAsNeeded)
self.ui.buttonCreate.setEnabled(True)
self.ui.filterBox.setEnabled(True)
QTimer.singleShot(100, self.runFinishHook)
def runFinishHook(self):
# Call waiting functions
for func in self.animatorFinishHook:
func()
self.animatorFinishHook = []
def hideEditBox(self):
if self.lastAnimation == SHOW:
self.lastAnimation = HIDE
self.hideScrollBars()
self.animator.setFrameRange(self.ui.editBox.height(), TARGET_HEIGHT)
self.animator.start()
self.resetForm()
def showEditBox(self, package, profile=None, device=None):
sender = self.sender().parent()
self.lastAnimation = SHOW
self.hideScrollBars()
# Fill package name and package capabilities
self.lastEditedPackage = package
self.lastEditedInfo = info = self.iface.capabilities(package)
# Hide all settings first
self.ui.groupRemote.hide()
self.ui.groupNetwork.hide()
self.ui.groupNameServer.hide()
modes = info["modes"].split(",")
if "auth" in modes:
self.ui.comboSecurityTypes.clear()
self.ui.comboSecurityTypes.addItem(i18n("No Authentication"), QVariant("none"))
for name, desc in self.iface.authMethods(package):
self.ui.comboSecurityTypes.addItem(desc, QVariant(name))
# Then show them by giving package
if "net" in modes:
self.ui.groupNetwork.show()
self.ui.groupNameServer.show()
if "remote" in modes:
remote_name = self.iface.remoteName(package)
self.ui.labelRemote.setText("%s :" % remote_name)
示例12: ViewMain
# 需要导入模块: from PyQt4.QtCore import QTimeLine [as 别名]
# 或者: from PyQt4.QtCore.QTimeLine import setFrameRange [as 别名]
class ViewMain(QMainWindow):
"""This Class Provides the Graphical Interface for Game"""
# Use Constants To Avoid Magic Numbers
# Declare stack widget names
MAIN_PAGE = 0
SETTINGS_PAGE = 1
GAME_PAGE = 2
INSTRUCTIONS_PAGE = 3
CREDITS_PAGE = 4
STORY_PAGE = 5
SCORE_PAGE = 6
finished = pyqtSignal()
def __init__(self, parent=None):
"""Initialize the abstracted class instance"""
super(ViewMain, self).__init__(parent)
# Init Data Members
self.gui = Gui(self)
self.game = None
self.connectGui()
self.gameWasLoaded = False
self.useLoadWorkaround = True
# Dictionary of Graphics Objects
self.graphicsObjects = {}
# Overlays
self.overlays = {}
self.currStackIndex = self.MAIN_PAGE
self.gui.soundManager.playCurrMusic()
#self.gui.soundManager.setVolume(0)
# Timer initialization and setup for normal popups
self.popupTimelineStart = QTimeLine(200)
self.popupTimelineStart.setFrameRange(0,100)
self.popupTimelineEnd = QTimeLine(200)
self.popupTimelineEnd.setFrameRange(0,100)
self.popupTimelineWait = QTimeLine()
self.popupTimelineWait.setFrameRange(0,100)
self.popupClue = False
self.popupStory = False
# Initialization and setup for animated popups
self.popupAnimationOpen = QPropertyAnimation(self.gui.popup,"geometry")
self.popupAnimationOpen.setDuration(200)
self.popupAnimationOpen.setStartValue(QRect(0, 591, 0, 0))
self.popupAnimationOpen.setEndValue(QRect(25, 25, 750, 450))
self.popupAnimationClose = QPropertyAnimation(self.gui.popup,"geometry")
self.popupAnimationClose.setDuration(200)
self.popupAnimationClose.setStartValue(QRect(25, 25, 750, 450))
self.popupAnimationClose.setEndValue(QRect(0, 591, 0, 0))
self.popupAnimationWait = QTimeLine()
self.toMain = False
#self.gui.personView.centerOn(0,0)
self.gui.mapView.centerOn(0,0)
########################################
### Signals and slots connected here ###
########################################
# Connections for normal popups
self.popupTimelineStart.frameChanged.connect(self.drawPopup)
self.popupTimelineStart.finished.connect(self.popupWait)
self.popupTimelineEnd.frameChanged.connect(self.erasePopup)
self.popupTimelineWait.finished.connect(self.enableErasePopup)
self.popupTimelineEnd.finished.connect(self.writeClue)
# Connections for animated popups
self.popupAnimationOpen.finished.connect(self.popupAnimationWait.start)
self.popupAnimationWait.finished.connect(self.popupAnimationClose.start)
self.popupAnimationClose.finished.connect(self.popupAnimationCleanup)
self.finished.connect(self.writeStory)
def connectGui(self):
"""Connect signals for Gui"""
self.gui.actionQuit.triggered.connect(self.close)
self.gui.quitButton.released.connect(self.close)
self.gui.settingsButton.released.connect(self.setSettings)
self.gui.actionSettings.triggered.connect(self.setSettings)
self.gui.loadButton.released.connect(self.loadFileDialog)
self.gui.actionSave_Game.triggered.connect(self.saveFileDialog)
self.gui.doneButton.released.connect(self.goBack)
self.gui.startButton.released.connect(self.enterName)
self.gui.actionMain_Menu.triggered.connect(self.setMain)
self.gui.actionHelp.triggered.connect(self.setInstructions)
self.gui.instrButton.released.connect(self.setInstructions)
self.gui.doneButton2.released.connect(self.goBack)
self.gui.doneButton3.released.connect(self.goBack)
self.gui.doneButtonScore.released.connect(self.scoreButton)
self.gui.actionCredits.triggered.connect(self.setCredits)
self.gui.latLongCheck.stateChanged.connect(self.latLong)
self.gui.colorCheck.stateChanged.connect(self.colorize)
self.gui.legendCheck.stateChanged.connect(self.legend)
#.........这里部分代码省略.........
示例13: QPageWidget
# 需要导入模块: from PyQt4.QtCore import QTimeLine [as 别名]
# 或者: from PyQt4.QtCore.QTimeLine import setFrameRange [as 别名]
#.........这里部分代码省略.........
self.__pages.append(page)
self.layout.addWidget(page.widget)
# Add __tmp_page to end
self.__pages.append(self.__tmp_page)
self.layout.addWidget(self.__tmp_page.widget)
# Create connections for page navigation signals from new page
self.connect(page.widget, SIGNAL("pageNext()"), self.next)
self.connect(page.widget, SIGNAL("pagePrevious()"), self.prev)
self.connect(page.widget, SIGNAL("setCurrent(int)"), self.setCurrent)
def __setCurrent(self, pageNumber):
""" Internal method to set current page index. """
self.__last = self.__current
self.__current = min(max(0, pageNumber), len(self.__pages) - 2)
if pageNumber == len(self.__pages) - 1 and self.__return_to_first:
self.__current = 0
def setCurrent(self, pageNumber = 0):
""" Set and flip the page with given pageNumber.
pageNumber: index number of Page (default is 0)
"""
self.__setCurrent(pageNumber)
self.flipPage()
def getCurrent(self):
""" Returns current page index. """
return self.__current
def getCurrentWidget(self):
""" Returns current page widget. """
return self.getWidget(self.getCurrent())
def getWidget(self, pageNumber):
""" Returns widget for given page index
pageNumber: index number of Page
"""
try:
return self.__pages[pageNumber].widget
except:
return None
def count(self):
""" Returns number of pages. """
return len(self.__pages) - 1
def setAnimation(self, animation = 35):
""" Set the transition animation with the given animation.
animation: the number represents predefined QEasingCurves
List of predefined QEasingCurves can be found from:
http://doc.qt.nokia.com/4/qeasingcurve.html#Type-enum
Default is QEasingCurve::InOutBack (35)
"""
self.__animation = animation
self.__timeline.setEasingCurve(QEasingCurve(self.__animation))
def setDuration(self, duration = 400):
""" Set the transition duration.
duration: duration time in ms
"""
self.__duration = duration
self.__timeline.setDuration(self.__duration)
def flipPage(self, direction=0):
""" Flip the page with given direction.
direction: can be -1, 0 or +1
-1: previous page (if exists)
0: just flip to current page
+1: next page (if exists)
"""
# Enable all widgets
for page in self.__pages:
page.widget.setEnabled(True)
# Check given direction
direction = direction if direction == 0 else max(min(1, direction), -1)
# If direction is equal to zero no need to re-set current
if not direction == 0:
self.__setCurrent(self.__current + direction)
# If last page is different from new page, flip it !
if not self.__last == self.__current:
self.__timeline.setFrameRange(self.__scrollBar.value(), self.__current * self.__base_value())
self.__timeline.start()
def next(self):
""" Helper method to flip next page. """
self.flipPage(1)
def prev(self):
""" Helper method to flip previous page. """
self.flipPage(-1)
示例14: DualJoystickView
# 需要导入模块: from PyQt4.QtCore import QTimeLine [as 别名]
# 或者: from PyQt4.QtCore.QTimeLine import setFrameRange [as 别名]
class DualJoystickView(QGraphicsView):
def __init__(self, *args):
QGraphicsView.__init__(self, *args)
self.outerD = 125
self.innerD = 35
self.innerRange = 48
self.inputRange = 256
self.thresh = 3
self.padding = 40
self.worker = QSixAxisThread()
self.worker.valueUpdated.connect(self.moveJoysticks)
self.worker.start()
self.move(2, 100)
self.setContentsMargins(0, 0, 0, 0)
self.setMaximumHeight(180)
self.setMaximumWidth(420)
self.setMinimumHeight(140)
self.setMinimumWidth(300)
self.adjustSize()
self.scene = QGraphicsScene(self)
self.outerCircle1 = QGraphicsEllipseItem(0, 0, self.outerD, self.outerD)
self.outerCircle1.setPen(QPen(QColor(Qt.darkGray), 1, Qt.SolidLine))
self.outerCircle1.setBrush(Qt.gray)
self.innerCircle1 = QGraphicsEllipseItem(self.outerD / 2 - self.innerD / 2, self.outerD / 2 - self.innerD / 2, self.innerD, self.innerD)
self.innerCircle1.setPen(QPen(QColor(Qt.darkGray), 1, Qt.SolidLine))
self.innerCircle1.setBrush(Qt.lightGray)
self.scene.addItem(self.outerCircle1)
self.scene.addItem(self.innerCircle1)
self.outerCircle2 = QGraphicsEllipseItem(self.outerD + self.padding, 0, self.outerD, self.outerD)
self.outerCircle2.setPen(QPen(QColor(Qt.darkGray), 1, Qt.SolidLine))
self.outerCircle2.setBrush(Qt.gray)
self.innerCircle2 = QGraphicsEllipseItem(self.outerD + self.padding + self.outerD / 2 - self.innerD / 2, self.outerD / 2 - self.innerD / 2, self.innerD, self.innerD)
self.innerCircle2.setPen(QPen(QColor(Qt.darkGray), 1, Qt.SolidLine))
self.innerCircle2.setBrush(Qt.lightGray)
self.scene.addItem(self.outerCircle2)
self.scene.addItem(self.innerCircle2)
self.setScene(self.scene)
self.setStyleSheet('background-color:transparent;')
self.currentX = 0
self.currentY = 0
self.currentA = 0
self.currentZ = 0
self.test = QGraphicsItem(self.outerCircle2)
def moveJoysticks(self, x, y, a, z, l3, r3):
x2 = x * self.innerRange / self.inputRange - self.innerRange / 2
y2 = y * self.innerRange / self.inputRange - self.innerRange / 2
a2 = a * self.innerRange / self.inputRange - self.innerRange / 2
z2 = z * self.innerRange / self.inputRange - self.innerRange / 2
if -self.thresh <= x2 <= self.thresh:
x2 = 0
if -self.thresh <= y2 <= self.thresh:
y2 = 0
if -self.thresh <= a2 <= self.thresh:
a2 = 0
if -self.thresh <= z2 <= self.thresh:
z2 = 0
self.tl = QTimeLine(10)
self.tl.setFrameRange(0, 10)
self.a = QGraphicsItemAnimation()
self.a.setItem(self.innerCircle1)
self.a.setTimeLine(self.tl)
self.a.setPosAt(0, QPointF(self.currentX, self.currentY))
self.a.setTranslationAt(1, x2, y2)
if l3:
self.innerCircle1.setPen(QPen(QColor(Qt.white), 1, Qt.SolidLine))
self.innerCircle1.setBrush(QColor(200, 225, 3))
else:
self.innerCircle1.setPen(QPen(QColor(Qt.darkGray), 1, Qt.SolidLine))
self.innerCircle1.setBrush(Qt.lightGray)
if r3:
self.innerCircle2.setPen(QPen(QColor(Qt.white), 1, Qt.SolidLine))
self.innerCircle2.setBrush(QColor(200, 225, 3))
else:
self.innerCircle2.setPen(QPen(QColor(Qt.darkGray), 1, Qt.SolidLine))
self.innerCircle2.setBrush(Qt.lightGray)
self.b = QGraphicsItemAnimation()
self.b.setItem(self.innerCircle2)
self.b.setTimeLine(self.tl)
self.b.setPosAt(0, QPointF(self.currentA, self.currentZ))
self.b.setTranslationAt(1, a2, z2)
self.currentX = x2
self.currentY = y2
self.currentA = a2
self.currentZ = z2
self.tl.start()
示例15: SixAxisView
# 需要导入模块: from PyQt4.QtCore import QTimeLine [as 别名]
# 或者: from PyQt4.QtCore.QTimeLine import setFrameRange [as 别名]
class SixAxisView(QGraphicsView):
def __init__(self, *args):
QGraphicsView.__init__(self, *args)
self.move(20, 240)
self.outerD = 125
self.innerD = 35
self.innerRange = 48
self.inputRange = 256
self.thresh = 3
self.padding = 40
self.marginTop = 10
self.worker = QSixAxisThread()
self.worker.valueUpdated.connect(self.moveJoysticks)
self.worker.start()
self.setContentsMargins(0, 0, 0, 0)
self.setMaximumHeight(180)
self.setMaximumWidth(420)
self.setMinimumHeight(240)
self.setMinimumWidth(300)
self.adjustSize()
self.scene = QGraphicsScene(self)
self.outerCircle1 = QGraphicsEllipseItem(0, self.marginTop, self.outerD, self.outerD)
self.outerCircle1.setPen(QPen(QColor(Qt.darkGray), 1, Qt.SolidLine))
self.outerCircle1.setBrush(Qt.gray)
self.innerCircle1 = QGraphicsEllipseItem(self.outerD / 2 - self.innerD / 2, self.outerD / 2 - self.innerD / 2 + self.marginTop, self.innerD, self.innerD)
self.innerCircle1.setPen(QPen(QColor(Qt.darkGray), 1, Qt.SolidLine))
self.innerCircle1.setBrush(Qt.lightGray)
self.scene.addItem(self.outerCircle1)
self.scene.addItem(self.innerCircle1)
self.outerCircle2 = QGraphicsEllipseItem(self.outerD + self.padding, self.marginTop, self.outerD, self.outerD)
self.outerCircle2.setPen(QPen(QColor(Qt.darkGray), 1, Qt.SolidLine))
self.outerCircle2.setBrush(Qt.gray)
self.innerCircle2 = QGraphicsEllipseItem(self.outerD + self.padding + self.outerD / 2 - self.innerD / 2, self.outerD / 2 - self.innerD / 2 + self.marginTop, self.innerD, self.innerD)
self.innerCircle2.setPen(QPen(QColor(Qt.darkGray), 1, Qt.SolidLine))
self.innerCircle2.setBrush(Qt.lightGray)
self.scene.addItem(self.outerCircle2)
self.scene.addItem(self.innerCircle2)
self.setScene(self.scene)
self.setStyleSheet('background-color:transparent; border-width: 0px; border: 0px;')
self.currentX = 0
self.currentY = 0
self.currentA = 0
self.currentZ = 0
self.psBtn = QPixmap(os.getcwd() + '/../icons/bt_PS.png')
self.psBtn = self.psBtn.scaled(50, 50, Qt.KeepAspectRatio)
self.psItem = QGraphicsPixmapItem(self.psBtn)
self.psItem.setOffset(QPointF(self.outerD - 4, 0))
self.effect = QGraphicsDropShadowEffect()
self.effect.setOffset(0, 0)
self.effect.setBlurRadius(20)
self.effect.setColor(Qt.green)
self.psItem.setGraphicsEffect(self.effect)
self.scene.addItem(self.psItem)
self.tl2 = QTimeLine(10000)
self.tl2.setFrameRange(0, 10000)
self.c = QGraphicsItemAnimation()
self.c.setItem(self.psItem)
self.c.setTimeLine(self.tl2)
self.tl2.connect(self.tl2, SIGNAL('frameChanged(int)'), self.updateEffect)
self.effectd = 3
self.tl2.start()
def updateEffect(self):
if self.effect.blurRadius() > 50:
self.effectd = -3
elif self.effect.blurRadius() < 5:
self.effectd = 3
self.effect.setBlurRadius(self.effect.blurRadius() + self.effectd)
def update(self, *args, **kwargs):
return QGraphicsView.update(self, *args, **kwargs)
def moveJoysticks(self, x, y, a, z, l3, r3):
x2 = x * self.innerRange / self.inputRange - self.innerRange / 2
y2 = y * self.innerRange / self.inputRange - self.innerRange / 2
a2 = a * self.innerRange / self.inputRange - self.innerRange / 2
z2 = z * self.innerRange / self.inputRange - self.innerRange / 2
if -self.thresh <= x2 <= self.thresh:
x2 = 0
if -self.thresh <= y2 <= self.thresh:
y2 = 0
if -self.thresh <= a2 <= self.thresh:
a2 = 0
if -self.thresh <= z2 <= self.thresh:
z2 = 0
self.tl = QTimeLine(10)
self.tl.setFrameRange(0, 10)
self.a = QGraphicsItemAnimation()
self.a.setItem(self.innerCircle1)
self.a.setTimeLine(self.tl)
self.a.setPosAt(0, QPointF(self.currentX, self.currentY))
self.a.setTranslationAt(1, x2, y2)
if l3:
self.innerCircle1.setPen(QPen(QColor(Qt.white), 1, Qt.SolidLine))
self.innerCircle1.setBrush(QColor(200, 225, 3))
else:
self.innerCircle1.setPen(QPen(QColor(Qt.darkGray), 1, Qt.SolidLine))
self.innerCircle1.setBrush(Qt.lightGray)
if r3:
#.........这里部分代码省略.........