aboutsummaryrefslogtreecommitdiffstats
path: root/examples/statemachine/twowaybutton
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2022-09-15 13:21:53 +0200
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2022-09-16 10:30:36 +0200
commitcf32b66adbfb489cd6e5d5c0bf3f741b59ba204c (patch)
tree44be69c9487f5d4db1092d061a555bd6001c1ab4 /examples/statemachine/twowaybutton
parentb20d6f6906f91f9df608d7800f4e27f7a7160abe (diff)
Move examples around
Change the directory structure to closer match that of Qt. Task-number: PYSIDE-841 Change-Id: I87aca346b6654aafe94dd1fb83c184c182ceb2e6 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
Diffstat (limited to 'examples/statemachine/twowaybutton')
-rw-r--r--examples/statemachine/twowaybutton/twowaybutton.py33
-rw-r--r--examples/statemachine/twowaybutton/twowaybutton.pyproject3
2 files changed, 36 insertions, 0 deletions
diff --git a/examples/statemachine/twowaybutton/twowaybutton.py b/examples/statemachine/twowaybutton/twowaybutton.py
new file mode 100644
index 000000000..35a582f93
--- /dev/null
+++ b/examples/statemachine/twowaybutton/twowaybutton.py
@@ -0,0 +1,33 @@
+# Copyright (C) 2010 velociraptor Genjix <aphidia@hotmail.com>
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+import sys
+
+from PySide6.QtWidgets import QApplication, QPushButton
+from PySide6.QtStateMachine import QState, QStateMachine
+
+
+if __name__ == '__main__':
+ app = QApplication(sys.argv)
+ button = QPushButton()
+ machine = QStateMachine()
+
+ off = QState()
+ off.assignProperty(button, 'text', 'Off')
+ off.setObjectName('off')
+
+ on = QState()
+ on.setObjectName('on')
+ on.assignProperty(button, 'text', 'On')
+
+ off.addTransition(button.clicked, on)
+ on.addTransition(button.clicked, off)
+
+ machine.addState(off)
+ machine.addState(on)
+ machine.setInitialState(off)
+ machine.start()
+ button.resize(100, 50)
+ button.show()
+ sys.exit(app.exec())
diff --git a/examples/statemachine/twowaybutton/twowaybutton.pyproject b/examples/statemachine/twowaybutton/twowaybutton.pyproject
new file mode 100644
index 000000000..223a51e32
--- /dev/null
+++ b/examples/statemachine/twowaybutton/twowaybutton.pyproject
@@ -0,0 +1,3 @@
+{
+ "files": ["twowaybutton.py"]
+}