Ejemplo n.º 1
0
 def centerAndResize(self):
     """Centre et redimmensionne le widget.""" 
     screen = QDesktopWidget().screenGeometry()
     self.resize(screen.width() / 1.6, screen.height() / 1.4)
     size = self.geometry()
     self.move(
         (screen.width() - size.width()) / 2,
         (screen.height() - size.height()) / 2)
Ejemplo n.º 2
0
def getMarginalWindowSize(self, marginRatio):
    rectangle = QDesktopWidget().availableGeometry()
    upperTape = self.app.style().pixelMetric(QStyle.PM_TitleBarHeight)
    edge = self.app.style().pixelMetric(QStyle.PM_MdiSubWindowFrameWidth)
    margin = int(rectangle.height() * marginRatio)
    rectangle.adjust(margin + edge, upperTape,
                     -(margin + edge), -edge)
    return rectangle
Ejemplo n.º 3
0
 def centerAndResize(self):
     """Set up reasonable dimensions for our main window."""
     screen = QDesktopWidget().screenGeometry()
     self.resize(screen.width() / 1.2, screen.height() / 1.2)
     size = self.geometry()
     self.move(
         (screen.width() - size.width()) / 2,
         (screen.height() - size.height()) / 2)
Ejemplo n.º 4
0
    def __init__(self,parent):
        global dao
        super(EditDeliverySlipDialog,self).__init__(parent)

        title = _("Create delivery slip")
        self.setWindowTitle(title)

        top_layout = QVBoxLayout()
        self.title_widget = TitleWidget(title,self)
        top_layout.addWidget(self.title_widget)

        self.info_label = QLabel()
        self.info_label.setWordWrap(True)
        top_layout.addWidget(self.info_label)

        self.buttons = QDialogButtonBox()
        self.buttons.addButton( QDialogButtonBox.StandardButton.Cancel)
        self.buttons.addButton( QDialogButtonBox.Ok)

        order_part_prototype = []
        order_part_prototype.append( TextLinePrototype('human_identifier',_('Part n.'),editable=False))
        order_part_prototype.append( TextLinePrototype('description',_('Description'),editable=False))
        order_part_prototype.append( IntegerNumberPrototype('qty',_('Qty plan.'),editable=False))
        order_part_prototype.append( IntegerNumberPrototype('tex2',_('Qty so far'),editable=False))
        order_part_prototype.append( IntegerNumberPrototype(None,_('Qty out now'),nullable=True))
        self.qty_out_column = len(order_part_prototype) - 1

        # order_part_prototype.append( IntegerNumberPrototype(None,_('Reglages'),nullable=True))
        # order_part_prototype.append( IntegerNumberPrototype(None,_('Derogation'),nullable=True))
        # order_part_prototype.append( IntegerNumberPrototype(None,_('Rebus'),nullable=True))


        self.controller_part = PrototypeController(self, order_part_prototype,None,freeze_row_count=True)
        self.controller_part.view.horizontalHeader().setResizeMode(QHeaderView.ResizeToContents)
        self.controller_part.view.horizontalHeader().setResizeMode(1,QHeaderView.Stretch)


        self.controller_part.setModel(TrackingProxyModel(self,order_part_prototype))
        self.close_order_checkbox = QCheckBox(_("Close the order"))

        top_layout.addWidget(self.controller_part.view) # self.time_tracks_view)
        # top_layout.addWidget(self._make_units_qaulifications_gui())
        top_layout.addWidget(self.close_order_checkbox)
        top_layout.addWidget(self.buttons)
        self.setLayout(top_layout)

        self.buttons.accepted.connect(self.accept)
        self.buttons.rejected.connect(self.reject)

        sg = QDesktopWidget().screenGeometry()
        self.setMinimumWidth(0.5*sg.width())
        self.setMinimumHeight(0.3*sg.height())

        self.slip_id = None
    def __init__(self, parent=None):
        QDialog.__init__(self, parent)
        self.ui = Ui_SubscriberDialog()
        self.ui.setupUi(self)

        self.subscriber = None
        self.tableWidget = None
        self.listWidget = None

        if USE_MAEMO_5:
            switchButton = self.ui.buttonBox.addButton(
                self.tr('Switch'), QDialogButtonBox.ActionRole)
            switchButton.clicked.connect(self.switchRequested)

            self.tableWidget = self.ui.tableWidget
            headerLabels = ('Key', 'Value', 'Type')
            self.tableWidget.setColumnCount(3)
            self.tableWidget.setHorizontalHeaderLabels(headerLabels)
            horizontalHeader = self.tableWidget.horizontalHeader()
            horizontalHeader.setStretchLastSection(True)
            verticalHeader = self.tableWidget.verticalHeader()
            verticalHeader.setVisible(False)
            self.tableWidget.setColumnWidth(0, 200)
            self.tableWidget.setColumnWidth(1, 400)
        else:
            desktopWidget = QDesktopWidget()
            if desktopWidget.availableGeometry().width() < 400:
                # Screen is too small to fit a table widget without scrolling, use a list widget instead.
                self.listWidget = QListWidget()
                self.listWidget.setAlternatingRowColors(True)
                self.ui.verticalLayout.insertWidget(2, self.listWidget)
            else:
                self.tableWidget = QTableWidget()
                headerLabels = ('Key', 'Value', 'Type')
                self.tableWidget.setColumnCount(3)
                self.tableWidget.setHorizontalHeaderLabels(headerLabels)
                horizontalHeader = self.tableWidget.horizontalHeader()
                horizontalHeader.setStretchLastSection(True)
                self.tableWidget.verticalHeader()
                self.setVisible(False)
                self.ui.verticalLayout.insertWidget(2, self.tableWidget)

        self.ui.connectButton.clicked.connect(self.changeSubscriberPath)
        self.changeSubscriberPath()

        # if the default path does not exist reset it to /
        value = self.subscriber.value()
        subPaths = self.subscriber.subPaths()
        if not value and not subPaths:
            self.ui.basePath.setText('/')
            self.changeSubscriberPath()
