Esempio n. 1
0
    def __init__(self, fnPrevious, fnNext):
        QtGui.QWidget.__init__(self)
        #make frameles:
        self.setWindowFlags(QtCore.Qt.FramelessWindowHint | QtCore.Qt.WindowStaysOnTopHint)

        layout = QtGui.QHBoxLayout()
        self.setLayout(layout)

        btn_previous = QtGui.QPushButton('Previous')  
        btn_previous.clicked.connect(fnPrevious)   
        btn_next = QtGui.QPushButton('Next')
        btn_next.clicked.connect(fnNext)   

        layout.addWidget(btn_previous)
        layout.addWidget(btn_next)
Esempio n. 2
0
    def __init__(self, layerlabel, shape1, shape2):
        QtGui.QDialog.__init__(self)

        labTxt = QtGui.QLabel(
            '''the latest layer %s has a different shape than the other layers:
        %s != %s
        How would you like to proceed?''' % (layerlabel, shape1, shape2))
        btnR = QtGui.QPushButton("Resize")
        btnR.clicked.connect(
            lambda: [self.__setattr__('opt', self.optResize),
                     self.close()])
        btnR.setToolTip(
            'Resize the new image to fit the shape of the existent ones.')
        btnC = QtGui.QPushButton("Cut")
        btnC.clicked.connect(
            lambda: [self.__setattr__('opt', self.optCut),
                     self.close()])
        btnC.setToolTip(
            'Cut the new image to fit the shape of the existent ones.')

        btnW = QtGui.QPushButton("Warp")
        btnW.clicked.connect(
            lambda: [self.__setattr__('opt', self.optWarp),
                     self.close()])
        btnW.setToolTip(
            '''To a perspective transformation fo fit the last image 
        with the new one using pattern recognition''')

        btnN = QtGui.QPushButton("New display")
        btnN.clicked.connect(
            lambda:
            [self.__setattr__('opt', self.optNewDisplay),
             self.close()])
        btnN.setToolTip('Put the new image in a new display.')

        lv = QtGui.QVBoxLayout()
        lh = QtGui.QHBoxLayout()

        lv.addWidget(labTxt)
        lv.addLayout(lh)

        lh.addWidget(btnR)
        lh.addWidget(btnC)
        lh.addWidget(btnW)
        lh.addWidget(btnN)

        self.setLayout(lv)
Esempio n. 3
0
    def __init__(self, statusbar):
        QtGui.QWidget.__init__(self)

        self.statusbar = statusbar

        layout = QtGui.QHBoxLayout()
        layout.setContentsMargins(0, 0, 0, 0)
        self.setLayout(layout)
        self.bar = QtGui.QProgressBar()
        self.cancel = QtGui.QPushButton('Cancel')
        self.label = QtGui.QLabel()
        layout.addWidget(self.label)
        layout.addWidget(self.bar)
        layout.addWidget(self.cancel)
        self.statusbar.addPermanentWidget(self, stretch=1)

        self.hide()
Esempio n. 4
0
    def __init__(self, import_pref, fnames):
        QtGui.QDialog.__init__(self)

        l = QtGui.QVBoxLayout()
        self.setLayout(l)

        p = self.pref = import_pref
        self.dial_pref = p.__class__(p.gui)
        p.updateSettings(self.dial_pref)

        l.addWidget(self.dial_pref)
        if len(fnames) > 1:
            self.setWindowTitle('Import %s File(s)' % len(fnames))
        else:
            self.setWindowTitle('Import File')

        self.setWindowFlags(QtCore.Qt.WindowStaysOnTopHint)

        self.btn_done = QtGui.QPushButton('Done')
        self.btn_done.clicked.connect(self.accept)
        l.addWidget(self.btn_done)
Esempio n. 5
0
    def start(self, filenames):
        self.filenames = filenames

        if self.preferences and self.forceSetup and self._firstTime:
            d = QtGui.QDialog()
            d.setWindowTitle('Import preferences')

            l = QtGui.QVBoxLayout()
            t = ParameterTree(self.preferences)
            b = QtGui.QPushButton('OK')
            b.clicked.connect(d.accept)

            l.addWidget(t)
            l.addWidget(b)

            d.setLayout(l)

            d.accepted.connect(self._start)
            d.exec_()
        else:
            self._start()
