From 1698442aa8e3aed1fe0b2323dada6d5e1f2515a3 Mon Sep 17 00:00:00 2001 From: Tomi Valkeinen Date: Fri, 27 May 2022 17:44:30 +0300 Subject: py: Re-structure the controls API Add ControlInfo class and change the controls related methods to resemble the C++ API (e.g. no more string based control methods). We don't implement ControlList or ControlInfoMap but just expose the same data via standard Python dict. Signed-off-by: Tomi Valkeinen Reviewed-by: Laurent Pinchart Signed-off-by: Laurent Pinchart --- src/py/cam/cam.py | 8 ++++---- src/py/cam/cam_qt.py | 9 +++++---- 2 files changed, 9 insertions(+), 8 deletions(-) (limited to 'src/py/cam') diff --git a/src/py/cam/cam.py b/src/py/cam/cam.py index c8ffb084..677dd680 100755 --- a/src/py/cam/cam.py +++ b/src/py/cam/cam.py @@ -46,14 +46,14 @@ class CameraContext: def do_cmd_list_props(self): print('Properties for', self.id) - for name, prop in self.camera.properties.items(): - print('\t{}: {}'.format(name, prop)) + for cid, val in self.camera.properties.items(): + print('\t{}: {}'.format(cid, val)) def do_cmd_list_controls(self): print('Controls for', self.id) - for name, prop in self.camera.controls.items(): - print('\t{}: {}'.format(name, prop)) + for cid, info in self.camera.controls.items(): + print('\t{}: {}'.format(cid, info)) def do_cmd_info(self): print('Stream info for', self.id) diff --git a/src/py/cam/cam_qt.py b/src/py/cam/cam_qt.py index d638e9cc..e2395c4b 100644 --- a/src/py/cam/cam_qt.py +++ b/src/py/cam/cam_qt.py @@ -267,9 +267,9 @@ class MainWindow(QtWidgets.QWidget): camera = ctx.camera - for k, v in camera.properties.items(): + for cid, cv in camera.properties.items(): lab = QtWidgets.QLabel() - lab.setText(k + ' = ' + str(v)) + lab.setText('{} = {}'.format(cid, cv)) groupLayout.addWidget(lab) group = QtWidgets.QGroupBox('Controls') @@ -277,9 +277,10 @@ class MainWindow(QtWidgets.QWidget): group.setLayout(groupLayout) controlsLayout.addWidget(group) - for k, (min, max, default) in camera.controls.items(): + for cid, cinfo in camera.controls.items(): lab = QtWidgets.QLabel() - lab.setText('{} = {}/{}/{}'.format(k, min, max, default)) + lab.setText('{} = {}/{}/{}' + .format(cid, cinfo.min, cinfo.max, cinfo.default)) groupLayout.addWidget(lab) controlsLayout.addStretch() -- cgit v1.2.1