Ejemplo n.º 6
0
    def __init__(self, parent=None):
        QDialog.__init__(self, parent)
        self.ui = Ui_SubscriberDialog()
        self.ui.setupUi(self)

        self.subscriber = None
        self.tableWidget = None
        self.listWidget = None

        if USE_MAEMO_5:
            switchButton = self.ui.buttonBox.addButton(self.tr('Switch'), QDialogButtonBox.ActionRole)
            switchButton.clicked.connect(self.switchRequested)

            self.tableWidget = self.ui.tableWidget
            headerLabels = ('Key', 'Value', 'Type')
            self.tableWidget.setColumnCount(3)
            self.tableWidget.setHorizontalHeaderLabels(headerLabels)
            horizontalHeader = self.tableWidget.horizontalHeader()
            horizontalHeader.setStretchLastSection(True)
            verticalHeader = self.tableWidget.verticalHeader()
            verticalHeader.setVisible(False)
            self.tableWidget.setColumnWidth(0, 200)
            self.tableWidget.setColumnWidth(1, 400)
        else:
            desktopWidget = QDesktopWidget()
            if desktopWidget.availableGeometry().width() < 400:
                # Screen is too small to fit a table widget without scrolling, use a list widget instead.
                self.listWidget = QListWidget()
                self.listWidget.setAlternatingRowColors(True)
                self.ui.verticalLayout.insertWidget(2, self.listWidget)
            else:
                self.tableWidget = QTableWidget()
                headerLabels = ('Key', 'Value', 'Type')
                self.tableWidget.setColumnCount(3)
                self.tableWidget.setHorizontalHeaderLabels(headerLabels)
                horizontalHeader = self.tableWidget.horizontalHeader()
                horizontalHeader.setStretchLastSection(True)
                self.tableWidget.verticalHeader()
                self.setVisible(False)
                self.ui.verticalLayout.insertWidget(2, self.tableWidget)

        self.ui.connectButton.clicked.connect(self.changeSubscriberPath)
        self.changeSubscriberPath()

        # if the default path does not exist reset it to /
        value = self.subscriber.value()
        subPaths = self.subscriber.subPaths()
        if not value and not subPaths:
            self.ui.basePath.setText('/')
            self.changeSubscriberPath()
Ejemplo n.º 7
0
	def __init__(self, parent = None):
		# Initialize the constructor
		super(MainWindow, self).__init__(parent)

		# Show the application in fullscreen
		self.showFullScreen()
		
		# Setting the frames to be full screen
		desktop = QDesktopWidget()
		width = desktop.geometry().width()
		height = desktop.geometry().height()
		
		self.openglScreen = OpenglScreen(width, height)
		self.setCentralWidget(self.openglScreen)
Ejemplo n.º 8
0
 def center(self):
     """ Function to center the application
 """
     qRect = self.frameGeometry()
     centerPoint = QDesktopWidget().availableGeometry().center()
     qRect.moveCenter(centerPoint)
     self.move(qRect.topLeft())
Ejemplo n.º 9
0
 def center(self):
     """ Function to center the application
     """
     qRect = self.frameGeometry()
     centerPoint = QDesktopWidget().availableGeometry().center()
     # First move the rectangle
     qRect.moveCenter(centerPoint)
     # move my window to the moved rectangle.
     self.move(qRect.topLeft())
Ejemplo n.º 10
0
    def __init__(self, parent=None):
        super(MainWindow, self).__init__(parent)

        #widnow setup
        resolution = QDesktopWidget().screenGeometry()
        self.screen_w = resolution.width()
        self.screen_h = resolution.height()
        self.setGeometry(0, 0, 650, 200)
        self.setWindowTitle('bento dumper' + mof.get_version_suffix())
        self.setWindowIcon(QIcon('icons/run.png'))

        #center window
        qr = self.frameGeometry()
        cp = QtGui.QDesktopWidget().availableGeometry().center()
        qr.moveCenter(cp)
        self.move(qr.topLeft())
        #adjust size
        self.resize(self.screen_w / 2, self.screen_h / 16)
        self.Menu()
        self.Layout()

        central_widget = QtGui.QWidget()
        central_widget.setLayout(self.main_layout)
        self.setCentralWidget(central_widget)
Ejemplo n.º 11
0
    def __init__(self, parent=None):
        # Initialize the constructor
        super(MainWindow, self).__init__(parent)

        # Removes glances file - not needed
        if os.path.exists('GlancesNetclient.csv'):
            os.remove("GlancesNetclient.csv")

        # Define variables
        # Change to True to recreate post-drive screen
        self.summary = False

        self.initAll = False
        self.endDrive = False
        txtList = np.genfromtxt('largeSet.txt', dtype='str', delimiter='\n')
        ansList = np.genfromtxt('largeAnsSet.txt', dtype='int', delimiter='\n')
        # Creates the list of words with corresponding answer keys
        self.responseList = np.vstack((txtList, ansList)).T
        rnd = np.random.randint(0, self.responseList.shape[0] / 10)
        self.allList = self.responseList[rnd * 10:rnd * 10 + 10, :]

        self.counter = 0  # Defines the counter to go over list of phrases and answers
        self.response = np.nan  # Keeps track of the response
        self.trialNum = 0  # Keeps track of the trial number
        self.interact = 0  # Keeps track of the number of interactions

        # Set up the GUI
        self.setupUi(self)

        # Show the application in fullscreen
        self.showFullScreen()

        # Setting the frames to be full screen
        desktop = QDesktopWidget()
        width = desktop.geometry().width()
        height = desktop.geometry().height()

        # Create the graph object
        self.graph = Graph(width, height)

        # Hide all the frames except the initial
        self.introframe.show()
        self.readyframe.hide()
        self.feedbackframe.hide()
        self.gameframe.hide()
        self.endframe.hide()

        # Position and resize the frames.
        self.introframe.move(0, 0)
        self.introframe.resize(width, height)
        self.readyframe.move(0, 0)
        self.readyframe.resize(width, height)
        self.feedbackframe.move(0, 0)
        self.feedbackframe.resize(width, height)
        self.gameframe.move(0, 0)
        self.gameframe.resize(width, height)
        self.endframe.move(0, 0)
        self.endframe.resize(width, height)
        ''' BUTTONS '''
        # Button "DONE" on click
        QtCore.QObject.connect(self.btnDone, QtCore.SIGNAL("clicked()"),
                               self.showReadyFrame)
        # Moving UP/DOWN buttons
        QtCore.QObject.connect(self.btnUp, QtCore.SIGNAL("clicked()"),
                               self.moveUp)
        QtCore.QObject.connect(self.btnDown, QtCore.SIGNAL("clicked()"),
                               self.moveDown)
        self.btnUp.setEnabled(False)
        self.btnUp.setStyleSheet("QPushButton{background-color:#B0B0B0;}")
        # Selecting buttons
        QtCore.QObject.connect(self.btnLabelUp, QtCore.SIGNAL("clicked()"),
                               self.Uphighlight)
        QtCore.QObject.connect(self.btnLabelDown, QtCore.SIGNAL("clicked()"),
                               self.Downhighlight)
        # Button "SUBMIT" on click
        QtCore.QObject.connect(self.btnSubmit, QtCore.SIGNAL("clicked()"),
                               self.submitFun)
        # Button "START" on click
        QtCore.QObject.connect(self.btnStart, QtCore.SIGNAL("clicked()"),
                               self.showGameFrame)
        # Button "END" on click
        QtCore.QObject.connect(self.goButton, QtCore.SIGNAL("clicked()"),
                               self.showPostDrive)
