class CustomSignals(QtCore.QObject): '''custom signals''' changed = QtCore.pyqtSignal() checkBoxGridChanged = QtCore.pyqtSignal() closed = QtCore.pyqtSignal() # topics_editor recalc = QtCore.pyqtSignal() topicValueChanged = QtCore.pyqtSignal(str, str, float)
def restoreWindowGeometry(self, window, group=None): ''' put the window back where it was :param obj window: instance of QWidget ''' group = self.getGroupName(window, group) width = self.getKey(group + '/width') height = self.getKey(group + '/height') if width is None or height is None: return window.resize(QtCore.QSize(int(width), int(height))) x = self.getKey(group + '/x') y = self.getKey(group + '/y') if x is None or y is None: return # is this window on any available screen? qdw = QtGui.QDesktopWidget() x_onscreen = False y_onscreen = False for screen_num in range(qdw.screenCount()): # find the "available" screen dimensions # (excludes docks, menu bars, ...) available_rect = qdw.availableGeometry(screen_num) if available_rect.x() <= int( x) < available_rect.x() + available_rect.width(): x_onscreen = True if available_rect.y() <= int( y) < available_rect.y() + available_rect.height(): y_onscreen = True # Move the window to the primary window if it would otherwise be drawn off screen available_rect = qdw.availableGeometry(qdw.primaryScreen()) if not x_onscreen: offset = available_rect.x() + available_rect.width() / 10 x = available_rect.x() + offset width = min(int(width), available_rect.width()) if not y_onscreen: offset = available_rect.y() + available_rect.height() / 10 y = available_rect.y() + offset height = min(int(height), available_rect.height()) window.setGeometry( QtCore.QRect(int(x), int(y), int(width), int(height)))
def __init__(self, parent, layout, reviewer, proposal): ''' :param obj parent: owner (a QWidget subclass) :param obj layout: layout in which to place these widgets :param obj reviewer: instance of reviewer.AGUP_Reviewer_Data :param obj proposal: instance of proposal.AGUP_Proposal_Data ''' self.parent = parent self.layout = layout self.reviewer = reviewer self.proposal = proposal self.enabled = False QtCore.QObject.__init__(self, parent) QtCore.qInstallMsgHandler(self._handler_) self.comfort = "" self.custom_signals = signals.CustomSignals() self._init_controls_() self.dotProduct()
def data(self, index, role): ''' ''' if not index.isValid(): return None # For the foreground role you will need to edit this to suit your data row = index.row() if role == QtCore.Qt.ForegroundRole: item = self.data_object.getByIndex(row) elif role != QtCore.Qt.DisplayRole: return QtCore.QVariant() return self.data_object.getByIndex(row)
def selectFirstKeyword(self): ''' ''' idx = self.listWidget.indexAt(QtCore.QPoint(0, 0)) self.listWidget.setCurrentIndex(idx) if len(self.keyword_dict): self.current_key = sorted(self.keyword_dict.keys())[0] value = self.keyword_dict[self.current_key] else: self.current_key = sorted(email_template.REVIEWER_FIELDS.keys())[0] value = email_template.REVIEWER_FIELDS[self.current_key] self.plainTextEdit.setPlainText(value) return idx
def __init__(self, parent=None, topics_list=None, settings=None): self.parent = parent self.topics = topics.Topics() self.topics.addTopics(topics_list) self.settings = settings QtGui.QDialog.__init__(self) resources.loadUi(UI_FILE, self) self.restoreWindowGeometry() self.setWindowTitle('AGUP List of Topics') self.listWidget.addItems(self.topics.getTopicList()) self.add_pb.clicked.connect(self.onAdd) self.delete_pb.clicked.connect(self.onDelete) # select the first item in the list idx = self.listWidget.indexAt(QtCore.QPoint(0, 0)) self.listWidget.setCurrentIndex(idx) self.custom_signals = signals.CustomSignals()
def developer_main(): ''' create QGroupBox + QGridLayout and run the panel === === === === ==== ========================= R1 #1 R2 #2 % Reviewer Name === === === === ==== ========================= [x] 1 [ ] 0 100% Joe User [ ] 0 [x] 1 80% Second Reviewer [ ] 0 [ ] 0 22% Some Panel Member [ ] 0 [ ] 0 1% Another Panel Member === === === === ==== ========================= ''' import sys import os import agup_data global layout, agup testfile = os.path.abspath('project/agup_project.xml') agup = agup_data.AGUP_Data() agup.openPrpFile(testfile) app = QtGui.QApplication(sys.argv) grid = QtGui.QGroupBox('prop_revu_grid demo') layout = ReviewerAssignmentGridLayout(grid, agup) layout.addReviewers(agup.reviewers) layout.setReviewersValues(agup.reviewers) timer = QtCore.QTimer() timer.singleShot(2000, _onDelay1) timer.singleShot(5000, _onDelay2) timer.singleShot(7500, _onDelay3) grid.show() sys.exit(app.exec_())
def selectFirstListItem(self): ''' ''' idx = self.listView.indexAt(QtCore.QPoint(0,0)) self.listView.setCurrentIndex(idx) return idx
def doUrl(self, url): '''opening URL in default browser''' url = QtCore.QUrl(url) service = QtGui.QDesktopServices() service.openUrl(url)