def algorithm_screenshot(name, directory, version = -1, ext = ".png"): """ Takes a snapshot of an algorithm dialog and saves it as an image named "name_dlg.png" Args: name (str): The name of the algorithm directory (str): An directory path where the image should be saved version (str): A version of the algorithm to use (default=latest) ext (str): An optional extension (including the period). Default=.png Returns: str: A full path to the image file """ import mantid if not mantid.__gui__: raise RuntimeError("MantidPlot not available. Cannot take screenshot") import mantidqtpython as mantidqt from mantidplot import threadsafe_call iface_mgr = mantidqt.MantidQt.API.InterfaceManager() # threadsafe_call required for MantidPlot dlg = threadsafe_call(iface_mgr.createDialogFromName, name, version, None, True) suffix = ("-v%d" % version) if version != -1 else "" filename = "%s%s_dlg%s" % (name, suffix, ext) picture = Screenshot(dlg, filename, directory) threadsafe_call(dlg.close) return picture
def algorithm_screenshot(name, directory, version=-1, ext=".png"): """ Takes a snapshot of an algorithm dialog and saves it as an image named "name_dlg.png" Args: name (str): The name of the algorithm directory (str): An directory path where the image should be saved version (str): A version of the algorithm to use (default=latest) ext (str): An optional extension (including the period). Default=.png Returns: str: A full path to the image file """ import mantid if not mantid.__gui__: raise RuntimeError("MantidPlot not available. Cannot take screenshot") import mantidqtpython as mantidqt from mantidplot import threadsafe_call iface_mgr = mantidqt.MantidQt.API.InterfaceManager() # threadsafe_call required for MantidPlot dlg = threadsafe_call(iface_mgr.createDialogFromName, name, version, None, True) suffix = ("-v%d" % version) if version != -1 else "" filename = "%s%s_dlg%s" % (name, suffix, ext) picture = Screenshot(dlg, filename, directory) threadsafe_call(dlg.close) return picture
def custominterface_screenshot(name, directory, ext = ".png", widget_name = None): """ Takes a snapshot of a custom interface and saves it as an image named "name.png" Args: name (str): The name of the custom interface directory (str): An directory path where the image should be saved ext (str): An optional extension (including the period). Default=.png Returns: str: A full path to the image file """ import mantid if not mantid.__gui__: raise RuntimeError("MantidPlot not available. Cannot take screenshot") import mantidqtpython as mantidqt from mantidplot import threadsafe_call from PyQt4.QtGui import QWidget iface_mgr = mantidqt.MantidQt.API.InterfaceManager() # threadsafe_call required for MantidPlot dlg = threadsafe_call(iface_mgr.createSubWindow, name, None) if widget_name: widget = dlg.findChild(QWidget, widget_name) picture = Screenshot(widget, name.replace(' ','_') + "_" + widget_name + "_widget" + ext, directory) else: picture = Screenshot(dlg, name.replace(' ','_') + "_interface" + ext, directory) threadsafe_call(dlg.close) return picture
def LoadData(self,ws,label): print "b" print "label: ",label print "ws: ",ws," type(ws): ",type(ws) self.svw = threadsafe_call(mantidqtpython.MantidQt.Factory.WidgetFactory.Instance().createSliceViewerWindow, ws, label) print "b2"
def custominterface_screenshot(name, directory, ext=".png", widget_name=None): """ Takes a snapshot of a custom interface and saves it as an image named "name.png" Args: name (str): The name of the custom interface directory (str): An directory path where the image should be saved ext (str): An optional extension (including the period). Default=.png Returns: str: A full path to the image file """ import mantid if not mantid.__gui__: raise RuntimeError("MantidPlot not available. Cannot take screenshot") import mantidqtpython as mantidqt from mantidplot import threadsafe_call from PyQt4.QtGui import QWidget iface_mgr = mantidqt.MantidQt.API.InterfaceManager() # threadsafe_call required for MantidPlot dlg = threadsafe_call(iface_mgr.createSubWindow, name, None) if dlg is None: raise RuntimeError("Interface '%s' could not be created" % name) if widget_name: widget = dlg.findChild(QWidget, widget_name) if widget is None: raise RuntimeError("Widget '%s' does not exist in interface '%s'" % (widget_name, name)) picture = Screenshot( widget, name.replace(' ', '_') + "_" + widget_name + "_widget" + ext, directory) else: picture = Screenshot(dlg, name.replace(' ', '_') + "_interface" + ext, directory) threadsafe_call(dlg.close) return picture
def Show(self): print "c" wsNames=mtd.getObjectNames() print "WS Before SliceViewer: ",wsNames threadsafe_call(self.svw.show)
def SetParams(self,xydim,slicepoint,colormin,colormax,colorscalelog,limits, normalization): print "b3" # --- X/Y Dimensions --- if (not xydim is None): if len(xydim) != 2: raise Exception("You need to specify two values in the 'xydim' parameter") else: threadsafe_call(sv.setXYDim, xydim[0], xydim[1]) # --- Slice point --- if not slicepoint is None: for d in xrange(len(slicepoint)): try: val = float(slicepoint[d]) except ValueError: raise ValueError("Could not convert item %d of slicepoint parameter to float (got '%s'" % (d, slicepoint[d])) sv.setSlicePoint(d, val) # Set the normalization before the color scale print "b4" sv=threadsafe_call(self.svw.getSlicer) threadsafe_call(sv.setNormalization, normalization) print "b5" # --- Color scale --- if (not colormin is None) and (not colormax is None): threadsafe_call(sv.setColorScale, colormin, colormax, colorscalelog) else: if (not colormin is None): threadsafe_call(sv.setColorScaleMin, colormin) if (not colormax is None): threadsafe_call(sv.setColorScaleMax, colormax) print "b6" try: print "b7" threadsafe_call(sv.setColorScaleLog, colorscalelog) print "b8" except: print "Log color scale not possible." # --- XY limits --- if not limits is None: threadsafe_call(sv.setXYLimits, limits[0], limits[1], limits[2], limits[3]) print "b9"