Ejemplo n.º 12
0
class MainWindow(QMainWindow):
    def __init__(self, datta):
        QMainWindow.__init__(self)
        self.setWindowTitle('Project Parser')
        appIcon = QIcon('search.png')
        self.setWindowIcon(appIcon)
        self.viewPortBL = QDesktopWidget().availableGeometry().topLeft()
        self.viewPortTR = QDesktopWidget().availableGeometry().bottomRight()
        self.margin = int(QDesktopWidget().availableGeometry().width()*0.1/2)
        self.shirina = QDesktopWidget().availableGeometry().width() - self.margin*2
        self.visota = QDesktopWidget().availableGeometry().height() - self.margin*2
        self.setGeometry(self.viewPortBL.x() + self.margin, self.viewPortBL.y() + self.margin,
                         self.shirina, self.visota)
        # statusbar
        self.myStatusBar = QStatusBar()
        self.setStatusBar(self.myStatusBar)
        
        #lower long layout
        self.lowerLong = QFrame()
        self.detailsLabel = QLabel()
        self.skillsLabel = QLabel()
        self.urlLabel = QLabel()
        self.locationLabel = QLabel()
        self.skillsLabel.setText('skills')
        self.detailsLabel.setWordWrap(True)
        self.la = QVBoxLayout()
        self.la.addWidget(self.detailsLabel)
        self.la.addWidget(self.skillsLabel)
        self.la.addWidget(self.urlLabel)
        self.la.addWidget(self.locationLabel)
        self.lowerLong.setLayout(self.la)

        # table
        self.source_model = MyTableModel(self, datta, ['Id', 'Date', 'Title'])
        self.proxy_model = myTableProxy(self)
        self.proxy_model.setSourceModel(self.source_model)
        self.proxy_model.setDynamicSortFilter(True)
        self.table_view = QTableView()
        self.table_view.setModel(self.proxy_model)
        self.table_view.setAlternatingRowColors(True)
        self.table_view.resizeColumnsToContents()
        self.table_view.resizeRowsToContents()
        self.table_view.horizontalHeader().setStretchLastSection(True)
        self.table_view.setSortingEnabled(True)
        self.table_view.sortByColumn(2, Qt.AscendingOrder)

        # events
        self.selection = self.table_view.selectionModel()
        self.selection.selectionChanged.connect(self.handleSelectionChanged)
        #DO NOT use CreateIndex() method, use index()
        index = self.proxy_model.index(0,0)
        self.selection.select(index, QItemSelectionModel.Select)
        
        self.upperLong = self.table_view  

        # right side widgets
        self.right = QFrame()
        self.la1 = QVBoxLayout()
        self.btnDownload = QPushButton('Download data')
        self.btnDownload.clicked.connect(self.download)
        self.myButton = QPushButton('Show Skillls')
        self.myButton.clicked.connect(self.showAllSkills)
        self.btnSearchByWord = QPushButton('Search by word(s)')
        self.btnSearchByWord.clicked.connect(self.onSearchByWord)
        self.btnResetFilter= QPushButton('Discard Filter')
        self.btnResetFilter.clicked.connect(self.discardFilter)
        self.btnCopyURL = QPushButton('URL to Clipboard')
        self.btnCopyURL.clicked.connect(self.copyToClipboard)
        self.btnExit = QPushButton('Exit')
        self.btnExit.clicked.connect(lambda: sys.exit())
        self.dateTimeStamp = QLabel()
        self.la1.addWidget(self.btnDownload)
        self.la1.addSpacing(10)
        self.la1.addWidget(self.myButton)
        self.la1.addSpacing(10)
        self.la1.addWidget(self.btnSearchByWord)
        self.la1.addSpacing(10)
        self.la1.addWidget(self.btnResetFilter)
        self.la1.addSpacing(10)
        self.la1.addWidget(self.btnCopyURL)
        self.la1.addSpacing(70)
        self.la1.addWidget(self.btnExit)
        self.la1.addStretch(stretch=0)
        self.la1.addWidget(self.dateTimeStamp)
        self.right.setLayout(self.la1)
        self.right.setFrameShape(QFrame.StyledPanel)

        # splitters
        self.horiSplit = QSplitter(Qt.Vertical)
        self.horiSplit.addWidget(self.upperLong)
        self.horiSplit.addWidget(self.lowerLong)
        self.horiSplit.setSizes([self.visota/2, self.visota/2])
        self.vertiSplit = QSplitter(Qt.Horizontal)
        self.vertiSplit.addWidget(self.horiSplit)
        self.vertiSplit.addWidget(self.right)
        self.vertiSplit.setSizes([self.shirina*3/4, self.shirina*1/4])
        self.setCentralWidget(self.vertiSplit)
        
        self.settings = QSettings('elance.ini', QSettings.IniFormat)
        self.settings.beginGroup('DATE_STAMP')
        self.dateTimeStamp.setText('Data actuality: %s' % self.settings.value('date/time'))
        self.settings.endGroup()
        self.statusText = ''

    def handleSelectionChanged(self, selected, deselected):
        for index in selected.first().indexes():
            #print('Row %d is selected' % index.row())
            ind = index.model().mapToSource(index)
            desc = ind.model().mylist[ind.row()]['Description']
            self.detailsLabel.setText(desc)
            skills = ', '.join(ind.model().mylist[ind.row()]['Skills']).strip()
            self.skillsLabel.setText(skills)
            url = ind.model().mylist[ind.row()]['URL']
            self.urlLabel.setText(url)
            location = ind.model().mylist[ind.row()]['Location']
            self.locationLabel.setText(location)
    
    def showAllSkills(self):
        listSkills = []
        for elem in self.source_model.mylist:
            listSkills += elem['Skills']
        allSkills = Counter(listSkills)
        tbl = MyTableModel(self, allSkills.items(), ['Skill', 'Freq'])
        win = skillsWindow(tbl, self.table_view)
        win.exec_()
    
    def discardFilter(self):
        self.table_view.model().emit(SIGNAL("modelAboutToBeReset()"))
        self.table_view.model().criteria = {}
        self.table_view.model().emit(SIGNAL("modelReset()"))
        self.table_view.resizeRowsToContents()
        
    def download(self):
        self.btnDownload.setDisabled(True)
        self.statusLabel = QLabel('Connecting')
        self.progressBar = QProgressBar()
        self.progressBar.setMinimum(0)
        self.progressBar.setMaximum(100)
        self.myStatusBar.addWidget(self.statusLabel, 2)
        self.myStatusBar.addWidget(self.progressBar, 1)
        self.progressBar.setValue(1)
        self.settings.beginGroup('URLS')
        initialLink = self.settings.value('CategoriesDetailed/VahaSelected/InitialLink')
        pagingLink = self.settings.value('CategoriesDetailed/VahaSelected/PagingLink')
        self.settings.endGroup()
        downloader = Downloader(initialLink, pagingLink, 25, 5)
        downloader.messenger.downloadProgressChanged.connect(self.onDownloadProgressChanged)
        downloader.messenger.downloadComplete.connect(self.onDownloadComplete)
        downloader.download()
    
    def onDownloadComplete(self):
        #QMessageBox.information(self, 'Download complete', 'Download complete!', QMessageBox.Ok)
        self.table_view.model().emit(SIGNAL("modelAboutToBeReset()"))
        self.settings.beginGroup('DATE_STAMP')
        self.settings.setValue('date/time', time.strftime('%d-%b-%Y, %H:%M:%S'))
        self.dateTimeStamp.setText('Data actuality: %s' % self.settings.value('date/time'))
        self.settings.endGroup()
        with open("elance.json") as json_file:
            jobDB = json.load(json_file)
        for elem in jobDB:
            words = nltk.tokenize.regexp_tokenize(elem['Title'].lower(), r'\w+')
            elem['Tokens'] = words
            elem['Skills'] = [t.strip() for t in elem['Skills'].split(',')]
        self.source_model.mylist = jobDB
        self.table_view.model().emit(SIGNAL("modelReset()"))
        self.btnDownload.setEnabled(True)
        self.myStatusBar.removeWidget(self.statusLabel)
        self.myStatusBar.removeWidget(self.progressBar)
        self.myStatusBar.showMessage(self.statusText, timeout = 5000)
                
    
    def onDownloadProgressChanged(self, stata):
        self.progressBar.setValue(stata[2])
        #text = 'Processed records{:5d} of{:5d}'.format(percentage[0], percentage[1])
        bajtikov = '{:,}'.format(stata[5])
        self.statusText = 'Processed page{:4d} of{:4d}. \
               Job entries{:5d} of{:5d}. \
               Downloaded{:>12s} Bytes'.format(stata[3], stata[4],
                                              stata[0], stata[1],
                                              bajtikov)
        self.statusLabel.setText(self.statusText)
        
    def copyToClipboard(self):
        clipboard = QApplication.clipboard()
        clipboard.setText(self.urlLabel.text())
        self.myStatusBar.showMessage(self.urlLabel.text(), timeout = 3000)
    
    def onSearchByWord(self):
        text, ok = QInputDialog.getText(self, 'Search the base by word(s)', 'Enter your keyword/phrase to search for:')
        if ok:
            words = [t.strip() for t in nltk.tokenize.regexp_tokenize(text.lower(), r'\w+')]
            self.table_view.model().emit(SIGNAL("modelAboutToBeReset()"))
            self.table_view.model().criteria = {'Description' : words}
            self.table_view.model().emit(SIGNAL("modelReset()"))