Esempio n. 6
0
    def __init__(self, parameters, function, xVals, plotItem):
        QtGui.QWidget.__init__(self)

        #make frame-less:
        self.setWindowFlags(QtCore.Qt.FramelessWindowHint
                            | QtCore.Qt.WindowStaysOnTopHint)
        #TODO:
        #         #go to current screen:
        #         d = QtGui.QApplication.desktop()
        #         n = d.screenNumber(self)
        #         self.setGeometry(d.screenGeometry(n))

        self.xVals = xVals
        self.plotItem = plotItem
        self.function = function

        layout = QtGui.QGridLayout()
        self.setLayout(layout)

        self.s = []  #all spinboxes

        for n, (name, value) in enumerate(parameters.items()):
            layout.addWidget(QtGui.QLabel(name), n, 0)
            s = QtGui.QDoubleSpinBox()
            s.setValue(value)
            s.setMaximum(1e6)
            s.setMinimum(-1e6)

            s.valueChanged.connect(self._valueChanged)
            layout.addWidget(s, n, 1)
            self.s.append(s)

        btn_done = QtGui.QPushButton('Done')
        btn_done.clicked.connect(self.done)
        layout.addWidget(btn_done, n + 1, 0, 1, 2)

        self._valueChanged()
Esempio n. 7
0
area.moveDock(d5, 'top', d2)     ## move d5 to top edge of d2


## Add widgets into each dock

## first dock gets save/restore buttons
w1 = pg.LayoutWidget()
label = QtGui.QLabel(""" -- DockArea Example -- 
This window has 6 Dock widgets in it. Each dock can be dragged
by its title bar to occupy a different space within the window 
but note that one dock has its title bar hidden). Additionally,
the borders between docks may be dragged to resize. Docks that are dragged on top
of one another are stacked in a tabbed layout. Double-click a dock title
bar to place it in its own window.
""")
saveBtn = QtGui.QPushButton('Save dock state')
restoreBtn = QtGui.QPushButton('Restore dock state')
restoreBtn.setEnabled(False)
w1.addWidget(label, row=0, col=0)
w1.addWidget(saveBtn, row=1, col=0)
w1.addWidget(restoreBtn, row=2, col=0)
d1.addWidget(w1)
state = None
def save():
    global state
    state = area.saveState()
    restoreBtn.setEnabled(True)
def load():
    global state
    area.restoreState(state)
saveBtn.clicked.connect(save)
Esempio n. 8
0
    def __init__(self, gui):
        QtGui.QWidget.__init__(self)

        self.gui = gui

        rab = self.rabbitMQServer = RabbitMQServer(gui)
        self._wf = wf = WatchFolder(gui)

        s = gui.app.session
        #CONNECT SAVE/RESTORE:
        s.sigSave.connect(self._save)
        s.sigRestore.connect(self._restore)
        #CONNECT CLOSE
        gui.app.lastWindowClosed.connect(rab.stop)

        #LAYOUT:
        layout = QtGui.QVBoxLayout()
        layout.setAlignment(QtCore.Qt.AlignTop)
        self.setLayout(layout)

        #WATCH FOLDER
        #############
        self.cb_watchFolder = QtGui.QCheckBox('Watch folder')
        self.cb_watchFolder.toggled.connect(self._watchFolderChanged)
        layout.addWidget(self.cb_watchFolder)

        self._folder_opts = QtGui.QWidget()
        layout.addWidget(self._folder_opts)
        gl = QtGui.QGridLayout()
        self._folder_opts.setLayout(gl)
        self._folder_opts.hide()

        self._wf_folderEdit = QtGui.QLineEdit('-')
        self._wf_folderEdit.setReadOnly(True)
        gl.addWidget(self._wf_folderEdit, 0, 0)
        btn = QtGui.QPushButton('Change')
        btn.clicked.connect(self._wf_folderChanged)
        gl.addWidget(btn, 0, 1)

        self._cb_filesOnly = QtGui.QCheckBox('Files only')
        self._cb_filesOnly.setChecked(wf.opts['files only'])
        self.cb_watchFolder.toggled.connect(
            lambda val: wf.opts.__setitem__('files only', val))
        gl.addWidget(self._cb_filesOnly, 1, 0)

        gl.addWidget(QtGui.QLabel('refreshrate [msec]'), 2, 0)
        self._wf_refRate = QtGui.QSpinBox()
        self._wf_refRate.setRange(1, 100000)
        self._wf_refRate.setValue(wf.opts['refreshrate'])
        self._wf_refRate.valueChanged.connect(self._wf_refRateChanged)
        gl.addWidget(self._wf_refRate, 2, 1)

        #RABBIT MQ
        ##########
        hlayout = QtGui.QHBoxLayout()
        layout.addLayout(hlayout)

        self.cb_allowRabbit = QtGui.QCheckBox(
            'Allow inter-process communication\nusing the RabbitMQ server')
        self.cb_allowRabbit.toggled.connect(self._allowRabbitMQchanged)
        hlayout.addWidget(self.cb_allowRabbit)

        self.cb_confirm = QtGui.QCheckBox('Confirm received messages')
        self.cb_confirm.hide()
        self.cb_confirm.setChecked(rab.opts['corfirmPosts'])
        self.cb_confirm.toggled.connect(
            lambda val: rab.opts.__setitem__('corfirmPosts', val))
        hlayout.addWidget(self.cb_confirm)

        self._rab_opts = QtGui.QWidget()
        layout.addWidget(self._rab_opts)
        gl = QtGui.QGridLayout()
        self._rab_opts.setLayout(gl)
        self._rab_opts.hide()

        gl.addWidget(QtGui.QLabel('refreshrate [msec]'), 0, 0)
        self._rab_refRate = QtGui.QSpinBox()
        self._rab_refRate.setRange(1, 1000)
        self._rab_refRate.setValue(rab.opts['refreshrate'])
        self._rab_refRate.valueChanged.connect(
            lambda val: rab.opts.__setitem__('refreshrate', val))
        gl.addWidget(self._rab_refRate, 0, 1)

        gl.addWidget(QtGui.QLabel('host'), 1, 0)
        self.le_host = QtGui.QLineEdit()
        self.le_host.setText(rab.opts['host'])
        self.le_host.textChanged.connect(
            lambda val: rab.opts.__setitem__('host', val))
        gl.addWidget(self.le_host, 1, 1)

        gl.addWidget(QtGui.QLabel('timeout [msec]'), 2, 0)
        self.sb_timeout = QtGui.QSpinBox()
        self.sb_timeout.setRange(0, 1000)
        self.sb_timeout.setValue(rab.opts['timeout'])
        self.sb_timeout.valueChanged.connect(
            lambda val: rab.opts.__setitem__('timeout', val))
        gl.addWidget(self.sb_timeout, 2, 1)

        gl.addWidget(QtGui.QLabel('<b>....listen to queues named:</b>'), 3, 0)
        for n, (queue, action) in enumerate(rab.listenTo.iteritems()):
            gl.addWidget(QtGui.QLabel(queue), 4 + n, 0)
            gl.addWidget(QtGui.QLabel(action.__doc__), 4 + n, 1)
