Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def main():
global app
app = qt.QApplication([])
# Create a ThreadSafePlot2D, set its limits and display it
plot2d = ThreadSafePlot2D()
plot2d.setLimits(0, Nx, 0, Ny)
plot2d.show()
# Create the thread that calls ThreadSafePlot2D.addImageThreadSafe
updateThread = UpdateThread(plot2d)
updateThread.start() # Start updating the plot
app.exec_()
updateThread.stop() # Stop updating the plot
def main():
app = qt.QApplication([])
with tempfile.TemporaryDirectory() as tempdir:
# Create temporary file with datasets
filename = os.path.join(tempdir, "file.h5")
with h5py.File(filename, "w") as f:
f['image'] = numpy.arange(10000.).reshape(100, 100)
f['curve'] = numpy.sin(numpy.linspace(0, 2*numpy.pi, 1000))
# Create widgets
example = DragAndDropExample(urls=(
silx.io.url.DataUrl(file_path=filename, data_path='/image', scheme="silx"),
silx.io.url.DataUrl(file_path=filename, data_path='/curve', scheme="silx")))
example.setWindowTitle("Drag&Drop URLs sample code")
example.show()
app.exec_()
else:
if not os.path.isfile(args.filename):
raise IOError('No input file: %s' % args.filename)
else:
edfFile = EdfFile(args.filename)
data = edfFile.GetData(0)
nbFrames = edfFile.GetNumImages()
if nbFrames == 0:
raise IOError(
'Cannot read image(s) from file: %s' % args.filename)
global app # QApplication must be global to avoid seg fault on quit
app = qt.QApplication([])
sys.excepthook = qt.exceptionHandler
mainWindow = ImageViewMainWindow()
mainWindow.setAttribute(qt.Qt.WA_DeleteOnClose)
if args.log: # Use log normalization by default
colormap = mainWindow.getDefaultColormap()
colormap.setNormalization(colormap.LOGARITHM)
mainWindow.setImage(data,
origin=args.origin,
scale=args.scale)
if edfFile is not None and nbFrames > 1:
# Add a toolbar for multi-frame EDF support
multiFrameToolbar = qt.QToolBar('Multi-frame')
def grabWindow(winID):
screen = qt.QApplication.primaryScreen()
return screen.grabWindow(winID)
def main():
global app
app = qt.QApplication([])
# Create the ad hoc window containing a PlotWidget and associated tools
window = MyPlotWindow()
window.setAttribute(qt.Qt.WA_DeleteOnClose)
window.show()
# Change the default colormap
plot = window.getPlotWidget()
plot.getDefaultColormap().setName('viridis')
# Add an image to the plot
x = numpy.outer(
numpy.linspace(-10, 10, 200), numpy.linspace(-10, 5, 150))
image = numpy.sin(x) / x
plot.addImage(image)
def __setError(self, error):
"""Set the error message in case of the current state of the stored
NXdata is not valid.
:param str error: Message to display
"""
self.__error = error
style = qt.QApplication.style()
if error is None:
message = ""
icon = style.standardIcon(qt.QStyle.SP_DirLinkIcon)
else:
message = error
icon = style.standardIcon(qt.QStyle.SP_MessageBoxCritical)
self.setIcon(icon)
self.setToolTip(message)
def main():
app = qt.QApplication([])
sys.excepthook = qt.exceptionHandler
window = FindContours()
window.generateIsland()
window.show()
result = app.exec_()
# remove ending warnings relative to QTimer
app.deleteLater()
return result
def main(argv=None):
"""Display few lines with markers.
"""
global app # QApplication must be global to avoid seg fault on quit
app = qt.QApplication([])
sys.excepthook = qt.exceptionHandler
mainWindow = Plot1D(backend="gl")
mainWindow.setAttribute(qt.Qt.WA_DeleteOnClose)
plot = mainWindow
plot.setDataMargins(0.1, 0.1, 0.1, 0.1)
plot.addCurve(x=[-10,0,0,-10,-10], y=[90,90,10,10,90], legend="box1", color="gray")
plot.addCurve(x=[110,100,100,110,110], y=[90,90,10,10,90], legend="box2", color="gray")
plot.addCurve(y=[-10,0,0,-10,-10], x=[90,90,10,10,90], legend="box3", color="gray")
plot.addCurve(y=[110,100,100,110,110], x=[90,90,10,10,90], legend="box4", color="gray")
def addLine(source, destination, symbolSource, symbolDestination, legend, color):
line = numpy.array([source, destination]).T
plot.addCurve(x=line[0,:], y=line[1,:], color=color, legend=legend)
plot.addMarker(x=source[0], y=source[1], symbol=symbolSource, color=color)
# Probe OpenGL availability and widget
isGLAvailable = False
try:
import OpenGL
except ImportError:
_logger.debug("pyopengl not installed")
else:
# sanity check from silx.gui._glutils.OpenGLWidget
if not hasattr(silx_qt, 'QOpenGLWidget') and\
(not silx_qt.HAS_OPENGL or
silx_qt.QApplication.instance() and not silx_qt.QGLFormat.hasOpenGL()):
_logger.debug("qt has a QOpenGLWidget: %s", hasattr(silx_qt, 'QOpenGLWidget'))
_logger.debug("qt.HAS_OPENGL: %s", silx_qt.HAS_OPENGL)
_logger.debug("silx_qt.QGLFormat.hasOpenGL(): %s",
silx_qt.QApplication.instance() and not silx_qt.QGLFormat.hasOpenGL())
else:
isGLAvailable = True
_logger.debug("GL availability: %s", isGLAvailable)
class AxesPositionersSelector(qt.QWidget):
sigSelectionChanged = qt.pyqtSignal(object, object)
def __init__(self, parent=None):
qt.QWidget.__init__(self, parent)
hlayout = qt.QHBoxLayout()
self.setLayout(hlayout)
xlabel = qt.QLabel("X:", parent=parent)