Ejemplo n.º 13
0
 def scale(self):
     """Scale widget to screen"""
     resolution = QDesktopWidget().screenGeometry()
     self.resize(resolution.width() / 2, resolution.height() / 6)
Ejemplo n.º 14
0
 def position(self):
     """By default, position on top, centered"""
     resolution = QDesktopWidget().screenGeometry()
     self.move((resolution.width() - self.frameSize().width()) / 2,
               resolution.height() - self.frameSize().height() / 2)
Ejemplo n.º 15
0
 def center(self):
     qrect = self.frameGeometry()
     cp = QDesktopWidget().availableGeometry().center()
     qrect.moveCenter(cp)
     self.move(qrect.topLeft())
Ejemplo n.º 16
0
 def center(self):  
     screen = QDesktopWidget().screenGeometry()  
     size = self.geometry()  
     self.move((screen.width() - size.width()) / 2,
         (screen.height() - size.height()) / 2)  
Ejemplo n.º 17
0
    def __init__(self, datta):
        QMainWindow.__init__(self)
        self.setWindowTitle('Project Parser')
        appIcon = QIcon('search.png')
        self.setWindowIcon(appIcon)
        self.viewPortBL = QDesktopWidget().availableGeometry().topLeft()
        self.viewPortTR = QDesktopWidget().availableGeometry().bottomRight()
        self.margin = int(QDesktopWidget().availableGeometry().width()*0.1/2)
        self.shirina = QDesktopWidget().availableGeometry().width() - self.margin*2
        self.visota = QDesktopWidget().availableGeometry().height() - self.margin*2
        self.setGeometry(self.viewPortBL.x() + self.margin, self.viewPortBL.y() + self.margin,
                         self.shirina, self.visota)
        # statusbar
        self.myStatusBar = QStatusBar()
        self.setStatusBar(self.myStatusBar)
        
        #lower long layout
        self.lowerLong = QFrame()
        self.detailsLabel = QLabel()
        self.skillsLabel = QLabel()
        self.urlLabel = QLabel()
        self.locationLabel = QLabel()
        self.skillsLabel.setText('skills')
        self.detailsLabel.setWordWrap(True)
        self.la = QVBoxLayout()
        self.la.addWidget(self.detailsLabel)
        self.la.addWidget(self.skillsLabel)
        self.la.addWidget(self.urlLabel)
        self.la.addWidget(self.locationLabel)
        self.lowerLong.setLayout(self.la)

        # table
        self.source_model = MyTableModel(self, datta, ['Id', 'Date', 'Title'])
        self.proxy_model = myTableProxy(self)
        self.proxy_model.setSourceModel(self.source_model)
        self.proxy_model.setDynamicSortFilter(True)
        self.table_view = QTableView()
        self.table_view.setModel(self.proxy_model)
        self.table_view.setAlternatingRowColors(True)
        self.table_view.resizeColumnsToContents()
        self.table_view.resizeRowsToContents()
        self.table_view.horizontalHeader().setStretchLastSection(True)
        self.table_view.setSortingEnabled(True)
        self.table_view.sortByColumn(2, Qt.AscendingOrder)

        # events
        self.selection = self.table_view.selectionModel()
        self.selection.selectionChanged.connect(self.handleSelectionChanged)
        #DO NOT use CreateIndex() method, use index()
        index = self.proxy_model.index(0,0)
        self.selection.select(index, QItemSelectionModel.Select)
        
        self.upperLong = self.table_view  

        # right side widgets
        self.right = QFrame()
        self.la1 = QVBoxLayout()
        self.btnDownload = QPushButton('Download data')
        self.btnDownload.clicked.connect(self.download)
        self.myButton = QPushButton('Show Skillls')
        self.myButton.clicked.connect(self.showAllSkills)
        self.btnSearchByWord = QPushButton('Search by word(s)')
        self.btnSearchByWord.clicked.connect(self.onSearchByWord)
        self.btnResetFilter= QPushButton('Discard Filter')
        self.btnResetFilter.clicked.connect(self.discardFilter)
        self.btnCopyURL = QPushButton('URL to Clipboard')
        self.btnCopyURL.clicked.connect(self.copyToClipboard)
        self.btnExit = QPushButton('Exit')
        self.btnExit.clicked.connect(lambda: sys.exit())
        self.dateTimeStamp = QLabel()
        self.la1.addWidget(self.btnDownload)
        self.la1.addSpacing(10)
        self.la1.addWidget(self.myButton)
        self.la1.addSpacing(10)
        self.la1.addWidget(self.btnSearchByWord)
        self.la1.addSpacing(10)
        self.la1.addWidget(self.btnResetFilter)
        self.la1.addSpacing(10)
        self.la1.addWidget(self.btnCopyURL)
        self.la1.addSpacing(70)
        self.la1.addWidget(self.btnExit)
        self.la1.addStretch(stretch=0)
        self.la1.addWidget(self.dateTimeStamp)
        self.right.setLayout(self.la1)
        self.right.setFrameShape(QFrame.StyledPanel)

        # splitters
        self.horiSplit = QSplitter(Qt.Vertical)
        self.horiSplit.addWidget(self.upperLong)
        self.horiSplit.addWidget(self.lowerLong)
        self.horiSplit.setSizes([self.visota/2, self.visota/2])
        self.vertiSplit = QSplitter(Qt.Horizontal)
        self.vertiSplit.addWidget(self.horiSplit)
        self.vertiSplit.addWidget(self.right)
        self.vertiSplit.setSizes([self.shirina*3/4, self.shirina*1/4])
        self.setCentralWidget(self.vertiSplit)
        
        self.settings = QSettings('elance.ini', QSettings.IniFormat)
        self.settings.beginGroup('DATE_STAMP')
        self.dateTimeStamp.setText('Data actuality: %s' % self.settings.value('date/time'))
        self.settings.endGroup()
        self.statusText = ''