Esempio n. 9
0
    def __init__(self, imageDisplay):
        Tool.__init__(self, imageDisplay)

        self.calFileTool = self.showGlobalTool(CalibrationFile)

        self.camera = None
        self.cItem = None
        self.key = None
        
        self._rois = []
        self._roi = None
                
        pa = self.setParameterMenu() 
        
        btn = QtGui.QPushButton('Show Patterns')
        btn.clicked.connect(lambda: os.startfile(PATTERN_FILE) )
        btn.setFlat(True)
        self._menu.content.header.insertWidget(2, btn)

        self.pLive = pa.addChild({
            'name':'Live',
            'type':'bool',
            'value':False,
            'tip':"""'False': Images are taken from stack
True: Images are taken every time the first layer is updated 
      choose this if you use a webcam"""})
        
        self.pLiveStopAfter = self.pLive.addChild({
            'name':'Stop after n images',
            'type':'int',
            'value':20,
            'limits':[0,10000]})
        
        self.pLiveActivateTrigger = self.pLive.addChild({
            'name':"Manual trigger",
            'type':'bool',
            'value':True})
        
        self.pLiveTrigger = self.pLiveActivateTrigger.addChild({
            'name':"Trigger or KEY [+]",
            'type':'action',
            'visible':False})

        self.pLive.sigValueChanged.connect(
            #show/hide children
            lambda param, value: [ch.show(value) for ch in param.children()])
        self.pLive.sigValueChanged.emit(self.pLive, self.pLive.value())
        
        self.pMethod = pa.addChild({
            'name':'Method',
            'type':'list',
            'limits':['Chessboard', 'Symmetric circles', 'Asymmetric circles',
                      'Manual']})
        self.pMethod.sigValueChanged.connect(self._pMethodChanged)

        self.pFit = self.pMethod.addChild({
            'name':'Fit to corners',
            'type':'action',
            'visible':False,
            'tip': '''Fit grid to given corner positions'''}) 
        self.pFit.sigActivated.connect(self._pChebXYChanged)
        
        self.pChessbX = self.pMethod.addChild({
            'name':'N corners X',
            'type':'int',
            'value':6,
            'tip': '''Depending on used pattern, number of corners/circles in X''',
            'limits':[3,100]}) 
        self.pChessbX.sigValueChanged.connect(self._pChebXYChanged)
        
        self.pChessbY = self.pMethod.addChild({
            'name':'N corners Y',
            'type':'int',
            'value':8,
            'tip': '''Depending on used pattern, number of corners/circles in Y''',
            'limits':[3,100]})
        self.pChessbY.sigValueChanged.connect(self._pChebXYChanged)
        
        
        pApSize = pa.addChild({
            'name':'Aperture Size [mm]',
            'type':'group',
            'tip':'Physical size of the sensor'})
        
        self.pApertureX = pApSize.addChild({
            'name':'Size X',
            'type':'float',
            'value':4,
            'tip':'Physical width of the sensor'}) 
        
        self.pApertureY = pApSize.addChild({
            'name':'Size Y',
            'type':'float',
            'value':3,
            'tip':'Physical height of the sensor'})
        
        self.pDrawChessboard = pa.addChild({
            'name': 'Draw Chessboard',
            'type': 'bool',
            'value': False}) 

        self.pDisplacement  = pa.addChild({
            'name':'Return spatial uncertainty',
            'type':'bool',
            'value':False})

        self.pUpdate = pa.addChild({
                    'name':'Update calibration',
                    'type':'action',
                    'visible':False})
        self.pUpdate.sigActivated.connect(self.updateCalibration)

        self.pCorrect = pa.addChild({
                    'name':'Undistort',
                    'type':'action',
                    'visible':False})
        self.pCorrect.sigActivated.connect(self.correct)
