diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2021-03-25 17:20:24 +0100 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2021-04-06 11:24:08 +0200 |
commit | 27bb3f7839d9673b125f8b1b775c4398293932e2 (patch) | |
tree | b02329140fa93b3d35cc8f864672706d3325cdf7 /examples/widgets/animation | |
parent | 54f8953d629fd97460c82c977ba81d95f0dc5235 (diff) |
Port QWidget examples to snake case
Task-number: PYSIDE-1112
Change-Id: Ia42e395a3c650f4c11f05cfe5c6f67d309c4a3d3
Reviewed-by: Christian Tismer <tismer@stackless.com>
Diffstat (limited to 'examples/widgets/animation')
-rw-r--r-- | examples/widgets/animation/animatedtiles/animatedtiles.py | 90 | ||||
-rw-r--r-- | examples/widgets/animation/appchooser/appchooser.py | 14 | ||||
-rw-r--r-- | examples/widgets/animation/states/states.py | 30 |
3 files changed, 67 insertions, 67 deletions
diff --git a/examples/widgets/animation/animatedtiles/animatedtiles.py b/examples/widgets/animation/animatedtiles/animatedtiles.py index b5a030235..85ca55aa1 100644 --- a/examples/widgets/animation/animatedtiles/animatedtiles.py +++ b/examples/widgets/animation/animatedtiles/animatedtiles.py @@ -145,88 +145,88 @@ if __name__ == '__main__': app = QtWidgets.QApplication(sys.argv) - kineticPix = QtGui.QPixmap(':/images/kinetic.png') - bgPix = QtGui.QPixmap(':/images/Time-For-Lunch-2.jpg') + kinetic_pix = QtGui.QPixmap(':/images/kinetic.png') + bg_pix = QtGui.QPixmap(':/images/Time-For-Lunch-2.jpg') scene = QtWidgets.QGraphicsScene(-350, -350, 700, 700) items = [] for i in range(64): - item = Pixmap(kineticPix) - item.pixmap_item.setOffset(-kineticPix.width() / 2, - -kineticPix.height() / 2) + item = Pixmap(kinetic_pix) + item.pixmap_item.setOffset(-kinetic_pix.width() / 2, + -kinetic_pix.height() / 2) item.pixmap_item.setZValue(i) items.append(item) scene.addItem(item.pixmap_item) # Buttons. - buttonParent = QtWidgets.QGraphicsRectItem() - ellipseButton = Button(QtGui.QPixmap(':/images/ellipse.png'), buttonParent) - figure8Button = Button(QtGui.QPixmap(':/images/figure8.png'), buttonParent) - randomButton = Button(QtGui.QPixmap(':/images/random.png'), buttonParent) - tiledButton = Button(QtGui.QPixmap(':/images/tile.png'), buttonParent) - centeredButton = Button(QtGui.QPixmap(':/images/centered.png'), buttonParent) - - ellipseButton.setPos(-100, -100) - figure8Button.setPos(100, -100) - randomButton.setPos(0, 0) - tiledButton.setPos(-100, 100) - centeredButton.setPos(100, 100) - - scene.addItem(buttonParent) - buttonParent.setTransform(QtGui.QTransform().scale(0.75, 0.75)) - buttonParent.setPos(200, 200) - buttonParent.setZValue(65) + button_parent = QtWidgets.QGraphicsRectItem() + ellipse_button = Button(QtGui.QPixmap(':/images/ellipse.png'), button_parent) + figure_8button = Button(QtGui.QPixmap(':/images/figure8.png'), button_parent) + random_button = Button(QtGui.QPixmap(':/images/random.png'), button_parent) + tiled_button = Button(QtGui.QPixmap(':/images/tile.png'), button_parent) + centered_button = Button(QtGui.QPixmap(':/images/centered.png'), button_parent) + + ellipse_button.setPos(-100, -100) + figure_8button.setPos(100, -100) + random_button.setPos(0, 0) + tiled_button.setPos(-100, 100) + centered_button.setPos(100, 100) + + scene.addItem(button_parent) + button_parent.setTransform(QtGui.QTransform().scale(0.75, 0.75)) + button_parent.setPos(200, 200) + button_parent.setZValue(65) # States. - rootState = QtStateMachine.QState() - ellipseState = QtStateMachine.QState(rootState) - figure8State = QtStateMachine.QState(rootState) - randomState = QtStateMachine.QState(rootState) - tiledState = QtStateMachine.QState(rootState) - centeredState = QtStateMachine.QState(rootState) + root_state = QtStateMachine.QState() + ellipse_state = QtStateMachine.QState(root_state) + figure_8state = QtStateMachine.QState(root_state) + random_state = QtStateMachine.QState(root_state) + tiled_state = QtStateMachine.QState(root_state) + centered_state = QtStateMachine.QState(root_state) # Values. generator = QtCore.QRandomGenerator.global_() for i, item in enumerate(items): # Ellipse. - ellipseState.assignProperty(item, 'pos', + ellipse_state.assignProperty(item, 'pos', QtCore.QPointF(math.cos((i / 63.0) * 6.28) * 250, math.sin((i / 63.0) * 6.28) * 250)) # Figure 8. - figure8State.assignProperty(item, 'pos', + figure_8state.assignProperty(item, 'pos', QtCore.QPointF(math.sin((i / 63.0) * 6.28) * 250, math.sin(((i * 2)/63.0) * 6.28) * 250)) # Random. - randomState.assignProperty(item, 'pos', + random_state.assignProperty(item, 'pos', QtCore.QPointF(-250 + generator.bounded(0, 500), -250 + generator.bounded(0, 500))) # Tiled. - tiledState.assignProperty(item, 'pos', - QtCore.QPointF(((i % 8) - 4) * kineticPix.width() + kineticPix.width() / 2, - ((i // 8) - 4) * kineticPix.height() + kineticPix.height() / 2)) + tiled_state.assignProperty(item, 'pos', + QtCore.QPointF(((i % 8) - 4) * kinetic_pix.width() + kinetic_pix.width() / 2, + ((i // 8) - 4) * kinetic_pix.height() + kinetic_pix.height() / 2)) # Centered. - centeredState.assignProperty(item, 'pos', QtCore.QPointF()) + centered_state.assignProperty(item, 'pos', QtCore.QPointF()) # Ui. view = View(scene) view.setWindowTitle("Animated Tiles") view.setViewportUpdateMode(QtWidgets.QGraphicsView.BoundingRectViewportUpdate) - view.setBackgroundBrush(QtGui.QBrush(bgPix)) + view.setBackgroundBrush(QtGui.QBrush(bg_pix)) view.setCacheMode(QtWidgets.QGraphicsView.CacheBackground) view.setRenderHints( QtGui.QPainter.Antialiasing | QtGui.QPainter.SmoothPixmapTransform) view.show() states = QtStateMachine.QStateMachine() - states.addState(rootState) - states.setInitialState(rootState) - rootState.setInitialState(centeredState) + states.addState(root_state) + states.setInitialState(root_state) + root_state.setInitialState(centered_state) group = QtCore.QParallelAnimationGroup() for i, item in enumerate(items): @@ -235,25 +235,25 @@ if __name__ == '__main__': anim.setEasingCurve(QtCore.QEasingCurve.InOutBack) group.addAnimation(anim) - trans = rootState.addTransition(ellipseButton.pressed, ellipseState) + trans = root_state.addTransition(ellipse_button.pressed, ellipse_state) trans.addAnimation(group) - trans = rootState.addTransition(figure8Button.pressed, figure8State) + trans = root_state.addTransition(figure_8button.pressed, figure_8state) trans.addAnimation(group) - trans = rootState.addTransition(randomButton.pressed, randomState) + trans = root_state.addTransition(random_button.pressed, random_state) trans.addAnimation(group) - trans = rootState.addTransition(tiledButton.pressed, tiledState) + trans = root_state.addTransition(tiled_button.pressed, tiled_state) trans.addAnimation(group) - trans = rootState.addTransition(centeredButton.pressed, centeredState) + trans = root_state.addTransition(centered_button.pressed, centered_state) trans.addAnimation(group) timer = QtCore.QTimer() timer.start(125) timer.setSingleShot(True) - trans = rootState.addTransition(timer.timeout, ellipseState) + trans = root_state.addTransition(timer.timeout, ellipse_state) trans.addAnimation(group) states.start() diff --git a/examples/widgets/animation/appchooser/appchooser.py b/examples/widgets/animation/appchooser/appchooser.py index 5c9e9c6c1..752edccf4 100644 --- a/examples/widgets/animation/appchooser/appchooser.py +++ b/examples/widgets/animation/appchooser/appchooser.py @@ -69,14 +69,14 @@ class Pixmap(QtWidgets.QGraphicsWidget): self.p = QtGui.QPixmap(self.orig) -def createStates(objects, selectedRect, parent): +def create_states(objects, selectedRect, parent): for obj in objects: state = QtStateMachine.QState(parent) state.assignProperty(obj, 'geometry', selectedRect) parent.addTransition(obj.clicked, state) -def createAnimations(objects, machine): +def create_animations(objects, machine): for obj in objects: animation = QtCore.QPropertyAnimation(obj, b'geometry', obj) machine.addDefaultAnimation(animation) @@ -115,14 +115,14 @@ if __name__ == '__main__': machine.setGlobalRestorePolicy(QtStateMachine.QStateMachine.RestoreProperties) group = QtStateMachine.QState(machine) - selectedRect = QtCore.QRect(86, 86, 128, 128) + selected_rect = QtCore.QRect(86, 86, 128, 128) - idleState = QtStateMachine.QState(group) - group.setInitialState(idleState) + idle_state = QtStateMachine.QState(group) + group.setInitialState(idle_state) objects = [p1, p2, p3, p4] - createStates(objects, selectedRect, group) - createAnimations(objects, machine) + create_states(objects, selected_rect, group) + create_animations(objects, machine) machine.setInitialState(group) machine.start() diff --git a/examples/widgets/animation/states/states.py b/examples/widgets/animation/states/states.py index 77c76bd9e..f6ae7b571 100644 --- a/examples/widgets/animation/states/states.py +++ b/examples/widgets/animation/states/states.py @@ -72,10 +72,10 @@ if __name__ == '__main__': "asdf lkjha yuoiqwe asd iuaysd u iasyd uiy!") button = QtWidgets.QPushButton() - buttonProxy = QtWidgets.QGraphicsProxyWidget() - buttonProxy.setWidget(button) - editProxy = QtWidgets.QGraphicsProxyWidget() - editProxy.setWidget(edit) + button_proxy = QtWidgets.QGraphicsProxyWidget() + button_proxy.setWidget(button) + edit_proxy = QtWidgets.QGraphicsProxyWidget() + edit_proxy.setWidget(edit) box = QtWidgets.QGroupBox() box.setFlat(True) @@ -88,14 +88,14 @@ if __name__ == '__main__': layout2.addWidget(QtWidgets.QRadioButton("Petunias")) layout2.addStretch() - boxProxy = QtWidgets.QGraphicsProxyWidget() - boxProxy.setWidget(box) + box_proxy = QtWidgets.QGraphicsProxyWidget() + box_proxy.setWidget(box) # Parent widget. widget = QtWidgets.QGraphicsWidget() layout = QtWidgets.QGraphicsLinearLayout(QtCore.Qt.Vertical, widget) - layout.addItem(editProxy) - layout.addItem(buttonProxy) + layout.addItem(edit_proxy) + layout.addItem(button_proxy) widget.setLayout(layout) p1 = Pixmap(QtGui.QPixmap(':/digikam.png')) @@ -108,7 +108,7 @@ if __name__ == '__main__': scene = QtWidgets.QGraphicsScene(0, 0, 400, 300) scene.setBackgroundBrush(scene.palette().window()) scene.addItem(widget) - scene.addItem(boxProxy) + scene.addItem(box_proxy) scene.addItem(p1) scene.addItem(p2) scene.addItem(p3) @@ -138,7 +138,7 @@ if __name__ == '__main__': state1.assignProperty(p4, 'rotation', -270.0) state1.assignProperty(p5, 'rotation', -90.0) state1.assignProperty(p6, 'rotation', 270.0) - state1.assignProperty(boxProxy, 'opacity', 0.0) + state1.assignProperty(box_proxy, 'opacity', 0.0) state1.assignProperty(p1, 'opacity', 1.0) state1.assignProperty(p2, 'opacity', 1.0) state1.assignProperty(p3, 'opacity', 1.0) @@ -162,7 +162,7 @@ if __name__ == '__main__': state2.assignProperty(p4, 'rotation', 0.0) state2.assignProperty(p5, 'rotation', 0.0) state2.assignProperty(p6, 'rotation', 0.0) - state2.assignProperty(boxProxy, 'opacity', 1.0) + state2.assignProperty(box_proxy, 'opacity', 1.0) state2.assignProperty(p1, 'opacity', 0.0) state2.assignProperty(p2, 'opacity', 0.0) state2.assignProperty(p3, 'opacity', 0.0) @@ -188,10 +188,10 @@ if __name__ == '__main__': state3.assignProperty(p6, 'opacity', 1.0) t1 = state1.addTransition(button.clicked, state2) - animation1SubGroup = QtCore.QSequentialAnimationGroup() - animation1SubGroup.addPause(250) - animation1SubGroup.addAnimation(QtCore.QPropertyAnimation(box, b'geometry', state1)) - t1.addAnimation(animation1SubGroup) + animation_1sub_group = QtCore.QSequentialAnimationGroup() + animation_1sub_group.addPause(250) + animation_1sub_group.addAnimation(QtCore.QPropertyAnimation(box, b'geometry', state1)) + t1.addAnimation(animation_1sub_group) t1.addAnimation(QtCore.QPropertyAnimation(widget, b'geometry', state1)) t1.addAnimation(QtCore.QPropertyAnimation(p1, b'pos', state1)) t1.addAnimation(QtCore.QPropertyAnimation(p2, b'pos', state1)) |