Ejemplo n.º 18
0
 def position(self):
     """By default, position on top, centered"""
     resolution = QDesktopWidget().screenGeometry()
     self.move((resolution.width() - self.frameSize().width()) / 2,
               resolution.height() - self.frameSize().height() / 2)
Ejemplo n.º 19
0
 def position(self):
     screen = QDesktopWidget().screenGeometry()
     size = self.geometry()
     self.move((screen.width()-size.width()-5),screen.height()-size.height()-45)        
Ejemplo n.º 20
0
 def setup(self):
     
     self.dirty = False
     
     self.def_cfg = copy.deepcopy(self.config)
     self.config.update_from_user_file()
     self.base_cfg = copy.deepcopy(self.config)
     
     self.categories = QListWidget()
     #self.categories.setSizePolicy(QSizePolicy.Fixed,QSizePolicy.Expanding)
     self.settings = QStackedWidget()
     #self.categories.setSizePolicy(QSizePolicy.MinimumExpanding,QSizePolicy.Expanding)
     
     QObject.connect(self.categories, SIGNAL('itemSelectionChanged()'), self.category_selected)
     
     self.widget_list = {}
     for cat in self.config.get_categories():
         self.widget_list[cat] = {}
     longest_cat = 0
     for cat in self.config.get_categories():
         if len(cat) > longest_cat:
             longest_cat = len(cat)
         self.categories.addItem(cat)
         settings_layout = QGridLayout()
         r = 0
         c = 0
         for setting in self.config.get_settings(cat):
             info = self.config.get_setting(cat, setting, True)
             s = QWidget()
             s.setSizePolicy(QSizePolicy.Expanding,QSizePolicy.Fixed)
             sl = QVBoxLayout()
             label = QLabel()
             if info.has_key('alias'):
                 label.setText(info['alias'])
             else:
                 label.setText(setting)
             if info.has_key('about'):
                 label.setToolTip(info['about'])
             sl.addWidget(label)
             if info['type'] == constants.CT_LINEEDIT:
                 w = LineEdit(self, self.config,cat,setting,info)
             elif info['type'] == constants.CT_CHECKBOX:
                 w = CheckBox(self, self.config,cat,setting,info)
             elif info['type'] == constants.CT_SPINBOX:
                 w = SpinBox(self, self.config,cat,setting,info)
             elif info['type'] == constants.CT_DBLSPINBOX:
                 w = DoubleSpinBox(self, self.config,cat,setting,info)
             elif info['type'] == constants.CT_COMBO:
                 w = ComboBox(self, self.config,cat,setting,info)
             w.setSizePolicy(QSizePolicy.Expanding,QSizePolicy.Fixed)
             self.widget_list[cat][setting] = w
             sl.addWidget(w)
             s.setLayout(sl)
             c = self.config.config[cat].index(setting) % 2
             settings_layout.addWidget(s, r, c)
             if c == 1:
                 r += 1
         settings = QWidget()
         settings.setLayout(settings_layout)
         settings_scroller = QScrollArea()
         settings_scroller.setWidget(settings)
         settings_scroller.setWidgetResizable(True)
         self.settings.addWidget(settings_scroller)
         
     font = self.categories.font()
     fm = QFontMetrics(font)
     self.categories.setMaximumWidth(fm.widthChar('X')*(longest_cat+4))
     
     self.main = QWidget()
     self.main_layout = QVBoxLayout()
     
     self.config_layout = QHBoxLayout()
     self.config_layout.addWidget(self.categories)
     self.config_layout.addWidget(self.settings)
     
     self.mainButtons = QDialogButtonBox(QDialogButtonBox.RestoreDefaults | QDialogButtonBox.Reset | QDialogButtonBox.Apply)
     self.main_apply = self.mainButtons.button(QDialogButtonBox.StandardButton.Apply)
     self.main_reset = self.mainButtons.button(QDialogButtonBox.StandardButton.Reset)
     self.main_defaults = self.mainButtons.button(QDialogButtonBox.StandardButton.LastButton)
     QObject.connect(self.mainButtons, SIGNAL('clicked(QAbstractButton *)'), self.mainbutton_clicked)
     
     self.dirty_check()
     
     self.main_layout.addLayout(self.config_layout)
     self.main_layout.addWidget(self.mainButtons)
     
     self.main.setLayout(self.main_layout)
     
     self.setCentralWidget(self.main)
     self.setWindowTitle(self.title)
     self.setUnifiedTitleAndToolBarOnMac(True)
     
     self.categories.setCurrentItem(self.categories.item(0))
     
     self.menuBar = QMenuBar()
     self.filemenu = QMenu('&File')
     self.quitAction = QAction(self)
     self.quitAction.setText('&Quit')
     if platform.system() != 'Darwin':
         self.quitAction.setShortcut(QKeySequence(Qt.CTRL + Qt.Key_Q))
     QObject.connect(self.quitAction, SIGNAL('triggered()'), self.quitApp)
     self.filemenu.addAction(self.quitAction)
     self.menuBar.addMenu(self.filemenu)
     self.setMenuBar(self.menuBar)
     
     self.show()
     self.activateWindow()
     self.raise_()
     
     self.setMinimumWidth(self.geometry().width()*1.2)
     
     screen = QDesktopWidget().screenGeometry()
     size = self.geometry()
     self.move((screen.width()-size.width())/2, (screen.height()-size.height())/2)
