def test_server_resync(self): from pizco import Server app = QApplication([]) srv = RemotePizcoEmitterResync() pizco_srv = Server(srv,rep_endpoint="tcp://127.0.0.1:1211") from threading import Thread import numpy as np from guiqwt.plot import ImageWidget from guiqwt.builder import make import time im = ImageWidget() im.register_all_curve_tools() ts = TestSync() def test_thread(): ts.initialize_subobject(im) srv.std_signal.connect(ts.receiver_int) v_int = 0 while True: v_int += 1 srv.emission() time.sleep(0.5) if v_int==5: break im.close() t = Thread(None,test_thread) t.start() im.show() app.exec_() pizco_srv.stop() assert(ts._internal_value != 0)
def test_guiqwt_case_altthread(self): app = QApplication([]) from threading import Thread import numpy as np from guiqwt.plot import ImageWidget from guiqwt.builder import make import time im = ImageWidget() im.register_all_curve_tools() ts = TestSync() def test_thread(): ts.initialize_subobject(im) std_signal = SignalResync.Auto(intermediate_thread=True) std_signal.connect(ts.receiver_int) v_int = 0 while True: v_int += 1 std_signal.emit(v_int) time.sleep(0.5) if v_int==5: break im.close() t = Thread(None,test_thread) t.start() im.show() app.exec_() assert(ts._internal_value != 0)
def __init__(self, parent, toolbar): QSplitter.__init__(self, parent) self.setContentsMargins(10, 10, 10, 10) self.setOrientation(Qt.Vertical) imagelistwithproperties = ImageListWithProperties(self) self.addWidget(imagelistwithproperties) self.imagelist = imagelistwithproperties.imagelist self.connect(self.imagelist, SIGNAL("currentRowChanged(int)"), self.current_item_changed) self.connect(self.imagelist, SIGNAL("itemSelectionChanged()"), self.selection_changed) self.properties = imagelistwithproperties.properties self.connect(self.properties, SIGNAL("apply_button_clicked()"), self.properties_changed) self.imagewidget = ImageWidget(self) self.connect(self.imagewidget.plot, SIG_LUT_CHANGED, self.lut_range_changed) self.item = None # image item self.imagewidget.add_toolbar(toolbar, "default") self.imagewidget.register_all_image_tools() self.addWidget(self.imagewidget) self.images = [] # List of ImageParam instances self.lut_ranges = [] # List of LUT ranges self.setStretchFactor(0, 0) self.setStretchFactor(1, 1) self.setHandleWidth(10) self.setSizes([1, 2])
def test_proxy_resync(self): from pizco import Server pxy = Server.serve_in_process(RemotePizcoEmitter,(),{},rep_endpoint="tcp://127.0.0.1:1111") app = QApplication([]) resync_proxy(pxy) from threading import Thread import numpy as np from guiqwt.plot import ImageWidget from guiqwt.builder import make import time im = ImageWidget() im.register_all_curve_tools() ts = TestSync() def test_thread(): ts.initialize_subobject(im) pxy.std_signal.connect(ts.receiver_int) #std_signal.connect(pg.setValue) #test_built_in.connect(pg.setRange) v_int = 0 while True: v_int += 1 #ts.update_curve() goes through a non generic signal pxy.emission() time.sleep(0.5) if v_int==5: break im.close() t = Thread(None,test_thread) t.start() im.show() app.exec_() pxy._proxy_stop_server() pxy._proxy_stop_me() assert(ts._internal_value != 0)
def test_guiqwt_case(self): app = QApplication([]) from threading import Thread import numpy as np from guiqwt.plot import ImageWidget from guiqwt.builder import make import time im = ImageWidget() im.register_all_curve_tools() ts = TestSync() def test_thread(): ts.initialize_subobject(im) std_signal = SignalResync(1) std_signal.connect(ts.receiver_int) #std_signal.connect(pg.setValue) #test_built_in.connect(pg.setRange) v_int = 0 while True: v_int += 1 #ts.update_curve() goes through a non generic signal std_signal.emit(v_int) time.sleep(0.5) if v_int == 5: break im.close() t = Thread(None,test_thread) t.start() im.show() app.exec_() assert(ts._internal_value != 0)
def add_plot(self, iplt, irow, icol): widget = ImageWidget(self, "Plot #%d" % (iplt + 1)) widget.setMinimumSize(200, 150) xdata = np.linspace(-10, 10) ydata = np.sin(xdata + np.random.randint(0, 100) * 0.01 * np.pi) curve_item = make.curve(xdata, ydata, color="b") widget.plot.add_item(curve_item) self.layout().addWidget(widget, irow, icol, 1, 1)
def __init__(self, parent, options=None): QWidget.__init__(self, parent=parent) if options is None: options = {} self.imagewidget = ImageWidget(self, **options) self.imagewidget.register_all_image_tools() hlayout = QHBoxLayout() self.add_buttons_to_layout(hlayout) vlayout = QVBoxLayout() vlayout.addWidget(self.imagewidget) vlayout.addLayout(hlayout) self.setLayout(vlayout)
def setupUi(self, Form): Form.setObjectName(_fromUtf8("Form")) Form.resize(608, 673) self.dial = QtGui.QDial(Form) self.dial.setGeometry(QtCore.QRect(110, 490, 111, 141)) self.dial.setObjectName(_fromUtf8("dial")) self.dial_2 = QtGui.QDial(Form) self.dial_2.setGeometry(QtCore.QRect(370, 490, 111, 131)) self.dial_2.setObjectName(_fromUtf8("dial_2")) self.label = QtGui.QLabel(Form) self.label.setGeometry(QtCore.QRect(130, 470, 46, 16)) font = QtGui.QFont() font.setPointSize(24) self.label.setFont(font) self.label.setObjectName(_fromUtf8("label")) self.label_2 = QtGui.QLabel(Form) self.label_2.setGeometry(QtCore.QRect(390, 470, 46, 16)) font = QtGui.QFont() font.setPointSize(24) self.label_2.setFont(font) self.label_2.setObjectName(_fromUtf8("label_2")) self.imagewidget = ImageWidget(Form) self.imagewidget.setGeometry(QtCore.QRect(90, 60, 400, 300)) self.imagewidget.setOrientation(QtCore.Qt.Vertical) self.imagewidget.setObjectName(_fromUtf8("imagewidget")) self.retranslateUi(Form) QtCore.QMetaObject.connectSlotsByName(Form)
def setupUi(self, NWADirectoryViewerWindow): NWADirectoryViewerWindow.setObjectName("NWADirectoryViewerWindow") NWADirectoryViewerWindow.resize(800, 600) sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Preferred) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(NWADirectoryViewerWindow.sizePolicy().hasHeightForWidth()) NWADirectoryViewerWindow.setSizePolicy(sizePolicy) self.centralwidget = QtGui.QWidget(NWADirectoryViewerWindow) self.centralwidget.setObjectName("centralwidget") self.verticalLayout = QtGui.QVBoxLayout(self.centralwidget) self.verticalLayout.setObjectName("verticalLayout") self.horizontalLayout = QtGui.QHBoxLayout() self.horizontalLayout.setObjectName("horizontalLayout") self.fileLabel = QtGui.QLabel(self.centralwidget) sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Preferred) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.fileLabel.sizePolicy().hasHeightForWidth()) self.fileLabel.setSizePolicy(sizePolicy) self.fileLabel.setObjectName("fileLabel") self.horizontalLayout.addWidget(self.fileLabel) self.watchCheckBox = QtGui.QCheckBox(self.centralwidget) self.watchCheckBox.setChecked(True) self.watchCheckBox.setObjectName("watchCheckBox") self.horizontalLayout.addWidget(self.watchCheckBox) self.autoscaleCheckBox = QtGui.QCheckBox(self.centralwidget) self.autoscaleCheckBox.setChecked(True) self.autoscaleCheckBox.setObjectName("autoscaleCheckBox") self.horizontalLayout.addWidget(self.autoscaleCheckBox) self.linearCheckBox = QtGui.QCheckBox(self.centralwidget) self.linearCheckBox.setObjectName("linearCheckBox") self.horizontalLayout.addWidget(self.linearCheckBox) self.normalizeCheckBox = QtGui.QCheckBox(self.centralwidget) self.normalizeCheckBox.setObjectName("normalizeCheckBox") self.horizontalLayout.addWidget(self.normalizeCheckBox) self.fileButton = QtGui.QPushButton(self.centralwidget) self.fileButton.setObjectName("fileButton") self.horizontalLayout.addWidget(self.fileButton) self.verticalLayout.addLayout(self.horizontalLayout) self.imagewidget = ImageWidget(self.centralwidget) sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.imagewidget.sizePolicy().hasHeightForWidth()) self.imagewidget.setSizePolicy(sizePolicy) self.imagewidget.setOrientation(QtCore.Qt.Vertical) self.imagewidget.setObjectName("imagewidget") self.verticalLayout.addWidget(self.imagewidget) NWADirectoryViewerWindow.setCentralWidget(self.centralwidget) self.menubar = QtGui.QMenuBar(NWADirectoryViewerWindow) self.menubar.setGeometry(QtCore.QRect(0, 0, 800, 22)) self.menubar.setObjectName("menubar") NWADirectoryViewerWindow.setMenuBar(self.menubar) self.statusbar = QtGui.QStatusBar(NWADirectoryViewerWindow) self.statusbar.setObjectName("statusbar") NWADirectoryViewerWindow.setStatusBar(self.statusbar) self.retranslateUi(NWADirectoryViewerWindow) QtCore.QMetaObject.connectSlotsByName(NWADirectoryViewerWindow)
class Ui_RingBufferViewer(object): def setupUi(self, RingBufferViewer): RingBufferViewer.setObjectName(_fromUtf8("RingBufferViewer")) RingBufferViewer.resize(617, 601) self.verticalLayout = QtGui.QVBoxLayout(RingBufferViewer) self.verticalLayout.setObjectName(_fromUtf8("verticalLayout")) self.imageWidget = ImageWidget(RingBufferViewer) self.imageWidget.setOrientation(QtCore.Qt.Vertical) self.imageWidget.setObjectName(_fromUtf8("imageWidget")) self.verticalLayout.addWidget(self.imageWidget) self.horizontalLayout = QtGui.QHBoxLayout() self.horizontalLayout.setObjectName(_fromUtf8("horizontalLayout")) self.indexSlider = QtGui.QSlider(RingBufferViewer) self.indexSlider.setOrientation(QtCore.Qt.Horizontal) self.indexSlider.setObjectName(_fromUtf8("indexSlider")) self.horizontalLayout.addWidget(self.indexSlider) self.indexBox = QtGui.QSpinBox(RingBufferViewer) self.indexBox.setObjectName(_fromUtf8("indexBox")) self.horizontalLayout.addWidget(self.indexBox) self.verticalLayout.addLayout(self.horizontalLayout) self.horizontalLayout_2 = QtGui.QHBoxLayout() self.horizontalLayout_2.setObjectName(_fromUtf8("horizontalLayout_2")) spacerItem = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) self.horizontalLayout_2.addItem(spacerItem) self.closeButton = QtGui.QPushButton(RingBufferViewer) self.closeButton.setObjectName(_fromUtf8("closeButton")) self.horizontalLayout_2.addWidget(self.closeButton) self.verticalLayout.addLayout(self.horizontalLayout_2) self.retranslateUi(RingBufferViewer) QtCore.QObject.connect(self.indexSlider, QtCore.SIGNAL(_fromUtf8("valueChanged(int)")), self.indexBox.setValue) QtCore.QObject.connect(self.indexBox, QtCore.SIGNAL(_fromUtf8("valueChanged(int)")), self.indexSlider.setValue) QtCore.QMetaObject.connectSlotsByName(RingBufferViewer) def retranslateUi(self, RingBufferViewer): RingBufferViewer.setWindowTitle( QtGui.QApplication.translate("RingBufferViewer", "Ring buffer viewer", None, QtGui.QApplication.UnicodeUTF8)) self.closeButton.setText( QtGui.QApplication.translate("RingBufferViewer", "Close", None, QtGui.QApplication.UnicodeUTF8))
def addImageWidget(self, images, *args, **kwargs): widget = ImageWidget(self, *args, **kwargs) plot = widget.get_plot() if (images.__class__ is not list): plot.add_item(images) else: for image in images: plot.add_item(image) # end for # end if self.centralWidget().layout().addWidget(widget) self.__l_layoutChilds.append(widget) return widget
class BaseTransformWidget(QWidget): """Base transform widget: see for example rotatecrop.py""" def __init__(self, parent, options=None): QWidget.__init__(self, parent=parent) if options is None: options = {} self.imagewidget = ImageWidget(self, **options) self.imagewidget.register_all_image_tools() hlayout = QHBoxLayout() self.add_buttons_to_layout(hlayout) vlayout = QVBoxLayout() vlayout.addWidget(self.imagewidget) vlayout.addLayout(hlayout) self.setLayout(vlayout) def get_plot(self): """Required for BaseTransformMixin""" return self.imagewidget.get_plot()
def test_guiqwt_case_altthread(self): app = QApplication([]) from threading import Thread import numpy as np from guiqwt.plot import ImageWidget from guiqwt.builder import make import time im = ImageWidget() im.register_all_curve_tools() ts = TestSync() def test_thread(): ts.initialize_subobject(im) std_signal = SignalResync.Auto(intermediate_thread=True) std_signal.connect(ts.receiver_int) v_int = 0 while True: v_int += 1 std_signal.emit(v_int) time.sleep(0.5) if v_int == 5: break im.close() t = Thread(None, test_thread) t.start() im.show() app.exec_() assert (ts._internal_value != 0)
def test_guiqwt_case(self): app = QApplication([]) from threading import Thread import numpy as np from guiqwt.plot import ImageWidget from guiqwt.builder import make import time im = ImageWidget() im.register_all_curve_tools() ts = TestSync() def test_thread(): ts.initialize_subobject(im) std_signal = SignalResync(1) std_signal.connect(ts.receiver_int) #std_signal.connect(pg.setValue) #test_built_in.connect(pg.setRange) v_int = 0 while True: v_int += 1 #ts.update_curve() goes through a non generic signal std_signal.emit(v_int) time.sleep(0.5) if v_int == 5: break im.close() t = Thread(None, test_thread) t.start() im.show() app.exec_() assert (ts._internal_value != 0)
def test_server_resync(self): from pizco import Server app = QApplication([]) srv = RemotePizcoEmitterResync() pizco_srv = Server(srv, rep_endpoint="tcp://127.0.0.1:1211") from threading import Thread import numpy as np from guiqwt.plot import ImageWidget from guiqwt.builder import make import time im = ImageWidget() im.register_all_curve_tools() ts = TestSync() def test_thread(): ts.initialize_subobject(im) srv.std_signal.connect(ts.receiver_int) v_int = 0 while True: v_int += 1 srv.emission() time.sleep(0.5) if v_int == 5: break im.close() t = Thread(None, test_thread) t.start() im.show() app.exec_() pizco_srv.stop() assert (ts._internal_value != 0)
def test_proxy_resync(self): from pizco import Server pxy = Server.serve_in_process(RemotePizcoEmitter, (), {}, rep_endpoint="tcp://127.0.0.1:1111") app = QApplication([]) resync_proxy(pxy) from threading import Thread import numpy as np from guiqwt.plot import ImageWidget from guiqwt.builder import make import time im = ImageWidget() im.register_all_curve_tools() ts = TestSync() def test_thread(): ts.initialize_subobject(im) pxy.std_signal.connect(ts.receiver_int) #std_signal.connect(pg.setValue) #test_built_in.connect(pg.setRange) v_int = 0 while True: v_int += 1 #ts.update_curve() goes through a non generic signal pxy.emission() time.sleep(0.5) if v_int == 5: break im.close() t = Thread(None, test_thread) t.start() im.show() app.exec_() pxy._proxy_stop_server() pxy._proxy_stop_me() assert (ts._internal_value != 0)
def setupUi(self, NWADirectoryViewerWindow): NWADirectoryViewerWindow.setObjectName("NWADirectoryViewerWindow") NWADirectoryViewerWindow.resize(800, 600) sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Preferred) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( NWADirectoryViewerWindow.sizePolicy().hasHeightForWidth()) NWADirectoryViewerWindow.setSizePolicy(sizePolicy) self.centralwidget = QtGui.QWidget(NWADirectoryViewerWindow) self.centralwidget.setObjectName("centralwidget") self.verticalLayout = QtGui.QVBoxLayout(self.centralwidget) self.verticalLayout.setObjectName("verticalLayout") self.horizontalLayout = QtGui.QHBoxLayout() self.horizontalLayout.setObjectName("horizontalLayout") self.fileLabel = QtGui.QLabel(self.centralwidget) sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Preferred) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( self.fileLabel.sizePolicy().hasHeightForWidth()) self.fileLabel.setSizePolicy(sizePolicy) self.fileLabel.setObjectName("fileLabel") self.horizontalLayout.addWidget(self.fileLabel) self.watchCheckBox = QtGui.QCheckBox(self.centralwidget) self.watchCheckBox.setChecked(True) self.watchCheckBox.setObjectName("watchCheckBox") self.horizontalLayout.addWidget(self.watchCheckBox) self.autoscaleCheckBox = QtGui.QCheckBox(self.centralwidget) self.autoscaleCheckBox.setChecked(True) self.autoscaleCheckBox.setObjectName("autoscaleCheckBox") self.horizontalLayout.addWidget(self.autoscaleCheckBox) self.linearCheckBox = QtGui.QCheckBox(self.centralwidget) self.linearCheckBox.setObjectName("linearCheckBox") self.horizontalLayout.addWidget(self.linearCheckBox) self.normalizeCheckBox = QtGui.QCheckBox(self.centralwidget) self.normalizeCheckBox.setObjectName("normalizeCheckBox") self.horizontalLayout.addWidget(self.normalizeCheckBox) self.fileButton = QtGui.QPushButton(self.centralwidget) self.fileButton.setObjectName("fileButton") self.horizontalLayout.addWidget(self.fileButton) self.verticalLayout.addLayout(self.horizontalLayout) self.imagewidget = ImageWidget(self.centralwidget) sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( self.imagewidget.sizePolicy().hasHeightForWidth()) self.imagewidget.setSizePolicy(sizePolicy) self.imagewidget.setOrientation(QtCore.Qt.Vertical) self.imagewidget.setObjectName("imagewidget") self.verticalLayout.addWidget(self.imagewidget) NWADirectoryViewerWindow.setCentralWidget(self.centralwidget) self.menubar = QtGui.QMenuBar(NWADirectoryViewerWindow) self.menubar.setGeometry(QtCore.QRect(0, 0, 800, 22)) self.menubar.setObjectName("menubar") NWADirectoryViewerWindow.setMenuBar(self.menubar) self.statusbar = QtGui.QStatusBar(NWADirectoryViewerWindow) self.statusbar.setObjectName("statusbar") NWADirectoryViewerWindow.setStatusBar(self.statusbar) self.retranslateUi(NWADirectoryViewerWindow) QtCore.QMetaObject.connectSlotsByName(NWADirectoryViewerWindow)
def setupUi(self, Dialog): Dialog.setObjectName(_fromUtf8("Dialog")) Dialog.resize(905, 675) self.graphicsView = QtGui.QGraphicsView(Dialog) self.graphicsView.setGeometry(QtCore.QRect(9, 9, 256, 192)) self.graphicsView.setObjectName(_fromUtf8("graphicsView")) self.imagewidget = ImageWidget(Dialog) self.imagewidget.setGeometry(QtCore.QRect(290, 10, 291, 191)) self.imagewidget.setOrientation(QtCore.Qt.Vertical) self.imagewidget.setObjectName(_fromUtf8("imagewidget")) self.curvewidget = CurveWidget(Dialog) self.curvewidget.setGeometry(QtCore.QRect(620, 10, 241, 211)) self.curvewidget.setOrientation(QtCore.Qt.Horizontal) self.curvewidget.setObjectName(_fromUtf8("curvewidget")) self.mplwidget = MatplotlibWidget(Dialog) self.mplwidget.setGeometry(QtCore.QRect(0, 230, 311, 231)) self.mplwidget.setObjectName(_fromUtf8("mplwidget")) self.qwtPlot = Qwt5.QwtPlot(Dialog) self.qwtPlot.setGeometry(QtCore.QRect(540, 260, 281, 161)) self.qwtPlot.setObjectName(_fromUtf8("qwtPlot")) self.AnalogClock = Qwt5.QwtAnalogClock(Dialog) self.AnalogClock.setGeometry(QtCore.QRect(30, 500, 151, 151)) self.AnalogClock.setLineWidth(4) self.AnalogClock.setObjectName(_fromUtf8("AnalogClock")) self.Compass = Qwt5.QwtCompass(Dialog) self.Compass.setGeometry(QtCore.QRect(220, 490, 151, 151)) self.Compass.setLineWidth(4) self.Compass.setObjectName(_fromUtf8("Compass")) self.Thermo = Qwt5.QwtThermo(Dialog) self.Thermo.setGeometry(QtCore.QRect(390, 480, 71, 151)) self.Thermo.setObjectName(_fromUtf8("Thermo")) self.Wheel = Qwt5.QwtWheel(Dialog) self.Wheel.setGeometry(QtCore.QRect(510, 470, 151, 31)) self.Wheel.setObjectName(_fromUtf8("Wheel")) self.label = QtGui.QLabel(Dialog) self.label.setGeometry(QtCore.QRect(80, 210, 131, 16)) self.label.setObjectName(_fromUtf8("label")) self.label_2 = QtGui.QLabel(Dialog) self.label_2.setGeometry(QtCore.QRect(370, 210, 131, 16)) self.label_2.setObjectName(_fromUtf8("label_2")) self.label_3 = QtGui.QLabel(Dialog) self.label_3.setGeometry(QtCore.QRect(690, 230, 131, 16)) self.label_3.setObjectName(_fromUtf8("label_3")) self.label_4 = QtGui.QLabel(Dialog) self.label_4.setGeometry(QtCore.QRect(80, 470, 131, 16)) self.label_4.setObjectName(_fromUtf8("label_4")) self.label_5 = QtGui.QLabel(Dialog) self.label_5.setGeometry(QtCore.QRect(370, 420, 131, 16)) self.label_5.setObjectName(_fromUtf8("label_5")) self.label_6 = QtGui.QLabel(Dialog) self.label_6.setGeometry(QtCore.QRect(660, 430, 131, 16)) self.label_6.setObjectName(_fromUtf8("label_6")) self.label_8 = QtGui.QLabel(Dialog) self.label_8.setGeometry(QtCore.QRect(60, 650, 131, 16)) self.label_8.setObjectName(_fromUtf8("label_8")) self.label_9 = QtGui.QLabel(Dialog) self.label_9.setGeometry(QtCore.QRect(250, 650, 131, 16)) self.label_9.setObjectName(_fromUtf8("label_9")) self.label_10 = QtGui.QLabel(Dialog) self.label_10.setGeometry(QtCore.QRect(410, 650, 131, 16)) self.label_10.setObjectName(_fromUtf8("label_10")) self.label_11 = QtGui.QLabel(Dialog) self.label_11.setGeometry(QtCore.QRect(550, 530, 131, 16)) self.label_11.setObjectName(_fromUtf8("label_11")) self.retranslateUi(Dialog) QtCore.QMetaObject.connectSlotsByName(Dialog)
def __init__(self, ident, rank, accum, plotkwargs, trace=None, xpts=[], ypts=[]): qt.QWidget.__init__(self) qt.QVBoxLayout(self) self.layout().setSpacing(0) self.layout().setContentsMargins(5,0,5,0) self.toolbar = toolbar = qt.QToolBar() self.layout().addWidget(toolbar) self.ident = ident self.rank = rank self.accum = accum self.xpts = xpts self.ypts = ypts self.update_count = 0 self.collapsed = False autoscale_gui_default=True if self.rank == 1: self.plot_widget = CurveWidget(title=ident) self.plot_widget.add_toolbar(toolbar) self.plot_widget.register_all_curve_tools() try: vmin,vmax=plotkwargs.pop('xlimit') self.plot_widget.plot.set_axis_limits(2,vmin,vmax) autoscale_gui_default=False except: pass try: vmin,vmax=plotkwargs.pop('ylimit') self.plot_widget.plot.set_axis_limits(0,vmin,vmax) autoscale_gui_default=False except: pass try: title=plotkwargs.pop('title') self.plot_widget.set_title(title) except: pass try: background=plotkwargs.pop('background') self.plot_widget.plot.grid.gridparam.background = background self.plot_widget.plot.grid.update_params() except: pass elif self.rank == 2: self.plot_widget = ImageWidget(title=ident, lock_aspect_ratio=False) self.plot_widget.add_toolbar(toolbar) self.plot_widget.register_all_image_tools() else: raise ValueError self.items = {} self.add_item(trace, plotkwargs) self.layout().addWidget(self.plot_widget) self.buttons_widget = buttons = qt.QWidget() qt.QHBoxLayout(buttons) self.hide_button = qt.QPushButton('Hide') self.hide_button.clicked.connect(self.collapse) self.show_button = qt.QPushButton('Show ' + ident) self.show_button.clicked.connect(self.expand) self.show_button.hide() self.remove_button = qt.QPushButton('Remove') self.zoom_button = qt.QPushButton('Zoom') self.autoscale_check = qt.QCheckBox('autoscale') #print autoscale_gui_default,"<== is this true?" self.autoscale_check.setChecked(autoscale_gui_default) buttons.layout().addWidget(self.hide_button) buttons.layout().addWidget(self.remove_button) buttons.layout().addWidget(self.zoom_button) buttons.layout().addWidget(self.autoscale_check) self.layout().addWidget(buttons) self.layout().addWidget(self.show_button)
def __init__(self, fname=None): gui.SlabWindow.__init__(self, HDFViewThread) self.setupSlabWindow(autoparam=True) self.auto_register_gui() self.register_param(self.datasets_treeWidget, "dataset") self.register_param(self.datapath_lineEdit, "datapath") # Setup Plots -- Could be eliminated if QtDesigner plugins were setup self.toolbar = Qt.QToolBar() self.addToolBar(self.toolbar) self.image_widget = ImageWidget(show_xsection=True, show_ysection=True) self.image_widget.add_toolbar(self.toolbar) self.image_widget.register_all_image_tools() self.image_plot = self.image_widget.plot self.image_plot_layout.addWidget(self.image_widget) self.gui["image_plot"] = self.image_plot self.line_widget = CurveWidget() self.gui[ "line_plot"] = self.line_plot = self.line_widget.plot #CurvePlot() self.line_plot_layout.addWidget(self.line_plot) self.line_widget.register_all_image_tools() # Context Menu actions self.set_x_action = Qt.QAction("Set as x data", self) self.clear_x_action = Qt.QAction("Clear x data", self) self.datasets_treeWidget.customContextMenuRequested.connect( lambda point: self.msg("menu requested")) self.datasets_treeWidget.customContextMenuRequested.connect( self.datasets_context_menu) # Connect launchers self.datapath_browse_pushButton.clicked.connect(self.select_datapath) self.register_script("set_datapath", self.datapath_lineEdit) self.register_script("load_file", self.datafiles_listWidget) self.register_script("load_dset", self.datasets_treeWidget) self.register_script("set_x_data", self.set_x_action) self.register_script("clear_x_data", self.clear_x_action) # Syntax Highlighting self.highlight = syntax.PythonHighlighter( self.script_textEdit.document()) # Setup Prompt """ message = "The currently loaded file is stored as 'f'" self.shell = InternalShell(self, message=message) self.shell.set_font(Qt.QFont("Consolas")) self.shell_dockWidget.setWidget(self.shell) self.gui["shell"] = self.shell """ self.start_thread() if fname is not None: self.shell.exit_interpreter() directory = os.path.dirname(fname) nameitem = namedtuple('pseudoitem', ('filename', ))(fname) self.msg(fname) self.set_param("datapath", directory) self.start_script("set_datapath") self.start_script("load_file", nameitem)
class CentralWidget(QSplitter): def __init__(self, parent, toolbar): QSplitter.__init__(self, parent) self.setContentsMargins(10, 10, 10, 10) self.setOrientation(Qt.Vertical) imagelistwithproperties = ImageListWithProperties(self) self.addWidget(imagelistwithproperties) self.imagelist = imagelistwithproperties.imagelist self.connect(self.imagelist, SIGNAL("currentRowChanged(int)"), self.current_item_changed) self.connect(self.imagelist, SIGNAL("itemSelectionChanged()"), self.selection_changed) self.properties = imagelistwithproperties.properties self.connect(self.properties, SIGNAL("apply_button_clicked()"), self.properties_changed) self.imagewidget = ImageWidget(self) self.connect(self.imagewidget.plot, SIG_LUT_CHANGED, self.lut_range_changed) self.item = None # image item self.imagewidget.add_toolbar(toolbar, "default") self.imagewidget.register_all_image_tools() self.addWidget(self.imagewidget) self.images = [] # List of ImageParam instances self.lut_ranges = [] # List of LUT ranges self.setStretchFactor(0, 0) self.setStretchFactor(1, 1) self.setHandleWidth(10) self.setSizes([1, 2]) def refresh_list(self): self.imagelist.clear() self.imagelist.addItems([image.title for image in self.images]) def selection_changed(self): """Image list: selection changed""" row = self.imagelist.currentRow() self.properties.setDisabled(row == -1) def current_item_changed(self, row): """Image list: current image changed""" image, lut_range = self.images[row], self.lut_ranges[row] self.show_data(image.data, lut_range) update_dataset(self.properties.dataset, image) self.properties.get() def lut_range_changed(self): row = self.imagelist.currentRow() self.lut_ranges[row] = self.item.get_lut_range() def show_data(self, data, lut_range=None): plot = self.imagewidget.plot if self.item is not None: self.item.set_data(data) if lut_range is None: lut_range = self.item.get_lut_range() self.imagewidget.set_contrast_range(*lut_range) self.imagewidget.update_cross_sections() else: self.item = make.image(data) plot.add_item(self.item, z=0) plot.replot() def properties_changed(self): """The properties 'Apply' button was clicked: updating image""" row = self.imagelist.currentRow() image = self.images[row] update_dataset(image, self.properties.dataset) self.refresh_list() self.show_data(image.data) def add_image(self, image): self.images.append(image) self.lut_ranges.append(None) self.refresh_list() self.imagelist.setCurrentRow(len(self.images)-1) plot = self.imagewidget.plot plot.do_autoscale() def add_image_from_file(self, filename): image = ImageParam() image.title = to_text_string(filename) image.data = io.imread(filename, to_grayscale=True) image.height, image.width = image.data.shape self.add_image(image)
def setup_plot(self): self.imagewidget = ImageWidget() self.plot = self.imagewidget.plot self.image = make.image(np.random.rand(100, 100)) self.plot.add_item(self.image)
class CentralWidget(QSplitter): def __init__(self, parent, toolbar): QSplitter.__init__(self, parent) self.setContentsMargins(10, 10, 10, 10) self.setOrientation(Qt.Vertical) imagelistwithproperties = ImageListWithProperties(self) self.addWidget(imagelistwithproperties) self.imagelist = imagelistwithproperties.imagelist self.connect(self.imagelist, SIGNAL("currentRowChanged(int)"), self.current_item_changed) self.connect(self.imagelist, SIGNAL("itemSelectionChanged()"), self.selection_changed) self.properties = imagelistwithproperties.properties self.connect(self.properties, SIGNAL("apply_button_clicked()"), self.properties_changed) self.imagewidget = ImageWidget(self) self.connect(self.imagewidget.plot, SIG_LUT_CHANGED, self.lut_range_changed) self.item = None # image item self.imagewidget.add_toolbar(toolbar, "default") self.imagewidget.register_all_image_tools() self.addWidget(self.imagewidget) self.images = [] # List of ImageParam instances self.lut_ranges = [] # List of LUT ranges self.setStretchFactor(0, 0) self.setStretchFactor(1, 1) self.setHandleWidth(10) self.setSizes([1, 2]) def refresh_list(self): self.imagelist.clear() self.imagelist.addItems([image.title for image in self.images]) def selection_changed(self): """Image list: selection changed""" row = self.imagelist.currentRow() self.properties.setDisabled(row == -1) def current_item_changed(self, row): """Image list: current image changed""" image, lut_range = self.images[row], self.lut_ranges[row] self.show_data(image.data, lut_range) update_dataset(self.properties.dataset, image) self.properties.get() def lut_range_changed(self): row = self.imagelist.currentRow() self.lut_ranges[row] = self.item.get_lut_range() def show_data(self, data, lut_range=None): plot = self.imagewidget.plot if self.item is not None: self.item.set_data(data) if lut_range is None: lut_range = self.item.get_lut_range() self.imagewidget.set_contrast_range(*lut_range) self.imagewidget.update_cross_sections() else: self.item = make.image(data) plot.add_item(self.item, z=0) plot.replot() def properties_changed(self): """The properties 'Apply' button was clicked: updating image""" row = self.imagelist.currentRow() image = self.images[row] update_dataset(image, self.properties.dataset) self.refresh_list() self.show_data(image.data) def add_image(self, image): self.images.append(image) self.lut_ranges.append(None) self.refresh_list() self.imagelist.setCurrentRow(len(self.images) - 1) plot = self.imagewidget.plot plot.do_autoscale() def add_image_from_file(self, filename): image = ImageParam() image.title = to_text_string(filename) image.data = io.imread(filename, to_grayscale=True) image.height, image.width = image.data.shape self.add_image(image)
def __init__(self, ident, rank, accum, plotkwargs, trace=None, xpts=[], ypts=[]): qt.QWidget.__init__(self) qt.QVBoxLayout(self) self.layout().setSpacing(0) self.layout().setContentsMargins(5, 0, 5, 0) self.toolbar = toolbar = qt.QToolBar() self.layout().addWidget(toolbar) self.ident = ident self.rank = rank self.accum = accum self.xpts = xpts self.ypts = ypts self.update_count = 0 self.collapsed = False autoscale_gui_default = True if self.rank == 1: self.plot_widget = CurveWidget(title=ident) self.plot_widget.add_toolbar(toolbar) self.plot_widget.register_all_curve_tools() try: vmin, vmax = plotkwargs.pop('xlimit') self.plot_widget.plot.set_axis_limits(2, vmin, vmax) autoscale_gui_default = False except: pass try: vmin, vmax = plotkwargs.pop('ylimit') self.plot_widget.plot.set_axis_limits(0, vmin, vmax) autoscale_gui_default = False except: pass try: title = plotkwargs.pop('title') self.plot_widget.set_title(title) except: pass try: background = plotkwargs.pop('background') self.plot_widget.plot.grid.gridparam.background = background self.plot_widget.plot.grid.update_params() except: pass elif self.rank == 2: self.plot_widget = ImageWidget(title=ident, lock_aspect_ratio=False) self.plot_widget.add_toolbar(toolbar) self.plot_widget.register_all_image_tools() else: raise ValueError self.items = {} self.add_item(trace, plotkwargs) self.layout().addWidget(self.plot_widget) self.buttons_widget = buttons = qt.QWidget() qt.QHBoxLayout(buttons) self.hide_button = qt.QPushButton('Hide') self.hide_button.clicked.connect(self.collapse) self.show_button = qt.QPushButton('Show ' + ident) self.show_button.clicked.connect(self.expand) self.show_button.hide() self.remove_button = qt.QPushButton('Remove') self.zoom_button = qt.QPushButton('Zoom') self.autoscale_check = qt.QCheckBox('autoscale') #print autoscale_gui_default,"<== is this true?" self.autoscale_check.setChecked(autoscale_gui_default) buttons.layout().addWidget(self.hide_button) buttons.layout().addWidget(self.remove_button) buttons.layout().addWidget(self.zoom_button) buttons.layout().addWidget(self.autoscale_check) self.layout().addWidget(buttons) self.layout().addWidget(self.show_button)
def __init__(self, fname=None): gui.SlabWindow.__init__(self, HDFViewThread) self.setupSlabWindow(autoparam=True) self.auto_register_gui() self.register_param(self.datasets_treeWidget, "dataset") self.register_param(self.datapath_lineEdit, "datapath") # Setup Plots -- Could be eliminated if QtDesigner plugins were setup self.toolbar = Qt.QToolBar() self.addToolBar(self.toolbar) self.image_widget = ImageWidget(show_xsection=True, show_ysection=True) self.image_widget.add_toolbar(self.toolbar) self.image_widget.register_all_image_tools() self.image_plot = self.image_widget.plot self.image_plot_layout.addWidget(self.image_widget) self.gui["image_plot"] = self.image_plot self.line_widget = CurveWidget() self.gui["line_plot"] = self.line_plot = self.line_widget.plot #CurvePlot() self.line_plot_layout.addWidget(self.line_plot) self.line_widget.register_all_image_tools() # Context Menu actions self.set_x_action = Qt.QAction("Set as x data", self) self.clear_x_action = Qt.QAction("Clear x data", self) self.datasets_treeWidget.customContextMenuRequested.connect( lambda point: self.msg("menu requested")) self.datasets_treeWidget.customContextMenuRequested.connect( self.datasets_context_menu) # Connect launchers self.datapath_browse_pushButton.clicked.connect(self.select_datapath) self.register_script("set_datapath", self.datapath_lineEdit) self.register_script("load_file", self.datafiles_listWidget) self.register_script("load_dset", self.datasets_treeWidget) self.register_script("set_x_data", self.set_x_action) self.register_script("clear_x_data", self.clear_x_action) # Syntax Highlighting self.highlight = syntax.PythonHighlighter(self.script_textEdit.document()) # Setup Prompt """ message = "The currently loaded file is stored as 'f'" self.shell = InternalShell(self, message=message) self.shell.set_font(Qt.QFont("Consolas")) self.shell_dockWidget.setWidget(self.shell) self.gui["shell"] = self.shell """ self.start_thread() if fname is not None: self.shell.exit_interpreter() directory = os.path.dirname(fname) nameitem = namedtuple('pseudoitem', ('filename',))(fname) self.msg(fname) self.set_param("datapath", directory) self.start_script("set_datapath") self.start_script("load_file", nameitem)
def setupUi(self, MainWindow): MainWindow.setObjectName(_fromUtf8("MainWindow")) MainWindow.resize(540, 854) self.centralwidget = QtGui.QWidget(MainWindow) self.centralwidget.setObjectName(_fromUtf8("centralwidget")) self.verticalLayout_2 = QtGui.QVBoxLayout(self.centralwidget) self.verticalLayout_2.setObjectName(_fromUtf8("verticalLayout_2")) self.imageWidget = ImageWidget(self.centralwidget) self.imageWidget.setOrientation(QtCore.Qt.Vertical) self.imageWidget.setObjectName(_fromUtf8("imageWidget")) self.verticalLayout_2.addWidget(self.imageWidget) self.groupBox = QtGui.QGroupBox(self.centralwidget) self.groupBox.setObjectName(_fromUtf8("groupBox")) self.verticalLayout = QtGui.QVBoxLayout(self.groupBox) self.verticalLayout.setObjectName(_fromUtf8("verticalLayout")) self.gridLayout_2 = QtGui.QGridLayout() self.gridLayout_2.setObjectName(_fromUtf8("gridLayout_2")) self.exposureTimeBox = QtGui.QSpinBox(self.groupBox) self.exposureTimeBox.setMinimum(10) self.exposureTimeBox.setMaximum(5000) self.exposureTimeBox.setSingleStep(10) self.exposureTimeBox.setProperty("value", 100) self.exposureTimeBox.setObjectName(_fromUtf8("exposureTimeBox")) self.gridLayout_2.addWidget(self.exposureTimeBox, 0, 1, 1, 1) self.label = QtGui.QLabel(self.groupBox) self.label.setObjectName(_fromUtf8("label")) self.gridLayout_2.addWidget(self.label, 0, 0, 1, 1) spacerItem = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) self.gridLayout_2.addItem(spacerItem, 0, 2, 1, 1) self.verticalLayout.addLayout(self.gridLayout_2) self.verticalLayout_2.addWidget(self.groupBox) self.groupBox_2 = QtGui.QGroupBox(self.centralwidget) self.groupBox_2.setObjectName(_fromUtf8("groupBox_2")) self.gridLayout = QtGui.QGridLayout(self.groupBox_2) self.gridLayout.setObjectName(_fromUtf8("gridLayout")) self.gridLayout_3 = QtGui.QGridLayout() self.gridLayout_3.setObjectName(_fromUtf8("gridLayout_3")) self.scaleMinBox = QtGui.QSpinBox(self.groupBox_2) self.scaleMinBox.setMaximum(99999) self.scaleMinBox.setSingleStep(20) self.scaleMinBox.setObjectName(_fromUtf8("scaleMinBox")) self.gridLayout_3.addWidget(self.scaleMinBox, 0, 1, 1, 1) self.autoscaleButton = QtGui.QCheckBox(self.groupBox_2) self.autoscaleButton.setChecked(True) self.autoscaleButton.setObjectName(_fromUtf8("autoscaleButton")) self.gridLayout_3.addWidget(self.autoscaleButton, 2, 1, 1, 1) self.scaleMaxBox = QtGui.QSpinBox(self.groupBox_2) self.scaleMaxBox.setMinimum(1) self.scaleMaxBox.setMaximum(99999) self.scaleMaxBox.setSingleStep(10) self.scaleMaxBox.setProperty("value", 2000) self.scaleMaxBox.setObjectName(_fromUtf8("scaleMaxBox")) self.gridLayout_3.addWidget(self.scaleMaxBox, 1, 1, 1, 1) self.colormapBox = QtGui.QComboBox(self.groupBox_2) self.colormapBox.setObjectName(_fromUtf8("colormapBox")) self.gridLayout_3.addWidget(self.colormapBox, 3, 1, 1, 1) self.label_2 = QtGui.QLabel(self.groupBox_2) self.label_2.setObjectName(_fromUtf8("label_2")) self.gridLayout_3.addWidget(self.label_2, 0, 0, 1, 1) self.label_5 = QtGui.QLabel(self.groupBox_2) self.label_5.setObjectName(_fromUtf8("label_5")) self.gridLayout_3.addWidget(self.label_5, 3, 0, 1, 1) self.label_3 = QtGui.QLabel(self.groupBox_2) self.label_3.setObjectName(_fromUtf8("label_3")) self.gridLayout_3.addWidget(self.label_3, 1, 0, 1, 1) self.rescaleButton = QtGui.QPushButton(self.groupBox_2) self.rescaleButton.setObjectName(_fromUtf8("rescaleButton")) self.gridLayout_3.addWidget(self.rescaleButton, 0, 3, 1, 1) self.rotateCWButton = QtGui.QPushButton(self.groupBox_2) self.rotateCWButton.setEnabled(True) self.rotateCWButton.setObjectName(_fromUtf8("rotateCWButton")) self.gridLayout_3.addWidget(self.rotateCWButton, 1, 3, 1, 1) spacerItem1 = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Minimum) self.gridLayout_3.addItem(spacerItem1, 0, 2, 1, 1) self.rotateCCWButton = QtGui.QPushButton(self.groupBox_2) self.rotateCCWButton.setObjectName(_fromUtf8("rotateCCWButton")) self.gridLayout_3.addWidget(self.rotateCCWButton, 1, 2, 1, 1) self.showROIBox = QtGui.QCheckBox(self.groupBox_2) self.showROIBox.setChecked(True) self.showROIBox.setObjectName(_fromUtf8("showROIBox")) self.gridLayout_3.addWidget(self.showROIBox, 3, 3, 1, 1) self.flipVerticalButton = QtGui.QPushButton(self.groupBox_2) self.flipVerticalButton.setObjectName(_fromUtf8("flipVerticalButton")) self.gridLayout_3.addWidget(self.flipVerticalButton, 2, 2, 1, 1) self.flipHorizontalButton = QtGui.QPushButton(self.groupBox_2) self.flipHorizontalButton.setObjectName( _fromUtf8("flipHorizontalButton")) self.gridLayout_3.addWidget(self.flipHorizontalButton, 2, 3, 1, 1) self.gridLayout.addLayout(self.gridLayout_3, 0, 0, 2, 1) self.verticalLayout_2.addWidget(self.groupBox_2) self.horizontalLayout = QtGui.QHBoxLayout() self.horizontalLayout.setObjectName(_fromUtf8("horizontalLayout")) spacerItem2 = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) self.horizontalLayout.addItem(spacerItem2) self.adjustROIButton = QtGui.QPushButton(self.centralwidget) self.adjustROIButton.setObjectName(_fromUtf8("adjustROIButton")) self.horizontalLayout.addWidget(self.adjustROIButton) self.roiStatisticsButton = QtGui.QToolButton(self.centralwidget) self.roiStatisticsButton.setObjectName( _fromUtf8("roiStatisticsButton")) self.horizontalLayout.addWidget(self.roiStatisticsButton) self.cameraSettingsButton = QtGui.QToolButton(self.centralwidget) self.cameraSettingsButton.setObjectName( _fromUtf8("cameraSettingsButton")) self.horizontalLayout.addWidget(self.cameraSettingsButton) self.acquisitionButton = QtGui.QPushButton(self.centralwidget) self.acquisitionButton.setObjectName(_fromUtf8("acquisitionButton")) self.horizontalLayout.addWidget(self.acquisitionButton) self.verticalLayout_2.addLayout(self.horizontalLayout) MainWindow.setCentralWidget(self.centralwidget) self.menubar = QtGui.QMenuBar(MainWindow) self.menubar.setGeometry(QtCore.QRect(0, 0, 540, 29)) self.menubar.setObjectName(_fromUtf8("menubar")) self.menuFile = QtGui.QMenu(self.menubar) self.menuFile.setObjectName(_fromUtf8("menuFile")) self.menuHelp = QtGui.QMenu(self.menubar) self.menuHelp.setObjectName(_fromUtf8("menuHelp")) self.menuRing_Buffer = QtGui.QMenu(self.menubar) self.menuRing_Buffer.setObjectName(_fromUtf8("menuRing_Buffer")) MainWindow.setMenuBar(self.menubar) self.statusBar = QtGui.QStatusBar(MainWindow) self.statusBar.setObjectName(_fromUtf8("statusBar")) MainWindow.setStatusBar(self.statusBar) self.actionSaveAs = QtGui.QAction(MainWindow) self.actionSaveAs.setObjectName(_fromUtf8("actionSaveAs")) self.actionExit = QtGui.QAction(MainWindow) self.actionExit.setObjectName(_fromUtf8("actionExit")) self.actionAbout = QtGui.QAction(MainWindow) self.actionAbout.setEnabled(False) self.actionAbout.setObjectName(_fromUtf8("actionAbout")) self.actionEnable = QtGui.QAction(MainWindow) self.actionEnable.setCheckable(True) self.actionEnable.setChecked(True) self.actionEnable.setObjectName(_fromUtf8("actionEnable")) self.actionView = QtGui.QAction(MainWindow) self.actionView.setObjectName(_fromUtf8("actionView")) self.menuFile.addAction(self.actionSaveAs) self.menuFile.addAction(self.actionExit) self.menuHelp.addAction(self.actionAbout) self.menuRing_Buffer.addAction(self.actionEnable) self.menuRing_Buffer.addAction(self.actionView) self.menubar.addAction(self.menuFile.menuAction()) self.menubar.addAction(self.menuRing_Buffer.menuAction()) self.menubar.addAction(self.menuHelp.menuAction()) self.retranslateUi(MainWindow) QtCore.QMetaObject.connectSlotsByName(MainWindow)