diff options
Diffstat (limited to 'examples/customSilxView.py')
-rw-r--r-- | examples/customSilxView.py | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/examples/customSilxView.py b/examples/customSilxView.py index c240280..57b94f7 100644 --- a/examples/customSilxView.py +++ b/examples/customSilxView.py @@ -1,5 +1,4 @@ #!/usr/bin/env python -# coding: utf-8 # /*########################################################################## # # Copyright (c) 2020 European Synchrotron Radiation Facility @@ -32,7 +31,7 @@ import numpy def createWindow(parent, settings): # Local import to avoid early import (like h5py) - # SOme libraries have to be configured first properly + # SOme libraries have to be configured first properly from silx.gui.plot.actions import PlotAction from silx.app.view.Viewer import Viewer from silx.app.view.ApplicationContext import ApplicationContext @@ -40,10 +39,14 @@ def createWindow(parent, settings): class RandomColorAction(PlotAction): def __init__(self, plot, parent=None): super(RandomColorAction, self).__init__( - plot, icon="colormap", text='Color', - tooltip='Random plot background color', + plot, + icon="colormap", + text="Color", + tooltip="Random plot background color", triggered=self.__randomColor, - checkable=False, parent=parent) + checkable=False, + parent=parent, + ) def __randomColor(self): color = "#%06X" % numpy.random.randint(0xFFFFFF) @@ -51,7 +54,7 @@ def createWindow(parent, settings): class MyApplicationContext(ApplicationContext): """This class is shared to all the silx view application.""" - + def findPrintToolBar(self, plot): # FIXME: It would be better to use the Qt API return plot._outputToolBar @@ -62,6 +65,7 @@ def createWindow(parent, settings): So we can custom it. """ from silx.gui.plot import Plot1D + if isinstance(widget, Plot1D): toolBar = self.findPrintToolBar(widget) action = RandomColorAction(widget, widget) @@ -78,11 +82,12 @@ def createWindow(parent, settings): def main(args): from silx.app.view import main as silx_view_main + # Monkey patch the main window creation silx_view_main.createWindow = createWindow # Use the default launcher silx_view_main.main(args) -if __name__ == '__main__': +if __name__ == "__main__": main(sys.argv) |