Ejemplo n.º 21
0
class MainWindow(QMainWindow):
    start_acq = Signal(str)
    start_rec = Signal(str)
    collect_frame = Signal(object)
    collect_threshed = Signal(object)

    def __init__(self, parent=None):
        ''' sets up the whole main window '''

        #standard init
        super(MainWindow, self).__init__(parent)

        #set the window title
        self.setWindowTitle('Open Ephys Control GUI')

        self.window_height = 700
        self.window_width = 1100

        self.screen2 = QDesktopWidget().screenGeometry(0)
        self.move(
            self.screen2.left() +
            (self.screen2.width() - self.window_width) / 2.,
            self.screen2.top() +
            (self.screen2.height() - self.window_height) / 2.)

        self.get_info()
        self.noinfo = True

        while self.noinfo:
            loop = QEventLoop()
            QTimer.singleShot(500., loop.quit)
            loop.exec_()

        subprocess.Popen('start %s' % open_ephys_path, shell=True)

        self.collect_frame.connect(self.update_frame)
        self.collect_threshed.connect(self.update_threshed)
        self.acquiring = False
        self.recording = False

        self.video_height = self.window_height * .52
        self.video_width = self.window_width * .48

        self.resize(self.window_width, self.window_height)

        #create QTextEdit window 'terminal' for receiving stdout and stderr
        self.terminal = QTextEdit(self)
        #set the geometry
        self.terminal.setGeometry(
            QRect(self.window_width * .02,
                  self.window_height * .15 + self.video_height,
                  self.video_width * .96, 150))

        #make widgets
        self.setup_video_frames()
        self.setup_thresh_buttons()

        self.overlay = True

        #create thread and worker for video processing
        self.videoThread = QThread(self)
        self.videoThread.start()
        self.videoproc_worker = VideoWorker(self)
        self.videoproc_worker.moveToThread(self.videoThread)

        self.vt_file = None
        """""" """""" """""" """""" """""" """""" """""" """
        set up menus
        """ """""" """""" """""" """""" """""" """""" """"""

        #create a QMenuBar and set geometry
        self.menubar = QMenuBar(self)
        self.menubar.setGeometry(
            QRect(0, 0, self.window_width * .5, self.window_height * .03))
        #set the QMenuBar as menu bar for main window
        self.setMenuBar(self.menubar)

        #create a QStatusBar
        statusbar = QStatusBar(self)
        #set it as status bar for main window
        self.setStatusBar(statusbar)

        #create icon toolbar with default image
        iconToolBar = self.addToolBar("iconBar.png")

        #create a QAction for the acquire button
        self.action_Acq = QAction(self)
        #make it checkable
        self.action_Acq.setCheckable(True)
        #grab an icon for the button
        acq_icon = self.style().standardIcon(QStyle.SP_MediaPlay)
        #set the icon for the action
        self.action_Acq.setIcon(acq_icon)
        #when the button is pressed, call the Acquire function
        self.action_Acq.triggered.connect(self.Acquire)

        #create a QAction for the record button
        self.action_Record = QAction(self)
        #make it checkable
        self.action_Record.setCheckable(True)
        #grab an icon for the button
        record_icon = self.style().standardIcon(QStyle.SP_DialogYesButton)
        #set the icon for the action
        self.action_Record.setIcon(record_icon)
        #when the button is pressed, call advanced_settings function
        self.action_Record.triggered.connect(self.Record)

        #create QAction for stop button
        action_Stop = QAction(self)
        #grab close icon
        stop_icon = self.style().standardIcon(QStyle.SP_MediaStop)
        #set icon for action
        action_Stop.setIcon(stop_icon)
        #when button pressed, close window
        action_Stop.triggered.connect(self.Stop)

        #show tips for each action in the status bar
        self.action_Acq.setStatusTip("Start acquiring")
        self.action_Record.setStatusTip("Start recording")
        action_Stop.setStatusTip("Stop acquiring/recording")

        #add actions to icon toolbar
        iconToolBar.addAction(self.action_Acq)
        iconToolBar.addAction(self.action_Record)
        iconToolBar.addAction(action_Stop)

        #        self.sort_button = QPushButton('Sort Now',self)
        #        self.sort_button.setGeometry(QRect(self.window_width*.85,0,self.window_width*.15,self.window_height*.05))
        #        self.sort_button.clicked.connect(self.sort_now)

        #show the window if minimized by windows
        self.showMinimized()
        self.showNormal()
        """""" """""" """""" """""" """""" """""" """""" """""" """""" """""" ""
        """""" """""" """""" """""" """""" """""" """""" """""" """""" """""" ""

    #this function acts as a slot to accept 'message' signal
    @Slot(str)
    def print_message(self, message):
        ''' print stdout and stderr to terminal window '''

        #move terminal cursor to end
        self.terminal.moveCursor(QTextCursor.End)
        #write message to terminal
        self.terminal.insertPlainText(message)

    def setup_thresh_buttons(self):
        ''' set up buttons for overlay/clearing thresh view '''

        self.button_frame = QFrame(self)
        self.button_frame.setGeometry(
            QRect(self.window_width * .52,
                  self.window_height * .13 + self.video_height,
                  self.video_width * .98, 50))
        button_layout = QHBoxLayout()
        self.button_frame.setLayout(button_layout)
        self.clear_button = QPushButton('Clear')
        self.overlay_button = QPushButton('Overlay')
        button_layout.addWidget(self.clear_button)
        button_layout.addWidget(self.overlay_button)

        self.clear_button.setEnabled(False)
        self.clear_button.clicked.connect(self.clear_threshed)
        self.overlay_button.setEnabled(False)
        self.overlay_button.clicked.connect(self.overlay_threshed)

    def setup_video_frames(self):
        ''' set up spots for playing video frames '''

        filler_frame = np.zeros((360, 540, 3))
        filler_frame = qimage2ndarray.array2qimage(filler_frame)

        self.raw_frame = QFrame(self)
        self.raw_label = QLabel()
        self.raw_label.setText('raw')
        self.raw_frame.setGeometry(
            QRect(self.window_width * .01, self.window_height * .15,
                  self.video_width, self.video_height))
        self.raw_frame
        raw_layout = QVBoxLayout()
        self.raw_frame.setLayout(raw_layout)
        raw_layout.addWidget(self.raw_label)

        self.threshed_frame = QFrame(self)
        self.threshed_label = QLabel()
        self.threshed_label.setText('Threshed')
        self.threshed_frame.setGeometry(
            QRect(self.window_width * .51, self.window_height * .15,
                  self.video_width, self.video_height))
        threshed_layout = QVBoxLayout()
        self.threshed_frame.setLayout(threshed_layout)
        threshed_layout.addWidget(self.threshed_label)

        self.label_frame = QFrame(self)
        self.label_frame.setGeometry(
            QRect(self.window_width * .01, self.window_height * .11,
                  self.video_width * 2, 50))
        self.label_rawlabel = QLabel()
        self.label_rawlabel.setText('Raw Video')
        self.label_threshedlabel = QLabel()
        self.label_threshedlabel.setText('Threshold View')
        label_layout = QHBoxLayout()
        self.label_frame.setLayout(label_layout)
        label_layout.addWidget(self.label_rawlabel)
        label_layout.addWidget(self.label_threshedlabel)

        self.raw_label.setPixmap(QPixmap.fromImage(filler_frame))
        self.threshed_label.setPixmap(QPixmap.fromImage(filler_frame))

    def Acquire(self):

        if self.action_Acq.isChecked():

            self.vidbuffer = []

            if self.recording:

                while 1:
                    try:
                        self.sock.send('StopRecord')
                        self.sock.recv()
                    except:
                        continue
                    break

                self.recording = False

            else:
                #create and start a thread to transport a worker to later
                self.workerThread = QThread(self)
                self.workerThread.start()
                #create a worker object based on Worker class and move it to our
                #worker thread
                self.worker = Worker(self)
                self.worker.moveToThread(self.workerThread)

                try:
                    self.start_acq.disconnect()
                except:
                    pass

                while 1:
                    try:
                        self.sock.send('StartAcquisition')
                        self.sock.recv()
                    except:
                        continue
                    break

                self.acquiring = True
                self.start_acq.connect(self.worker.acquire)
                self.start_acq.emit('start!')

            self.action_Acq.setEnabled(False)
            self.action_Record.setChecked(False)
            self.action_Record.setEnabled(True)

            record_icon = self.style().standardIcon(QStyle.SP_DialogYesButton)
            #set the icon for the action
            self.action_Record.setIcon(record_icon)

    def Record(self):

        if self.action_Record.isChecked():

            if not self.acquiring:
                self.workerThread = QThread(self)
                self.workerThread.start()

                self.worker = Worker(self)
                self.worker.moveToThread(self.workerThread)

                try:
                    self.start_rec.disconnect()
                except:
                    pass

                while 1:
                    try:
                        self.sock.send('StartAcquisition')
                        self.sock.recv()
                    except:
                        continue
                    break

                while 1:
                    try:
                        self.sock.send('StartRecord')
                        self.sock.recv()
                    except:
                        continue
                    break

                self.vidbuffer = []
                self.start_rec.connect(self.worker.acquire)
                self.recording = True
                self.start_rec.emit('start!')

            else:

                while 1:
                    try:
                        self.sock.send('StartRecord')
                        self.sock.recv()
                    except:
                        continue
                    break

                self.vidbuffer = []
                self.recording = True

            record_icon = self.style().standardIcon(QStyle.SP_DialogNoButton)
            #set the icon for the action
            self.action_Record.setIcon(record_icon)
            self.action_Record.setEnabled(False)

            self.action_Acq.setChecked(False)
            self.action_Acq.setEnabled(True)

    def Stop(self):

        self.acquiring = False
        self.recording = False

        while 1:
            try:
                self.sock.send('isRecording')
                rec = self.sock.recv()
            except:
                continue
            break

        if rec == '1':
            while 1:
                try:
                    self.sock.send('StopRecord')
                    self.sock.recv()
                except:
                    continue
                break

            self.action_Record.setEnabled(True)
            self.action_Record.setChecked(False)

        while 1:
            try:
                self.sock.send('isAcquiring')
                acq = self.sock.recv_string()
            except:
                continue
            break

        if acq == '1':
            while 1:
                try:
                    self.sock.send('StopAcquisition')
                    self.sock.recv()
                except:
                    continue
                break

        self.action_Acq.setEnabled(True)
        self.action_Acq.setChecked(False)

        try:
            #open a csv file for saving tracking data
            with open(self.vt_file, 'a') as csvfile:
                #create a writer
                vidwriter = csv.writer(csvfile, dialect='excel-tab')
                #check if it's an empty file
                for row in self.vidbuffer:
                    vidwriter.writerow(row)

        except:
            pass

        record_icon = self.style().standardIcon(QStyle.SP_DialogYesButton)
        #set the icon for the action
        self.action_Record.setIcon(record_icon)

    def update_frame(self, image):
        self.raw_label.setPixmap(QPixmap.fromImage(image))

    def update_threshed(self, threshed_image):
        self.threshed_label.setPixmap(QPixmap.fromImage(threshed_image))

    def clear_threshed(self):
        self.green_frame = np.zeros_like(self.green_frame)
        self.red_frame = np.zeros_like(self.red_frame)

    def overlay_threshed(self):
        if self.overlay:
            self.overlay = False
        elif not self.overlay:
            self.overlay = True


