diff options
author | Picca Frédéric-Emmanuel <picca@synchrotron-soleil.fr> | 2019-05-28 08:16:16 +0200 |
---|---|---|
committer | Picca Frédéric-Emmanuel <picca@synchrotron-soleil.fr> | 2019-05-28 08:16:16 +0200 |
commit | a763e5d1b3921b3194f3d4e94ab9de3fbe08bbdd (patch) | |
tree | 45d462ed36a5522e9f3b9fde6c4ec4918c2ae8e3 /examples | |
parent | cebdc9244c019224846cb8d2668080fe386a6adc (diff) |
New upstream version 0.10.1+dfsg
Diffstat (limited to 'examples')
-rw-r--r-- | examples/compareImages.py | 110 | ||||
-rw-r--r-- | examples/customDataView.py | 4 | ||||
-rw-r--r-- | examples/dropZones.py | 134 | ||||
-rw-r--r-- | examples/fileDialog.py | 4 | ||||
-rwxr-xr-x | examples/hdf5widget.py | 40 | ||||
-rwxr-xr-x | examples/imageview.py | 5 | ||||
-rw-r--r-- | examples/plot3dSceneWindow.py | 3 | ||||
-rw-r--r-- | examples/plotInteractiveImageROI.py | 18 | ||||
-rw-r--r-- | examples/plotStats.py | 4 | ||||
-rwxr-xr-x | examples/printPreview.py | 24 | ||||
-rw-r--r-- | examples/syncPlotLocation.py | 105 | ||||
-rw-r--r-- | examples/viewer3DVolume.py | 10 |
12 files changed, 392 insertions, 69 deletions
diff --git a/examples/compareImages.py b/examples/compareImages.py index 94f68a0..623216a 100644 --- a/examples/compareImages.py +++ b/examples/compareImages.py @@ -30,19 +30,18 @@ import sys import logging import numpy import argparse +import os import silx.io from silx.gui import qt import silx.test.utils +from silx.io.url import DataUrl from silx.gui.plot.CompareImages import CompareImages +from silx.gui.widgets.UrlSelectionTable import UrlSelectionTable _logger = logging.getLogger(__name__) -try: - import fabio -except ImportError: - _logger.debug("Backtrace", exc_info=True) - fabio = None +import fabio try: import PIL @@ -51,6 +50,70 @@ except ImportError: PIL = None +class CompareImagesSelection(qt.QMainWindow): + def __init__(self, backend): + qt.QMainWindow.__init__(self, parent=None) + self._plot = CompareImages(parent=self, backend=backend) + + self._selectionTable = UrlSelectionTable(parent=self) + self._dockWidgetMenu = qt.QDockWidget(parent=self) + self._dockWidgetMenu.layout().setContentsMargins(0, 0, 0, 0) + self._dockWidgetMenu.setFeatures(qt.QDockWidget.DockWidgetMovable) + self._dockWidgetMenu.setWidget(self._selectionTable) + self.addDockWidget(qt.Qt.LeftDockWidgetArea, self._dockWidgetMenu) + + self.setCentralWidget(self._plot) + + self._selectionTable.sigImageAChanged.connect(self._updateImageA) + self._selectionTable.sigImageBChanged.connect(self._updateImageB) + + def setUrls(self, urls): + for url in urls: + self._selectionTable.addUrl(url) + + def setFiles(self, files): + urls = list() + for _file in files: + if os.path.isfile(_file): + urls.append(DataUrl(file_path=_file, scheme=None)) + urls.sort(key=lambda url: url.path()) + window.setUrls(urls) + window._selectionTable.setSelection(url_img_a=urls[0].path(), + url_img_b=urls[1].path()) + + def clear(self): + self._plot.clear() + self._selectionTable.clear() + + def _updateImageA(self, urlpath): + self._updateImage(urlpath, self._plot.setImage1) + + def _updateImage(self, urlpath, fctptr): + def getData(): + _url = silx.io.url.DataUrl(path=urlpath) + for scheme in ('silx', 'fabio'): + try: + dataImg = silx.io.utils.get_data( + silx.io.url.DataUrl(file_path=_url.file_path(), + data_slice=_url.data_slice(), + data_path=_url.data_path(), + scheme=scheme)) + except: + _logger.debug("Error while loading image with %s" % scheme, + exc_info=True) + else: + # TODO: check is an image + return dataImg + return None + + data = getData() + if data is not None: + fctptr(data) + + def _updateImageB(self, urlpath): + self._updateImage(urlpath, self._plot.setImage2) + + def createTestData(): data = numpy.arange(100 * 100) data = (data % 100) / 5.0 @@ -68,14 +131,10 @@ def loadImage(filename): except Exception: _logger.debug("Error while loading image with silx.io", exc_info=True) - if fabio is None and PIL is None: - raise ImportError("fabio nor PIL are available") - - if fabio is not None: - try: - return fabio.open(filename).data - except Exception: - _logger.debug("Error while loading image with fabio", exc_info=True) + try: + return fabio.open(filename).data + except Exception: + _logger.debug("Error while loading image with fabio", exc_info=True) if PIL is not None: try: @@ -128,22 +187,25 @@ if __name__ == "__main__": if options.debug: logging.root.setLevel(logging.DEBUG) - if options.testdata: - _logger.info("Generate test data") - data1, data2 = createTestData() - else: - if len(options.files) != 2: - raise Exception("Expected 2 images to compare them") - data1 = loadImage(options.files[0]) - data2 = loadImage(options.files[1]) - if options.use_opengl_plot: backend = "gl" else: backend = "mpl" app = qt.QApplication([]) - window = CompareImages(backend=backend) - window.setData(data1, data2) + if options.testdata or len(options.files) == 2: + if options.testdata: + _logger.info("Generate test data") + data1, data2 = createTestData() + else: + data1 = loadImage(options.files[0]) + data2 = loadImage(options.files[1]) + window = CompareImages(backend=backend) + window.setData(data1, data2) + else: + data = options.files + window = CompareImagesSelection(backend=backend) + window.setFiles(options.files) + window.setVisible(True) app.exec_() diff --git a/examples/customDataView.py b/examples/customDataView.py index 6db5c3e..33662e8 100644 --- a/examples/customDataView.py +++ b/examples/customDataView.py @@ -2,7 +2,7 @@ # coding: utf-8 # /*########################################################################## # -# Copyright (c) 2016-2017 European Synchrotron Radiation Facility +# Copyright (c) 2016-2018 European Synchrotron Radiation Facility # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal @@ -26,6 +26,7 @@ """Qt data view example """ +import enum import logging import sys @@ -36,7 +37,6 @@ _logger = logging.getLogger("customDataView") from silx.gui import qt from silx.gui.data.DataViewerFrame import DataViewerFrame from silx.gui.data.DataViews import DataView -from silx.third_party import enum class Color(enum.Enum): diff --git a/examples/dropZones.py b/examples/dropZones.py new file mode 100644 index 0000000..d0d16b5 --- /dev/null +++ b/examples/dropZones.py @@ -0,0 +1,134 @@ +#!/usr/bin/env python +# coding: utf-8 +# /*########################################################################## +# +# Copyright (c) 2016-2018 European Synchrotron Radiation Facility +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +# THE SOFTWARE. +# +# ###########################################################################*/ +""" +Example of drop zone supporting application/x-silx-uri +""" + +from __future__ import absolute_import + +__authors__ = ["V. Valls"] +__license__ = "MIT" +__date__ = "25/01/2019" + +import logging +import silx.io +from silx.gui import qt +from silx.gui.plot.PlotWidget import PlotWidget + +_logger = logging.getLogger(__name__) +logging.basicConfig(level=logging.DEBUG) + + +class DropPlotWidget(PlotWidget): + + def __init__(self, parent=None, backend=None): + PlotWidget.__init__(self, parent=parent, backend=backend) + self.setAcceptDrops(True) + + def dragEnterEvent(self, event): + if event.mimeData().hasFormat("application/x-silx-uri"): + event.acceptProposedAction() + + def dropEvent(self, event): + byteString = event.mimeData().data("application/x-silx-uri") + silxUrl = byteString.data().decode("utf-8") + with silx.io.open(silxUrl) as h5: + if silx.io.is_dataset(h5): + dataset = h5[...] + else: + _logger.error("Unsupported URI") + dataset = None + + if dataset is not None: + if dataset.ndim == 1: + self.clear() + self.addCurve(y=dataset, x=range(dataset.size)) + event.acceptProposedAction() + elif dataset.ndim == 2: + self.clear() + self.addImage(data=dataset) + event.acceptProposedAction() + else: + _logger.error("Unsupported dataset") + + +class DropLabel(qt.QLabel): + + def __init__(self, parent=None, backend=None): + qt.QLabel.__init__(self) + self.setAcceptDrops(True) + self.setText("Drop something here") + + def dragEnterEvent(self, event): + if event.mimeData().hasFormat("application/x-silx-uri"): + event.acceptProposedAction() + + def dropEvent(self, event): + byteString = event.mimeData().data("application/x-silx-uri") + silxUrl = byteString.data().decode("utf-8") + url = silx.io.url.DataUrl(silxUrl) + self.setText(url.path()) + + toolTipTemplate = ("<html><ul>" + "<li><b>file_path</b>: {file_path}</li>" + "<li><b>data_path</b>: {data_path}</li>" + "<li><b>data_slice</b>: {data_slice}</li>" + "<li><b>scheme</b>: {scheme}</li>" + "</html>" + "</ul></html>" + ) + + toolTip = toolTipTemplate.format( + file_path=url.file_path(), + data_path=url.data_path(), + data_slice=url.data_slice(), + scheme=url.scheme()) + + self.setToolTip(toolTip) + event.acceptProposedAction() + + +class DropExample(qt.QMainWindow): + + def __init__(self, parent=None): + super(DropExample, self).__init__(parent) + centralWidget = qt.QWidget(self) + layout = qt.QVBoxLayout() + centralWidget.setLayout(layout) + layout.addWidget(DropPlotWidget(parent=self)) + layout.addWidget(DropLabel(parent=self)) + self.setCentralWidget(centralWidget) + + +def main(): + app = qt.QApplication([]) + example = DropExample() + example.show() + app.exec_() + + +if __name__ == "__main__": + main() diff --git a/examples/fileDialog.py b/examples/fileDialog.py index 9730b9a..82e6798 100644 --- a/examples/fileDialog.py +++ b/examples/fileDialog.py @@ -2,7 +2,7 @@ # coding: utf-8 # /*########################################################################## # -# Copyright (c) 2016 European Synchrotron Radiation Facility +# Copyright (c) 2016-2018 European Synchrotron Radiation Facility # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal @@ -33,12 +33,12 @@ __authors__ = ["V. Valls"] __license__ = "MIT" __date__ = "14/02/2018" +import enum import logging from silx.gui import qt from silx.gui.dialog.ImageFileDialog import ImageFileDialog from silx.gui.dialog.DataFileDialog import DataFileDialog import silx.io -from silx.third_party import enum logging.basicConfig(level=logging.DEBUG) diff --git a/examples/hdf5widget.py b/examples/hdf5widget.py index bf92d4e..c344bec 100755 --- a/examples/hdf5widget.py +++ b/examples/hdf5widget.py @@ -33,7 +33,9 @@ import logging import sys import tempfile + import numpy +import six logging.basicConfig() _logger = logging.getLogger("hdf5widget") @@ -50,15 +52,12 @@ import h5py import silx.gui.hdf5 import silx.utils.html -from silx.third_party import six from silx.gui import qt from silx.gui.data.DataViewerFrame import DataViewerFrame from silx.gui.widgets.ThreadPoolPushButton import ThreadPoolPushButton -try: - import fabio -except ImportError: - fabio = None +import fabio + _file_cache = {} @@ -713,26 +712,25 @@ class Hdf5TreeViewExample(qt.QMainWindow): content.layout().addStretch(1) - if fabio is not None: - content = qt.QGroupBox("Create EDF", panel) - content.setLayout(qt.QVBoxLayout()) - panel.layout().addWidget(content) + content = qt.QGroupBox("Create EDF", panel) + content.setLayout(qt.QVBoxLayout()) + panel.layout().addWidget(content) - combo = qt.QComboBox() - combo.addItem("Containing all types", get_edf_with_all_types) - combo.addItem("Containing 100000 datasets", get_edf_with_100000_frames) - combo.activated.connect(self.__edfComboChanged) - content.layout().addWidget(combo) + combo = qt.QComboBox() + combo.addItem("Containing all types", get_edf_with_all_types) + combo.addItem("Containing 100000 datasets", get_edf_with_100000_frames) + combo.activated.connect(self.__edfComboChanged) + content.layout().addWidget(combo) - button = ThreadPoolPushButton(content, text="Create") - button.setCallable(combo.itemData(combo.currentIndex())) - button.succeeded.connect(self.__fileCreated) - content.layout().addWidget(button) + button = ThreadPoolPushButton(content, text="Create") + button.setCallable(combo.itemData(combo.currentIndex())) + button.succeeded.connect(self.__fileCreated) + content.layout().addWidget(button) - self.__edfCombo = combo - self.__createEdfButton = button + self.__edfCombo = combo + self.__createEdfButton = button - content.layout().addStretch(1) + content.layout().addStretch(1) option = qt.QGroupBox("Tree options", panel) option.setLayout(qt.QVBoxLayout()) diff --git a/examples/imageview.py b/examples/imageview.py index 37d1857..71bde70 100755 --- a/examples/imageview.py +++ b/examples/imageview.py @@ -42,7 +42,7 @@ from __future__ import division __authors__ = ["T. Vincent"] __license__ = "MIT" -__date__ = "18/10/2016" +__date__ = "08/11/2018" import logging from silx.gui.plot.ImageView import ImageViewMainWindow @@ -118,8 +118,7 @@ def main(argv=None): if args.log: # Use log normalization by default colormap = mainWindow.getDefaultColormap() - colormap['normalization'] = 'log' - mainWindow.setColormap(colormap) + colormap.setNormalization(colormap.LOGARITHM) mainWindow.setImage(data, origin=args.origin, diff --git a/examples/plot3dSceneWindow.py b/examples/plot3dSceneWindow.py index cf6f209..5e78aa6 100644 --- a/examples/plot3dSceneWindow.py +++ b/examples/plot3dSceneWindow.py @@ -57,7 +57,7 @@ from silx.gui.widgets.BoxLayoutDockWidget import BoxLayoutDockWidget SIZE = 1024 # Create QApplication -qapp = qt.QApplication([]) +qapp = qt.QApplication.instance() or qt.QApplication([]) # Create a SceneWindow widget window = SceneWindow() @@ -83,6 +83,7 @@ window.addDockWidget(qt.Qt.BottomDockWidgetArea, dock) img = numpy.random.random(3 * SIZE ** 2).reshape(SIZE, SIZE, 3) # Dummy image imageRgba = sceneWidget.addImage(img) # Add ImageRgba item to the scene +imageRgba.setLabel('Random RGBA image') # Set name displayed in parameter tree # Set imageRgba transform imageRgba.setTranslation(SIZE*.15, SIZE*.15, 0.) # Translate the image diff --git a/examples/plotInteractiveImageROI.py b/examples/plotInteractiveImageROI.py index d45bdf5..e06db89 100644 --- a/examples/plotInteractiveImageROI.py +++ b/examples/plotInteractiveImageROI.py @@ -39,14 +39,14 @@ from silx.gui.plot import Plot2D from silx.gui.plot.tools.roi import RegionOfInterestManager from silx.gui.plot.tools.roi import RegionOfInterestTableWidget from silx.gui.plot.items.roi import RectangleROI +from silx.gui.plot.items import LineMixIn, SymbolMixIn def dummy_image(): """Create a dummy image""" x = numpy.linspace(-1.5, 1.5, 1024) xv, yv = numpy.meshgrid(x, x) - signal = numpy.exp(- (xv ** 2 / 0.15 ** 2 - + yv ** 2 / 0.25 ** 2)) + signal = numpy.exp(- (xv ** 2 / 0.15 ** 2 + yv ** 2 / 0.25 ** 2)) # add noise signal += 0.3 * numpy.random.random(size=signal.shape) return signal @@ -54,8 +54,12 @@ def dummy_image(): app = qt.QApplication([]) # Start QApplication +backend = "matplotlib" +if "--opengl" in sys.argv: + backend = "opengl" + # Create the plot widget and add an image -plot = Plot2D() +plot = Plot2D(backend=backend) plot.getDefaultColormap().setName('viridis') plot.addImage(dummy_image()) @@ -69,6 +73,12 @@ def updateAddedRegionOfInterest(roi): """Called for each added region of interest: set the name""" if roi.getLabel() == '': roi.setLabel('ROI %d' % len(roiManager.getRois())) + if isinstance(roi, LineMixIn): + roi.setLineWidth(2) + roi.setLineStyle('--') + if isinstance(roi, SymbolMixIn): + roi.setSymbol('o') + roi.setSymbolSize(5) roiManager.sigRoiAdded.connect(updateAddedRegionOfInterest) @@ -99,6 +109,7 @@ widget.setLayout(layout) layout.addWidget(roiToolbar) layout.addWidget(roiTable) + def roiDockVisibilityChanged(visible): """Handle change of visibility of the roi dock widget @@ -107,6 +118,7 @@ def roiDockVisibilityChanged(visible): if not visible: roiManager.stop() + dock = qt.QDockWidget('Image ROI') dock.setWidget(widget) dock.visibilityChanged.connect(roiDockVisibilityChanged) diff --git a/examples/plotStats.py b/examples/plotStats.py index fff7585..f7474ec 100644 --- a/examples/plotStats.py +++ b/examples/plotStats.py @@ -2,7 +2,7 @@ # coding: utf-8 # /*########################################################################## # -# Copyright (c) 2016-2018 European Synchrotron Radiation Facility +# Copyright (c) 2016-2019 European Synchrotron Radiation Facility # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal @@ -43,6 +43,7 @@ __date__ = "24/07/2018" from silx.gui import qt +from silx.gui.colors import Colormap from silx.gui.plot import Plot1D from silx.gui.plot.stats.stats import StatBase import numpy @@ -102,6 +103,7 @@ def main(): plot.addScatter(x=[0, 2, 5, 5, 12, 20], y=[2, 3, 4, 20, 15, 6], value=[5, 6, 7, 10, 90, 20], + colormap=Colormap('viridis'), legend='myScatter') stats = [ diff --git a/examples/printPreview.py b/examples/printPreview.py index 7567adb..6de8209 100755 --- a/examples/printPreview.py +++ b/examples/printPreview.py @@ -42,22 +42,38 @@ from silx.gui import qt from silx.gui.plot import PlotWidget from silx.gui.plot import PrintPreviewToolButton + +class MyPrintPreviewButton(PrintPreviewToolButton.PrintPreviewToolButton): + """This class illustrates how to subclass PrintPreviewToolButton + to add a title and a comment.""" + def getTitle(self): + return "Widget 1's plot" + + def getCommentAndPosition(self): + legends = self.getPlot().getAllCurves(just_legend=True) + comment = "Curves displayed in widget 1:\n\t" + if legends: + comment += ", ".join(legends) + else: + comment += "none" + return comment, "CENTER" + + app = qt.QApplication([]) x = numpy.arange(1000) -# first widget has a standalone print preview action +# first widget has a standalone preview action with custom title and comment pw1 = PlotWidget() pw1.setWindowTitle("Widget 1 with standalone print preview") toolbar1 = qt.QToolBar(pw1) -toolbutton1 = PrintPreviewToolButton.PrintPreviewToolButton(parent=toolbar1, - plot=pw1) +toolbutton1 = MyPrintPreviewButton(parent=toolbar1, plot=pw1) pw1.addToolBar(toolbar1) toolbar1.addWidget(toolbutton1) pw1.show() pw1.addCurve(x, numpy.tan(x * 2 * numpy.pi / 1000)) -# next two plots share a common print preview +# next two plots share a common standard print preview pw2 = PlotWidget() pw2.setWindowTitle("Widget 2 with shared print preview") toolbar2 = qt.QToolBar(pw2) diff --git a/examples/syncPlotLocation.py b/examples/syncPlotLocation.py new file mode 100644 index 0000000..55332bc --- /dev/null +++ b/examples/syncPlotLocation.py @@ -0,0 +1,105 @@ +#!/usr/bin/env python +# coding: utf-8 +# /*########################################################################## +# +# Copyright (c) 2016-2017 European Synchrotron Radiation Facility +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +# THE SOFTWARE. +# +# ###########################################################################*/ +"""This script is an example to illustrate how to use axis synchronization +tool. +""" + +from silx.gui import qt +from silx.gui.plot import Plot2D +import numpy +import silx.test.utils +from silx.gui.plot.utils.axis import SyncAxes +from silx.gui.colors import Colormap + + +class SyncPlot(qt.QMainWindow): + + def __init__(self): + qt.QMainWindow.__init__(self) + self.setWindowTitle("Plot with synchronized axes") + widget = qt.QWidget(self) + self.setCentralWidget(widget) + + layout = qt.QGridLayout() + widget.setLayout(layout) + + backend = "gl" + plots = [] + + data = numpy.arange(100 * 100) + data = (data % 100) / 5.0 + data = numpy.sin(data) + data.shape = 100, 100 + + colormaps = ["gray", "red", "green", "blue"] + for i in range(2 * 2): + plot = Plot2D(parent=widget, backend=backend) + plot.setInteractiveMode('pan') + plot.setDefaultColormap(Colormap(colormaps[i])) + noisyData = silx.test.utils.add_gaussian_noise(data, mean=i / 10.0) + plot.addImage(noisyData) + plots.append(plot) + + xAxis = [p.getXAxis() for p in plots] + yAxis = [p.getYAxis() for p in plots] + + self.constraint1 = SyncAxes(xAxis, + syncLimits=False, + syncScale=True, + syncDirection=True, + syncCenter=True, + syncZoom=True) + self.constraint2 = SyncAxes(yAxis, + syncLimits=False, + syncScale=True, + syncDirection=True, + syncCenter=True, + syncZoom=True) + + for i, plot in enumerate(plots): + if i % 2 == 0: + plot.setFixedWidth(400) + else: + plot.setFixedWidth(500) + if i // 2 == 0: + plot.setFixedHeight(400) + else: + plot.setFixedHeight(500) + layout.addWidget(plot, i // 2, i % 2) + + def createCenteredLabel(self, text): + label = qt.QLabel(self) + label.setAlignment(qt.Qt.AlignCenter) + label.setText(text) + return label + + +if __name__ == "__main__": + app = qt.QApplication([]) + window = SyncPlot() + window.setAttribute(qt.Qt.WA_DeleteOnClose, True) + window.setVisible(True) + app.exec_() diff --git a/examples/viewer3DVolume.py b/examples/viewer3DVolume.py index d030fba..4de04f6 100644 --- a/examples/viewer3DVolume.py +++ b/examples/viewer3DVolume.py @@ -52,13 +52,7 @@ logging.basicConfig() _logger = logging.getLogger(__name__) - -try: - import h5py -except ImportError: - _logger.warning('h5py is not installed: HDF5 not supported') - h5py = None - +import h5py def load(filename): """Load 3D scalar field from file. @@ -72,7 +66,7 @@ def load(filename): if not os.path.isfile(filename.split('::')[0]): raise IOError('No input file: %s' % filename) - if h5py is not None and h5py.is_hdf5(filename.split('::')[0]): + if h5py.is_hdf5(filename.split('::')[0]): if '::' not in filename: raise ValueError( 'HDF5 path not provided: Use <filename>::<path> format') |