From befbab5571de834b729b06fdb143f7b7e05d7a87 Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Wed, 23 Mar 2016 17:04:22 +0800 Subject: [PATCH] gui: add image applet --- artiq/applets/image.py | 29 +++++++++++++++++++++++++++++ artiq/gui/applets.py | 2 ++ 2 files changed, 31 insertions(+) create mode 100755 artiq/applets/image.py diff --git a/artiq/applets/image.py b/artiq/applets/image.py new file mode 100755 index 000000000..86b8653e7 --- /dev/null +++ b/artiq/applets/image.py @@ -0,0 +1,29 @@ +#!/usr/bin/env python3.5 + +import numpy as np +import PyQt5 # make sure pyqtgraph imports Qt5 +import pyqtgraph + +from artiq.applets.simple import SimpleApplet + + +class Image(pyqtgraph.ImageView): + def __init__(self, args): + pyqtgraph.ImageView.__init__(self) + self.args = args + + def data_changed(self, data, mods): + try: + img = data[self.args.img][1] + except KeyError: + return + self.setImage(img) + + +def main(): + applet = SimpleApplet(Image) + applet.add_dataset("img", "image data (2D numpy array)") + applet.run() + +if __name__ == "__main__": + main() diff --git a/artiq/gui/applets.py b/artiq/gui/applets.py index f9c93d9f5..90b1f6c9a 100644 --- a/artiq/gui/applets.py +++ b/artiq/gui/applets.py @@ -185,6 +185,8 @@ _templates = [ "--embed {ipc_address} X_DATASET " "HIST_BIN_BOUNDARIES_DATASET " "HISTS_COUNTS_DATASET"), + ("Image", "{python} -m artiq.applets.image " + "--embed {ipc_address} IMG_DATASET"), ]