diff options
author | Shyamnath Premnadh <Shyamnath.Premnadh@qt.io> | 2024-01-26 13:39:41 +0100 |
---|---|---|
committer | Shyamnath Premnadh <Shyamnath.Premnadh@qt.io> | 2024-02-26 11:30:44 +0100 |
commit | 6b8ca656b9c41a8f247047fa24e6cdb028423354 (patch) | |
tree | d8c9ff32773772e77832e61b58097955d8817f03 /examples/multimedia | |
parent | b5140977291be15951b723ba58379b3d7c54df70 (diff) |
Examples: adapt to consider permission API on macOS
- When Python is run in interpreter mode, we print and exist with
a message.
Pick-to: 6.5 6.6
Task-number: PYSIDE-2468
Change-Id: I79ce06eb2b96418fc2f84c11cccbd2e72207f3c1
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Diffstat (limited to 'examples/multimedia')
-rw-r--r-- | examples/multimedia/audiosource/audiosource.py | 10 | ||||
-rw-r--r-- | examples/multimedia/camera/camera.py | 14 |
2 files changed, 20 insertions, 4 deletions
diff --git a/examples/multimedia/audiosource/audiosource.py b/examples/multimedia/audiosource/audiosource.py index bc2d606c0..a78beb584 100644 --- a/examples/multimedia/audiosource/audiosource.py +++ b/examples/multimedia/audiosource/audiosource.py @@ -25,7 +25,7 @@ from PySide6.QtWidgets import (QApplication, QComboBox, QPushButton, QSlider, QV is_android = os.environ.get('ANDROID_ARGUMENT') -if is_android: +if is_android or sys.platform == "darwin": from PySide6.QtCore import QMicrophonePermission @@ -93,7 +93,13 @@ class InputTest(QWidget): @Slot() def initialize(self): - if is_android: + if is_android or sys.platform == "darwin": + is_nuitka = "__compiled__" in globals() + if not is_nuitka and sys.platform == "darwin": + print("This example does not work on macOS when Python is run in interpreted mode." + "For this example to work on macOS, package the example using pyside6-deploy" + "For more information, read `Notes for Developer` in the documentation") + sys.exit(0) permission = QMicrophonePermission() permission_status = qApp.checkPermission(permission) # noqa: F821 if permission_status == Qt.PermissionStatus.Undetermined: diff --git a/examples/multimedia/camera/camera.py b/examples/multimedia/camera/camera.py index f66f28a21..fa379c807 100644 --- a/examples/multimedia/camera/camera.py +++ b/examples/multimedia/camera/camera.py @@ -2,6 +2,7 @@ # SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause import os +import sys from pathlib import Path from PySide6.QtMultimedia import (QAudioInput, QCamera, QCameraDevice, @@ -16,8 +17,10 @@ from metadatadialog import MetaDataDialog from imagesettings import ImageSettings from videosettings import VideoSettings, is_android -if is_android: +if is_android or sys.platform == "darwin": from PySide6.QtCore import QMicrophonePermission, QCameraPermission + +if is_android: from ui_camera_mobile import Ui_Camera else: from ui_camera import Ui_Camera @@ -60,7 +63,14 @@ class Camera(QMainWindow): @Slot() def initialize(self): - if is_android: + if is_android or sys.platform == "darwin": + is_nuitka = "__compiled__" in globals() + if not is_nuitka and sys.platform == "darwin": + print("This example does not work on macOS when Python is run in interpreted mode." + "For this example to work on macOS, package the example using pyside6-deploy" + "For more information, read `Notes for Developer` in the documentation") + sys.exit(0) + # camera cam_permission = QCameraPermission() cam_permission_status = qApp.checkPermission(cam_permission) # noqa: F821 |