diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2021-01-26 08:40:30 +0100 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2021-01-26 11:20:26 +0100 |
commit | 019ab0d2388e30def0cb982c14e011af119d2409 (patch) | |
tree | cc34379c3114f67fcbe2477cb7c5294c17c6fa50 /examples/widgets/state-machine | |
parent | f2e3e8d8d34c93dc8e61d0efd01a59f542abd94c (diff) |
PySide6: Re-add QStateMachine
The code was moved from QtCore into a separate library, QStateMachine,
within the qtscxml repository.
Re-add tests and fix examples.
Task-number: PYSIDE-904
Task-number: PYSIDE-1482
Change-Id: I977b4835b3345fb342c369e4fdd92646118f7fda
Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
Diffstat (limited to 'examples/widgets/state-machine')
-rw-r--r-- | examples/widgets/state-machine/eventtrans.py | 4 | ||||
-rw-r--r-- | examples/widgets/state-machine/factstates.py | 5 | ||||
-rw-r--r-- | examples/widgets/state-machine/pingpong.py | 4 | ||||
-rw-r--r-- | examples/widgets/state-machine/rogue.py | 14 | ||||
-rw-r--r-- | examples/widgets/state-machine/trafficlight.py | 4 | ||||
-rw-r--r-- | examples/widgets/state-machine/twowaybutton.py | 4 |
6 files changed, 24 insertions, 11 deletions
diff --git a/examples/widgets/state-machine/eventtrans.py b/examples/widgets/state-machine/eventtrans.py index 3445832a0..312b4e258 100644 --- a/examples/widgets/state-machine/eventtrans.py +++ b/examples/widgets/state-machine/eventtrans.py @@ -2,7 +2,7 @@ ############################################################################# ## ## Copyright (C) 2010 velociraptor Genjix <aphidia@hotmail.com> -## Copyright (C) 2016 The Qt Company Ltd. +## Copyright (C) 2021 The Qt Company Ltd. ## Contact: http://www.qt.io/licensing/ ## ## This file is part of the Qt for Python examples of the Qt Toolkit. @@ -42,6 +42,8 @@ from PySide6.QtWidgets import * from PySide6.QtCore import * +from PySide6.QtStateMachine import QEventTransition, QState, QStateMachine + class MainWindow(QMainWindow): def __init__(self): diff --git a/examples/widgets/state-machine/factstates.py b/examples/widgets/state-machine/factstates.py index 64b9613ec..3608f2a49 100644 --- a/examples/widgets/state-machine/factstates.py +++ b/examples/widgets/state-machine/factstates.py @@ -2,7 +2,7 @@ ############################################################################# ## ## Copyright (C) 2010 velociraptor Genjix <aphidia@hotmail.com> -## Copyright (C) 2016 The Qt Company Ltd. +## Copyright (C) 2021 The Qt Company Ltd. ## Contact: http://www.qt.io/licensing/ ## ## This file is part of the Qt for Python examples of the Qt Toolkit. @@ -42,6 +42,9 @@ from PySide6.QtWidgets import * from PySide6.QtCore import * +from PySide6.QtStateMachine import (QFinalState, QSignalTransition, QState, + QStateMachine) + class Factorial(QObject): xChanged = Signal(int) diff --git a/examples/widgets/state-machine/pingpong.py b/examples/widgets/state-machine/pingpong.py index 6d64bebc6..f2e1f59f7 100644 --- a/examples/widgets/state-machine/pingpong.py +++ b/examples/widgets/state-machine/pingpong.py @@ -2,7 +2,7 @@ ############################################################################# ## ## Copyright (C) 2010 velociraptor Genjix <aphidia@hotmail.com> -## Copyright (C) 2016 The Qt Company Ltd. +## Copyright (C) 2021 The Qt Company Ltd. ## Contact: http://www.qt.io/licensing/ ## ## This file is part of the Qt for Python examples of the Qt Toolkit. @@ -42,6 +42,8 @@ from PySide6.QtWidgets import * from PySide6.QtCore import * +from PySide6.QtStateMachine import QAbstractTransition, QState, QStateMachine + class PingEvent(QEvent): def __init__(self): diff --git a/examples/widgets/state-machine/rogue.py b/examples/widgets/state-machine/rogue.py index af37b522b..b830d6023 100644 --- a/examples/widgets/state-machine/rogue.py +++ b/examples/widgets/state-machine/rogue.py @@ -2,7 +2,7 @@ ############################################################################# ## ## Copyright (C) 2010 velociraptor Genjix <aphidia@hotmail.com> -## Copyright (C) 2016 The Qt Company Ltd. +## Copyright (C) 2021 The Qt Company Ltd. ## Contact: http://www.qt.io/licensing/ ## ## This file is part of the Qt for Python examples of the Qt Toolkit. @@ -43,6 +43,9 @@ from PySide6.QtWidgets import * from PySide6.QtGui import * from PySide6.QtCore import * +from PySide6.QtStateMachine import (QEventTransition, QFinalState, + QKeyEventTransition, QState, QStateMachine) + class MovementTransition(QEventTransition): def __init__(self, window): @@ -83,12 +86,11 @@ class MainWindow(QMainWindow): self.height = 20 self.statusStr = '' - database = QFontDatabase() font = QFont() - if 'Monospace' in database.families(): + if 'Monospace' in QFontDatabase.families(): font = QFont('Monospace', 12) else: - for family in database.families(): + for family in QFontDatabase.families(): if database.isFixedPitch(family): font = QFont(family, 12) self.setFont(font) @@ -98,12 +100,12 @@ class MainWindow(QMainWindow): self.show() def setupMap(self): self.map = [] - qsrand(QTime(0, 0, 0).secsTo(QTime.currentTime())) + generator = QRandomGenerator().global_() for x in range(self.width): column = [] for y in range(self.height): if x == 0 or x == self.width - 1 or y == 0 or \ - y == self.height - 1 or qrand() % 40 == 0: + y == self.height - 1 or generator.bounded(0, 40) == 0: column.append('#') else: column.append('.') diff --git a/examples/widgets/state-machine/trafficlight.py b/examples/widgets/state-machine/trafficlight.py index 4aa8d560e..3631fdbbb 100644 --- a/examples/widgets/state-machine/trafficlight.py +++ b/examples/widgets/state-machine/trafficlight.py @@ -43,6 +43,8 @@ from PySide6.QtWidgets import * from PySide6.QtGui import * from PySide6.QtCore import * +from PySide6.QtStateMachine import QFinalState, QState, QStateMachine + class LightWidget(QWidget): def __init__(self, color): @@ -83,7 +85,7 @@ class TrafficLightWidget(QWidget): self.greenLight = LightWidget(Qt.green) vbox.addWidget(self.greenLight) pal = QPalette() - pal.setColor(QPalette.Background, Qt.black) + pal.setColor(QPalette.Window, Qt.black) self.setPalette(pal) self.setAutoFillBackground(True) diff --git a/examples/widgets/state-machine/twowaybutton.py b/examples/widgets/state-machine/twowaybutton.py index 44a011d69..6b3c58359 100644 --- a/examples/widgets/state-machine/twowaybutton.py +++ b/examples/widgets/state-machine/twowaybutton.py @@ -2,7 +2,7 @@ ############################################################################# ## ## Copyright (C) 2010 velociraptor Genjix <aphidia@hotmail.com> -## Copyright (C) 2016 The Qt Company Ltd. +## Copyright (C) 2021 The Qt Company Ltd. ## Contact: http://www.qt.io/licensing/ ## ## This file is part of the Qt for Python examples of the Qt Toolkit. @@ -42,6 +42,8 @@ from PySide6.QtWidgets import * from PySide6.QtCore import * +from PySide6.QtStateMachine import QState, QStateMachine + if __name__ == '__main__': import sys |