From b45386ebc5ce9d14bd3c63b0ce9abbbbf5985255 Mon Sep 17 00:00:00 2001 From: Ogi Moore Date: Thu, 11 Feb 2021 21:55:04 -0800 Subject: [PATCH] Have __init__.plot() use PlotWidget, not deprecated PlotWindow --- pyqtgraph/__init__.py | 43 +++++-------------- .../graphicsItems/tests/test_ImageItem.py | 4 +- 2 files changed, 12 insertions(+), 35 deletions(-) diff --git a/pyqtgraph/__init__.py b/pyqtgraph/__init__.py index 6dac9a0e..1468bbdd 100644 --- a/pyqtgraph/__init__.py +++ b/pyqtgraph/__init__.py @@ -384,29 +384,18 @@ def exit(): os._exit(0) - ## Convenience functions for command-line use - plots = [] images = [] QAPP = None def plot(*args, **kargs): """ - Create and return a :class:`PlotWindow ` - (this is just a window with :class:`PlotWidget ` inside), plot data in it. + Create and return a :class:`PlotWidget ` Accepts a *title* argument to set the title of the window. All other arguments are used to plot data. (see :func:`PlotItem.plot() `) """ - mkQApp() - #if 'title' in kargs: - #w = PlotWindow(title=kargs['title']) - #del kargs['title'] - #else: - #w = PlotWindow() - #if len(args)+len(kargs) > 0: - #w.plot(*args, **kargs) - + mkQApp() pwArgList = ['title', 'labels', 'name', 'left', 'right', 'top', 'bottom', 'background'] pwArgs = {} dataArgs = {} @@ -415,44 +404,32 @@ def plot(*args, **kargs): pwArgs[k] = kargs[k] else: dataArgs[k] = kargs[k] - - w = PlotWindow(**pwArgs) - w.sigClosed.connect(_plotWindowClosed) + windowTitle = pwArgs.pop("title", "PlotWidget") + w = PlotWidget(**pwArgs) + w.setWindowTitle(windowTitle) if len(args) > 0 or len(dataArgs) > 0: w.plot(*args, **dataArgs) plots.append(w) w.show() return w -def _plotWindowClosed(w): - w.close() - try: - plots.remove(w) - except ValueError: - pass - def image(*args, **kargs): """ - Create and return an :class:`ImageWindow ` - (this is just a window with :class:`ImageView ` widget inside), show image data inside. + Create and return an :class:`ImageView ` Will show 2D or 3D image data. Accepts a *title* argument to set the title of the window. All other arguments are used to show data. (see :func:`ImageView.setImage() `) """ mkQApp() - w = ImageWindow(*args, **kargs) - w.sigClosed.connect(_imageWindowClosed) + w = ImageView() + windowTitle = kargs.pop("title", "ImageView") + w.setWindowTitle(windowTitle) + w.setImage(*args, **kargs) images.append(w) w.show() return w show = image ## for backward compatibility -def _imageWindowClosed(w): - w.close() - try: - images.remove(w) - except ValueError: - pass def dbg(*args, **kwds): """ diff --git a/pyqtgraph/graphicsItems/tests/test_ImageItem.py b/pyqtgraph/graphicsItems/tests/test_ImageItem.py index 40b1c6b6..a9239e2a 100644 --- a/pyqtgraph/graphicsItems/tests/test_ImageItem.py +++ b/pyqtgraph/graphicsItems/tests/test_ImageItem.py @@ -10,11 +10,11 @@ app = pg.mkQApp() def test_ImageItem(transpose=False): - w = pg.GraphicsWindow() + w = pg.GraphicsLayoutWidget() + w.show() view = pg.ViewBox() w.setCentralWidget(view) w.resize(200, 200) - w.show() img = TransposedImageItem(border=0.5, transpose=transpose) view.addItem(img)