{ "cells": [ { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "%matplotlib inline" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Parameter editor widget\n\nThis example shows the usage of the generic ParamEditorWidget.\n\nThe widget can be used in various ways. Some of them are shwon in\nthis example.\n\nIn the first tab, we have a DummyGrabber live image with two\nParamEditorWidgets on the right side. The left one is a default one\nwith an information text field below. If a parameter is clicked, its\ndescription is shown there. The right one is configured such that\nchanges are not directly applied to the camera. Instead the Apply button\nmust be clicked to apply all recent changes.\n\nIn the second tab, we have a DummyMotor with 3 axes. There is one\nread-only ParamEditorWidget and one standard one, that only shows\na subset of parameters (depending on their category). The category\nof a parameter is an optional meta information and is part of the \nplugin.\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "from itom import dataIO\nfrom itom import actuator\nfrom itom import ui\n\n\ncam = dataIO(\"DummyGrabber\", 1280, 1024, 8)\ncam.setParam(\"frame_time\", 0.100) # limit to 10 Hz\nmot = actuator(\"DummyMotor\", 3)\n\ngui = ui(\"paramEditorWidget.ui\", ui.TYPEWINDOW)\n\n\ndef onApply():\n \"\"\"Call 'setParam' of the DummyGrabber device\n for all changed parameters in the right\n ParamEditorWidget of the camera tab.\"\"\"\n gui.pewGrabber2.call(\"applyChangedParameters\")\n\n\n# configure the DummyGrabber camera tab\ngui.plot[\"camera\"] = cam # assign the camera to the plot\ngui.pewGrabber[\n \"plugin\"\n] = cam # assign the camera to the left ParamEditorWidget\n\n# if a parameter is changed in this ParamEditorWidget, directly call\n# setParam of the camera\ngui.pewGrabber[\"immediatelyModifyPluginParamsAfterChange\"] = True\n\ngui.pewGrabber2[\n \"plugin\"\n] = cam # assign the camera to the right ParamEditorWidget\n\n# do not directly change the parameters in the camera, instead click\n# the Apply button...\ngui.pewGrabber2[\"immediatelyModifyPluginParamsAfterChange\"] = False\n\n# connect the click signal of the Apply button to the method ``onApply``.\ngui.btnApplyChangesGrabber.connect(\"clicked()\", onApply)\n\n# configure the DummyMotor tab\ngui.motorController[\"actuator\"] = mot\ngui.pewMotor1[\"plugin\"] = mot\n\n# do only show parameters that belong to these two categories\ngui.pewMotor1[\"filteredCategories\"] = (\"General\", \"Motion\")\n\n# make the left ParamEditorWidget readonly\ngui.pewMotor1[\"readonly\"] = True\n\ngui.pewMotor2[\"plugin\"] = mot\n\ngui.show()" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.8.10" } }, "nbformat": 4, "nbformat_minor": 0 }