#    def sort_now(self):
#
#        if self.recdir is not None:
#            os.chdir('./kilosort_control')
#            #create and show the main window
#            self.sort_frame = kilosort_control.sort_gui.MainWindow()
#            self.sort_frame.show()
#
#            #set up stream for stdout and stderr based on outputStream class
#            self.outputStream = kilosort_control.sort_gui.outputStream()
#            #when outputStream sends messages, connect to appropriate function for
#            #writing to terminal window
#            self.outputStream.message.connect(self.sort_frame.print_message)
#
#            #connect stdout and stderr to outputStream
#            sys.stdout = self.outputStream
#            sys.stderr = self.outputStream
#
#            self.sort_frame.run_now(self.recdir)
#
#            self.close()

    def get_info(self):

        self.info_window = QWidget()
        self.info_window.resize(400, 350)
        #set title
        self.info_window.setWindowTitle('Session Info')
        #give layout
        info_layout = QVBoxLayout(self.info_window)

        with open('info_fields.pickle', 'rb') as f:
            default_fields = pickle.load(f)
            f.close()

        #set label for pic_resolution setting
        experimenter_label = QLabel('Experimenter:')
        #make a QLineEdit box for displaying/editing settings
        experimenter = QComboBox(self.info_window)
        experimenter.setEditable(True)
        experimenter.addItems(default_fields['experimenter'])
        #add label and box to current window
        info_layout.addWidget(experimenter_label)
        info_layout.addWidget(experimenter)

        #set label for pic_resolution setting
        whose_animal_label = QLabel('Whose animal?')
        #make a QLineEdit box for displaying/editing settings
        whose_animal = QComboBox(self.info_window)
        whose_animal.setEditable(True)
        whose_animal.addItems(default_fields['whose_animal'])
        #add label and box to current window
        info_layout.addWidget(whose_animal_label)
        info_layout.addWidget(whose_animal)

        animal_number_label = QLabel('Animal number:')
        animal_number = QComboBox(self.info_window)
        animal_number.setEditable(True)
        animal_number.addItems(default_fields['animal_number'])
        info_layout.addWidget(animal_number_label)
        info_layout.addWidget(animal_number)

        session_number_label = QLabel('Session number:')
        session_number = QTextEdit(self.info_window)
        session_number.setText('1')
        info_layout.addWidget(session_number_label)
        info_layout.addWidget(session_number)

        session_type_label = QLabel('Session type:')
        session_type = QComboBox(self.info_window)
        session_type.setEditable(True)
        session_type.addItems(default_fields['session_type'])
        info_layout.addWidget(session_type_label)
        info_layout.addWidget(session_type)

        def save_info(self):

            info_fields = {}
            info_fields['experimenter'] = [
                experimenter.itemText(i) for i in range(experimenter.count())
            ]
            info_fields['whose_animal'] = [
                whose_animal.itemText(i) for i in range(whose_animal.count())
            ]
            info_fields['animal_number'] = [
                animal_number.itemText(i) for i in range(animal_number.count())
            ]
            info_fields['session_type'] = [
                session_type.itemText(i) for i in range(session_type.count())
            ]

            with open('info_fields.pickle', 'wb') as f:
                pickle.dump(info_fields, f, protocol=2)
                f.close()

            current_experimenter = str(experimenter.currentText())
            current_whose_animal = str(whose_animal.currentText())
            current_animal_number = str(animal_number.currentText())
            current_session_number = str(session_number.toPlainText())
            current_session_type = str(session_type.currentText())

            recdir = data_save_dir + current_whose_animal + '/' + current_animal_number

            if not os.path.exists(recdir):
                os.makedirs(recdir)

            self.experiment_info = '###### Experiment Info ######\r\n'
            self.experiment_info += 'Experimenter: %s\r\n' % current_experimenter
            self.experiment_info += 'Whose animal? %s\r\n' % current_whose_animal
            self.experiment_info += 'Animal number: %s\r\n' % current_animal_number
            self.experiment_info += 'Session number: %s\r\n' % current_session_number
            self.experiment_info += 'Session type: %s\r\n' % current_session_type

            self.experiment_info = self.experiment_info.encode()

            config_file = config_path + '/' + current_animal_number + '.xml'

            if not os.path.exists(config_file):
                shutil.copy(default_config, config_file)

            tree = et.parse(config_file)
            root = tree.getroot()
            for child in root:
                if child.tag == 'CONTROLPANEL':
                    child.attrib['recordPath'] = recdir.replace('/', '\\')
            tree.write(config_file)
            tree.write(default_config)

            self.info_window.close()
            self.noinfo = False

        ready_button = QPushButton('Ready!')
        ready_button.clicked.connect(lambda: save_info(self))
        info_layout.addWidget(ready_button)

        self.info_window.show()
