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 | 7287b75301a53bae723579b145448d43304272af (patch) | |
tree | df6d1a4595f3352a8c90ce9cba0e71ea0269e98b /examples/printPreview.py | |
parent | 3e5dcad207c1eadeb74fb53f524c3a94fbe19096 (diff) | |
parent | a763e5d1b3921b3194f3d4e94ab9de3fbe08bbdd (diff) |
Update upstream source from tag 'upstream/0.10.1+dfsg'
Update to upstream version '0.10.1+dfsg'
with Debian dir 6b2d4eeabb68177b2b91df4d7527306d5e19409d
Diffstat (limited to 'examples/printPreview.py')
-rwxr-xr-x | examples/printPreview.py | 24 |
1 files changed, 20 insertions, 4 deletions
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) |