2010-03-22 05:48:52 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
"""
|
|
|
|
graphicsWindows.py - Convenience classes which create a new window with PlotWidget or ImageView.
|
|
|
|
Copyright 2010 Luke Campagnola
|
|
|
|
Distributed under MIT/X11 license. See license.txt for more infomation.
|
|
|
|
"""
|
|
|
|
|
|
|
|
from PyQt4 import QtCore, QtGui
|
|
|
|
from PlotWidget import *
|
|
|
|
from ImageView import *
|
2010-07-24 18:29:09 +00:00
|
|
|
QAPP = None
|
2010-03-22 05:48:52 +00:00
|
|
|
class PlotWindow(QtGui.QMainWindow):
|
|
|
|
def __init__(self, title=None):
|
2010-07-24 18:29:09 +00:00
|
|
|
if QtGui.QApplication.instance() is None:
|
|
|
|
global QAPP
|
|
|
|
QAPP = QtGui.QApplication([])
|
2010-03-22 05:48:52 +00:00
|
|
|
QtGui.QMainWindow.__init__(self)
|
|
|
|
self.cw = PlotWidget()
|
|
|
|
self.setCentralWidget(self.cw)
|
2010-07-24 18:29:09 +00:00
|
|
|
for m in ['plot', 'autoRange', 'addItem', 'removeItem', 'setLabel', 'clear']:
|
2010-03-22 05:48:52 +00:00
|
|
|
setattr(self, m, getattr(self.cw, m))
|
|
|
|
if title is not None:
|
|
|
|
self.setWindowTitle(title)
|
|
|
|
self.show()
|
|
|
|
|
|
|
|
class ImageWindow(QtGui.QMainWindow):
|
|
|
|
def __init__(self, title=None):
|
2010-07-24 18:29:09 +00:00
|
|
|
if QtGui.QApplication.instance() is None:
|
|
|
|
global QAPP
|
|
|
|
QAPP = QtGui.QApplication([])
|
2010-03-22 05:48:52 +00:00
|
|
|
QtGui.QMainWindow.__init__(self)
|
|
|
|
self.cw = ImageView()
|
|
|
|
self.setCentralWidget(self.cw)
|
2010-07-24 18:29:09 +00:00
|
|
|
for m in ['setImage', 'autoRange', 'addItem', 'removeItem', 'blackLevel', 'whiteLevel', 'imageItem']:
|
2010-03-22 05:48:52 +00:00
|
|
|
setattr(self, m, getattr(self.cw, m))
|
|
|
|
if title is not None:
|
|
|
|
self.setWindowTitle(title)
|
|
|
|
self.show()
|