Esempio n. 10
0
    def __init__(self, display, splitter):
        QtGui.QWidget.__init__(self)

        self.display = display
        display.sigLayerChanged.connect(self.toggleDataChanged)
        display.sigNewLayer.connect(self.toggleNewData)

        self.splitter = splitter

        refreshR = 20

        self._collect = False
        self._activeWidgets = []
        #BUTTON: OF/OFF
        self.btn_show = QtGui.QRadioButton('Console')
        f = self.btn_show.font()
        f.setBold(True)
        self.btn_show.setFont(f)
        self.btn_show.clicked.connect(self._toggleShow)
        #COMBOBOX: IMPORT
        self.combo_import = QtGui.QComboBox()
        self.combo_import.addItems(('<import>', 'from file'))
        self.combo_import.addItems(
            #don't show '.py' and hide __init__.py
            [
                x[:-3] for x in SPRIPT_PATH.listdir()
                if (x[0] != '_' and x.endswith('.py'))
            ])
        self.combo_import.currentIndexChanged.connect(self._importScript)
        #BUTTON: COLLECT
        self.btn_collect = QtGui.QPushButton('Collect')
        self.btn_collect.setToolTip(
            'click on all tool parameters you want to change during the batch process'
        )
        self.btn_collect.setCheckable(True)
        self.btn_collect.clicked.connect(self.collectWidgets)
        #TABWIDGET: SCRIPT
        self.tabs = FwTabWidget()
        self.tabs.hide()
        self.tabs.setTabsAddable(True)
        self.tabs.setTabsClosable(True)
        self.tabs.setTabsRenamable(True)

        self.tabs.defaultTabWidget = lambda: ScriptTab(self, refreshR)
        self.tabs.addEmptyTab('New')
        #BUTTON: RUN AT NEW INPUT
        self.label_run_on = QtGui.QLabel('Activate on')
        self.cb_run_on = QtGui.QComboBox()
        self.cb_run_on.addItems(['-', 'New Data', 'Data Changed'])

        #SPINBOX REFRESHRATE
        self.label_refresh = QtGui.QLabel('Refresh rate:')
        self.sb_refreshrate = QtGui.QSpinBox()
        self.sb_refreshrate.setSuffix(" Hz")
        self.sb_refreshrate.setMinimum(0)
        self.sb_refreshrate.setMaximum(100)
        self.sb_refreshrate.setValue(refreshR)
        self.sb_refreshrate.valueChanged.connect(
            lambda hz: self.tabs.currentWidget().thread.setRefreshrate(hz))
        #BUTTON: RUN
        self.btn_run_now = QtGui.QPushButton('Run')
        self.btn_run_now.setCheckable(True)
        self.btn_run_now.clicked.connect(self.toggle)
        #LAYOUT
        layout = QtGui.QVBoxLayout()
        layout.setAlignment(QtCore.Qt.AlignTop)
        layout.setMargin(0)
        self.setLayout(layout)
        #top layout
        hl = QtGui.QHBoxLayout()
        hl.addWidget(self.btn_show)
        hl.addWidget(self.btn_collect)
        #fill layout
        layout.addLayout(hl)
        layout.addWidget(self.combo_import)
        layout.addWidget(self.tabs)

        hl2 = QtGui.QHBoxLayout()
        hl2.addWidget(self.label_run_on)
        hl2.addWidget(self.cb_run_on)
        hl2.addWidget(self.label_refresh)
        hl2.addWidget(self.sb_refreshrate)
        hl2.insertStretch(1, 0)
        hl2.insertStretch(2, 0)
        layout.addLayout(hl2)
        layout.addWidget(self.btn_run_now)

        self._toggleShow(False)  #automation disabled by default