Ejemplo n.º 22
0
    def __init__(self, parent=None):
        ''' sets up the whole main window '''

        #standard init
        super(MainWindow, self).__init__(parent)

        #set the window title
        self.setWindowTitle('Open Ephys Control GUI')

        self.window_height = 700
        self.window_width = 1100

        self.screen2 = QDesktopWidget().screenGeometry(0)
        self.move(
            self.screen2.left() +
            (self.screen2.width() - self.window_width) / 2.,
            self.screen2.top() +
            (self.screen2.height() - self.window_height) / 2.)

        self.get_info()
        self.noinfo = True

        while self.noinfo:
            loop = QEventLoop()
            QTimer.singleShot(500., loop.quit)
            loop.exec_()

        subprocess.Popen('start %s' % open_ephys_path, shell=True)

        self.collect_frame.connect(self.update_frame)
        self.collect_threshed.connect(self.update_threshed)
        self.acquiring = False
        self.recording = False

        self.video_height = self.window_height * .52
        self.video_width = self.window_width * .48

        self.resize(self.window_width, self.window_height)

        #create QTextEdit window 'terminal' for receiving stdout and stderr
        self.terminal = QTextEdit(self)
        #set the geometry
        self.terminal.setGeometry(
            QRect(self.window_width * .02,
                  self.window_height * .15 + self.video_height,
                  self.video_width * .96, 150))

        #make widgets
        self.setup_video_frames()
        self.setup_thresh_buttons()

        self.overlay = True

        #create thread and worker for video processing
        self.videoThread = QThread(self)
        self.videoThread.start()
        self.videoproc_worker = VideoWorker(self)
        self.videoproc_worker.moveToThread(self.videoThread)

        self.vt_file = None
        """""" """""" """""" """""" """""" """""" """""" """
        set up menus
        """ """""" """""" """""" """""" """""" """""" """"""

        #create a QMenuBar and set geometry
        self.menubar = QMenuBar(self)
        self.menubar.setGeometry(
            QRect(0, 0, self.window_width * .5, self.window_height * .03))
        #set the QMenuBar as menu bar for main window
        self.setMenuBar(self.menubar)

        #create a QStatusBar
        statusbar = QStatusBar(self)
        #set it as status bar for main window
        self.setStatusBar(statusbar)

        #create icon toolbar with default image
        iconToolBar = self.addToolBar("iconBar.png")

        #create a QAction for the acquire button
        self.action_Acq = QAction(self)
        #make it checkable
        self.action_Acq.setCheckable(True)
        #grab an icon for the button
        acq_icon = self.style().standardIcon(QStyle.SP_MediaPlay)
        #set the icon for the action
        self.action_Acq.setIcon(acq_icon)
        #when the button is pressed, call the Acquire function
        self.action_Acq.triggered.connect(self.Acquire)

        #create a QAction for the record button
        self.action_Record = QAction(self)
        #make it checkable
        self.action_Record.setCheckable(True)
        #grab an icon for the button
        record_icon = self.style().standardIcon(QStyle.SP_DialogYesButton)
        #set the icon for the action
        self.action_Record.setIcon(record_icon)
        #when the button is pressed, call advanced_settings function
        self.action_Record.triggered.connect(self.Record)

        #create QAction for stop button
        action_Stop = QAction(self)
        #grab close icon
        stop_icon = self.style().standardIcon(QStyle.SP_MediaStop)
        #set icon for action
        action_Stop.setIcon(stop_icon)
        #when button pressed, close window
        action_Stop.triggered.connect(self.Stop)

        #show tips for each action in the status bar
        self.action_Acq.setStatusTip("Start acquiring")
        self.action_Record.setStatusTip("Start recording")
        action_Stop.setStatusTip("Stop acquiring/recording")

        #add actions to icon toolbar
        iconToolBar.addAction(self.action_Acq)
        iconToolBar.addAction(self.action_Record)
        iconToolBar.addAction(action_Stop)

        #        self.sort_button = QPushButton('Sort Now',self)
        #        self.sort_button.setGeometry(QRect(self.window_width*.85,0,self.window_width*.15,self.window_height*.05))
        #        self.sort_button.clicked.connect(self.sort_now)

        #show the window if minimized by windows
        self.showMinimized()
        self.showNormal()
        """""" """""" """""" """""" """""" """""" """""" """""" """""" """""" ""
        """""" """""" """""" """""" """""" """""" """""" """""" """""" """""" ""
Ejemplo n.º 23
0
 def center_window(self):
     coords = QDesktopWidget().availableGeometry().center()
     fg = self.ui.frameGeometry()
     fg.moveCenter(coords)
     self.ui.move(fg.topLeft())
Ejemplo n.º 24
0
 def scale(self):
     """Scale widget to screen"""
     resolution = QDesktopWidget().screenGeometry()
     self.resize(resolution.width() / 2, resolution.height() / 6)
Ejemplo n.º 25
0
 def center(self):
     # Center window
     qr = self.frameGeometry()
     qr.moveCenter(QDesktopWidget().availableGeometry().center())
     self.move(qr.topLeft())
Ejemplo n.º 26
0
def place_dialog_on_screen(dialog, x_ratio=0.5, y_ratio=0.5):
    sg = QDesktopWidget().screenGeometry()
    dialog.setMinimumWidth(x_ratio*sg.width())
    dialog.setMinimumHeight(y_ratio*sg.height())
Ejemplo n.º 27
0
 def position(self):
     screen = QDesktopWidget().screenGeometry()
     size = self.geometry()
     #self.move((screen.width()-size.width()-5),screen.height()-size.height()-45)        
     #self.move(QtGui.QCursor.pos())
     self.move((screen.width()-size.width())/2,(screen.height()-size.height())/2)
Ejemplo n.º 28
0
 def center(self, parent=None):
     screen = QDesktopWidget().screenGeometry()
     size = self.geometry()
     self.move((screen.width() - size.width()) / 2,
               (screen.height() - size.height()) / 2)