Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def drawmain(self):
# the left contains the rows, the right the columns
leftlayout = QtGui.QVBoxLayout()
rightlayout = QtGui.QHBoxLayout()
mainlayout = QtGui.QHBoxLayout()
mainlayout.addLayout(leftlayout)
mainlayout.addLayout(rightlayout)
self.setLayout(mainlayout)
# the section 'slider' is treated as the first row
# this is only for backward compatibility
section = 'slider'
if config.has_section(section):
sectionlayout = QtGui.QHBoxLayout()
self.drawpanel(sectionlayout, config.items(section))
leftlayout.addLayout(sectionlayout)
for row in range(0, 16):
section = 'row%d' % (row + 1)
if config.has_section(section):
sectionlayout = QtGui.QHBoxLayout()
from ..graphicsItems.ROI import ROI
from ..graphicsItems.ViewBox import ViewBox
from ..graphicsItems.GridItem import GridItem
if USE_PYSIDE:
from .CanvasTemplate_pyside import *
else:
from .CanvasTemplate_pyqt import *
import numpy as np
from .. import debug
import weakref
from .CanvasManager import CanvasManager
from .CanvasItem import CanvasItem, GroupCanvasItem
class Canvas(QtGui.QWidget):
sigSelectionChanged = QtCore.Signal(object, object)
sigItemTransformChanged = QtCore.Signal(object, object)
sigItemTransformChangeFinished = QtCore.Signal(object, object)
def __init__(self, parent=None, allowTransforms=True, hideCtrl=False, name=None):
QtGui.QWidget.__init__(self, parent)
self.ui = Ui_Form()
self.ui.setupUi(self)
#self.view = self.ui.view
self.view = ViewBox()
self.ui.view.setCentralItem(self.view)
self.itemList = self.ui.itemList
self.itemList.setSelectionMode(self.itemList.ExtendedSelection)
self.allowTransforms = allowTransforms
self.multiSelectBox = SelectBox()
def widget(self):
w = QtGui.QWidget()
layout = QtGui.QGridLayout()
w.setLayout(layout)
layout.addWidget(self.OSC1.widget(), 0, 0)
layout.addWidget(self.OSC2.widget(), 1, 0)
layout.addWidget(self.OSC3.widget(), 2, 0)
layout.addWidget(self.OSC4.widget(), 3, 0)
layout.addWidget(self.Spec.widget(), 0, 1, 4, 1)
return w
def setup_menus(self):
"""
"""
self.menu_spots = QtGui.QMenu("Spots")
# action_add_spot = QtGui.QAction("Add spot", self.menu_spots)
# self.menu_spots.addAction(action_add_spot)
# action_add_spot.triggered.connect(lambda x: x)
action_remove_spot = QtGui.QAction("Remove spots", self.menu_spots)
self.menu_spots.addAction(action_remove_spot)
action_remove_spot.setShortcut("Del")
action_remove_spot.triggered.connect(self.remove_spots)
self.menu_trajs = QtGui.QMenu("Trajectories")
action_merge_trajs = QtGui.QAction("Merge two trajectories", self.menu_trajs)
self.menu_trajs.addAction(action_merge_trajs)
action_merge_trajs.triggered.connect(self.merge_trajs)
action_remove_traj = QtGui.QAction("Remove trajectory", self.menu_trajs)
self.menu_trajs.addAction(action_remove_traj)
action_remove_traj.triggered.connect(self.remove_traj)
action_cut_traj = QtGui.QAction("Cut trajectory", self.menu_trajs)
self.menu_trajs.addAction(action_cut_traj)
action_cut_traj.triggered.connect(self.cut_traj)
action_duplicate_traj = QtGui.QAction("Duplicate trajectory", self.menu_trajs)
self.menu_trajs.addAction(action_duplicate_traj)
action_duplicate_traj.triggered.connect(self.duplicate_traj)
pickle.dump(self.stitches, f)
f.close()
if keys is None:
keys = np.unique(self.pd.objid.values)
print 'N keys: ', len(keys)
self.keys = keys
self.key_index = -1
self.key = None
self.candidate = None
self.candidates = None
self.candidate_index = -1
self.new_key = True
## create GUI
self.app = QtGui.QApplication([])
self.w = QtGui.QWidget()
self.layout = QtGui.QGridLayout()
self.w.setLayout(self.layout)
next_btn = QtGui.QPushButton('next match')
next_btn.pressed.connect(self.next_stitch)
self.layout.addWidget(next_btn, 0, 0)
save_btn = QtGui.QPushButton('save stitch')
save_btn.pressed.connect(self.save_stitch)
self.layout.addWidget(save_btn, 1, 0)
reject_btn = QtGui.QPushButton('reject stitch')
reject_btn.pressed.connect(self.reject_stitch)
self.layout.addWidget(reject_btn, 2, 0)
def main():
import sys
app = QtGui.QApplication(sys.argv)
plot_controller = Controller()
if (sys.flags.interactive != 1) or not hasattr(QtCore, 'PYQT_VERSION'):
QtGui.QApplication.instance().exec_()
# -*- coding: utf-8 -*-
from pyqtgraph.Qt import QtGui, QtCore
from pyqtgraph.pgcollections import OrderedDict
import types, traceback
import numpy as np
try:
import metaarray
HAVE_METAARRAY = True
except:
HAVE_METAARRAY = False
__all__ = ['DataTreeWidget']
class DataTreeWidget(QtGui.QTreeWidget):
"""
Widget for displaying hierarchical python data structures
(eg, nested dicts, lists, and arrays)
"""
def __init__(self, parent=None, data=None):
QtGui.QTreeWidget.__init__(self, parent)
self.setVerticalScrollMode(self.ScrollPerPixel)
self.setData(data)
self.setColumnCount(3)
self.setHeaderLabels(['key / index', 'type', 'value'])
def setData(self, data, hideRoot=False):
"""data should be a dictionary."""
self.clear()
from pyqtgraph.Qt import QtGui, QtCore
from pyqtgraph.GraphicsScene import GraphicsScene
from .GraphicsItem import GraphicsItem
__all__ = ['GraphicsWidget']
class GraphicsWidget(GraphicsItem, QtGui.QGraphicsWidget):
_qtBaseClass = QtGui.QGraphicsWidget
def __init__(self, *args, **kargs):
"""
**Bases:** :class:`GraphicsItem `, :class:`QtGui.QGraphicsWidget`
Extends QGraphicsWidget with several helpful methods and workarounds for PyQt bugs.
Most of the extra functionality is inherited from :class:`GraphicsItem `.
"""
QtGui.QGraphicsWidget.__init__(self, *args, **kargs)
GraphicsItem.__init__(self)
## done by GraphicsItem init
#GraphicsScene.registerObject(self) ## workaround for pyqt bug in graphicsscene.items()
# Removed due to https://bugreports.qt-project.org/browse/PYSIDE-86
def resize(self, size):
oldSize = self.size()
GraphicsView.resize(self, size)
self.resizeEvent(QtGui.QResizeEvent(size, oldSize))
self.update()
def __exit__(self, *args):
BusyCursor.active.pop(-1)
if len(BusyCursor.active) == 0:
QtGui.QApplication.restoreOverrideCursor()