我们从Python开源项目中,提取了以下50个代码示例,用于说明如何使用PyQt4.QtCore.SIGNAL。
def setupUi(self, Dialog, mymodel): Dialog.setObjectName(_fromUtf8("Downloads_Dialog")) Dialog.resize(740, 440) self.verticalLayout = QtGui.QVBoxLayout(Dialog) self.verticalLayout.setObjectName(_fromUtf8("verticalLayout")) self.tableView = DownloadsTable(mymodel) self.tableView.setObjectName(_fromUtf8("tableView")) self.verticalLayout.addWidget(self.tableView) self.buttonBox = QtGui.QDialogButtonBox(Dialog) self.buttonBox.setOrientation(QtCore.Qt.Horizontal) self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Close) self.buttonBox.setObjectName(_fromUtf8("buttonBox")) self.verticalLayout.addWidget(self.buttonBox) self.retranslateUi(Dialog) QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(_fromUtf8("rejected()")), Dialog.reject) QtCore.QMetaObject.connectSlotsByName(Dialog)
def setupUi(self, Dialog): Dialog.resize(640, 165) Dialog.setWindowTitle("Add Bookmark") self.gridLayout = QtGui.QGridLayout(Dialog) self.label = QtGui.QLabel(Dialog) self.label.setText("Title :") self.gridLayout.addWidget(self.label, 0, 0, 1, 1) self.titleEdit = QtGui.QLineEdit(Dialog) self.gridLayout.addWidget(self.titleEdit, 0, 1, 1, 1) self.label_2 = QtGui.QLabel(Dialog) self.label_2.setText("Address :") self.gridLayout.addWidget(self.label_2, 1, 0, 1, 1) self.addressEdit = QtGui.QLineEdit(Dialog) self.gridLayout.addWidget(self.addressEdit, 1, 1, 1, 1) self.buttonBox = QtGui.QDialogButtonBox(Dialog) self.buttonBox.setLayoutDirection(QtCore.Qt.LeftToRight) self.buttonBox.setOrientation(QtCore.Qt.Horizontal) self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Cancel|QtGui.QDialogButtonBox.Save) self.gridLayout.addWidget(self.buttonBox, 2, 0, 1, 2) QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(_fromUtf8("accepted()")), Dialog.accept) QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(_fromUtf8("rejected()")), Dialog.reject)
def setupUi(self, Alert): Alert.setObjectName("Alert") Alert.resize(400, 93) self.verticalLayout = QtGui.QVBoxLayout(Alert) self.verticalLayout.setObjectName("verticalLayout") self.gridLayout = QtGui.QGridLayout() self.gridLayout.setObjectName("gridLayout") spacerItem = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) self.gridLayout.addItem(spacerItem, 0, 0, 1, 1) self.label = QtGui.QLabel(Alert) self.label.setObjectName("label") self.gridLayout.addWidget(self.label, 0, 1, 1, 1) spacerItem1 = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) self.gridLayout.addItem(spacerItem1, 0, 2, 1, 1) self.verticalLayout.addLayout(self.gridLayout) self.buttonBox = QtGui.QDialogButtonBox(Alert) self.buttonBox.setOrientation(QtCore.Qt.Horizontal) self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Ok) self.buttonBox.setObjectName("buttonBox") self.verticalLayout.addWidget(self.buttonBox) self.retranslateUi(Alert) QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL("accepted()"), Alert.accept) QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL("rejected()"), Alert.reject) QtCore.QMetaObject.connectSlotsByName(Alert)
def select_elements(self, names): """ return True if the selection is possible """ incorrect_names = self.check_names(names) if incorrect_names: self.emit(SIGNAL('incorrect_names'), 'the following names are incorrect: \n' + ', '.join(incorrect_names)) return False if 'all' in names: self.select(True) return True #selected_items = [self.findItems(name, Qt.MatchExactly)[0] for name in names] for item in self.get_items(): item_text = item.text() if item_text in names and not item.active: item.change(self.dic) elif not (item_text in names) and item.active: item.change(self.dic) return True
def connect_actions(self): self.connect(self.action_exit, SIGNAL('triggered()'), self.close) self.connect(self.action_open_terminals, SIGNAL('triggered()'), self.open_terminals) self.connect(self.action_send, SIGNAL('triggered()'), lambda : self.process_line(move_next=False, decrement = 1)) self.connect(self.action_send_move_next, SIGNAL('triggered()'), lambda : self.process_line(move_next=True, decrement = 2)) self.connect(self.action_about, SIGNAL('triggered()'), self.about) self.action_new.triggered.connect(self.new_project) self.action_save.triggered.connect(self.save_script) self.action_edit_var_file.triggered.connect(lambda : self.open_file( os.path.join(self.var_path, self.teminal_group + '.txt')) ) self.action_unselect_all.triggered.connect(lambda : self.listwidget.select(False)) self.action_select_all.triggered.connect(lambda : self.listwidget.select(True)) self.action_invert.triggered.connect(self.invert) self.action_close_terminals.triggered.connect(self.close_selection) self.action_save_as_template.triggered.connect(lambda : self.save_file(self.template_dir, "Save as template")) self.action_open_local_term.triggered.connect(self.open_local_term) self.action_open_local_dir.triggered.connect(self.open_local_dir) self.action_edit_config.triggered.connect(lambda : self.open_file(self.cfg_path)) self.action_restart.triggered.connect(self.restart)
def setupUi(self, Dialog): Dialog.setObjectName("Dialog") Dialog.resize(400, 300) self.verticalLayout = QtGui.QVBoxLayout(Dialog) self.verticalLayout.setObjectName("verticalLayout") self.textview = QtGui.QPlainTextEdit(Dialog) self.textview.setObjectName("textview") self.verticalLayout.addWidget(self.textview) self.buttonBox = QtGui.QDialogButtonBox(Dialog) self.buttonBox.setOrientation(QtCore.Qt.Horizontal) self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Close) self.buttonBox.setObjectName("buttonBox") self.verticalLayout.addWidget(self.buttonBox) self.retranslateUi(Dialog) QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL("accepted()"), Dialog.accept) QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL("rejected()"), Dialog.reject) QtCore.QMetaObject.connectSlotsByName(Dialog)
def setupUi(self, Dialog): Dialog.setObjectName(_fromUtf8("Dialog")) Dialog.resize(400, 300) self.verticalLayout = QtGui.QVBoxLayout(Dialog) self.verticalLayout.setObjectName(_fromUtf8("verticalLayout")) self.textview = QtGui.QPlainTextEdit(Dialog) self.textview.setObjectName(_fromUtf8("textview")) self.verticalLayout.addWidget(self.textview) self.buttonBox = QtGui.QDialogButtonBox(Dialog) self.buttonBox.setOrientation(QtCore.Qt.Horizontal) self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Close) self.buttonBox.setObjectName(_fromUtf8("buttonBox")) self.verticalLayout.addWidget(self.buttonBox) self.retranslateUi(Dialog) QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(_fromUtf8("accepted()")), Dialog.accept) QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(_fromUtf8("rejected()")), Dialog.reject) QtCore.QMetaObject.connectSlotsByName(Dialog)
def removeFullLines(self): numFullLines = 0 rowsToRemove = [] for i in range(Board.BoardHeight): n = 0 for j in range(Board.BoardWidth): if not self.shapeAt(j, i) == Tetrominoes.NoShape: n = n + 1 if n == 10: rowsToRemove.append(i) rowsToRemove.reverse() for m in rowsToRemove: for k in range(m, Board.BoardHeight): for l in range(Board.BoardWidth): self.setShapeAt(l, k, self.shapeAt(l, k + 1)) numFullLines = numFullLines + len(rowsToRemove) if numFullLines > 0: self.numLinesRemoved = self.numLinesRemoved + numFullLines self.emit(QtCore.SIGNAL("messageToStatusbar(QString)"), str(self.numLinesRemoved)) self.isWaitingAfterLine = True self.curPiece.setShape(Tetrominoes.NoShape) self.update()
def __init__(self, parent=None): QtGui.QWidget.__init__(self) self.setGeometry(300, 300, 250, 150) self.pBar = QtGui.QProgressBar(self) self.pBar.setGeometry(30, 40, 200, 25) self.button = QtGui.QPushButton('start', self) self.button.setFocusPolicy(QtCore.Qt.NoFocus) self.button.move(40, 80) self.connect(self.button, QtCore.SIGNAL('clicked()'), self.onStart) self.timer = QtCore.QBasicTimer() self.step = 0
def setupUi(self, StaticHelp): StaticHelp.setObjectName(_fromUtf8("StaticHelp")) StaticHelp.resize(698, 595) self.verticalLayout = QtGui.QVBoxLayout(StaticHelp) self.verticalLayout.setObjectName(_fromUtf8("verticalLayout")) self.help_view = QtWebKit.QWebView(StaticHelp) self.help_view.setUrl(QtCore.QUrl(_fromUtf8("about:blank"))) self.help_view.setObjectName(_fromUtf8("help_view")) self.verticalLayout.addWidget(self.help_view) self.buttonBox = QtGui.QDialogButtonBox(StaticHelp) self.buttonBox.setOrientation(QtCore.Qt.Horizontal) self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Close) self.buttonBox.setObjectName(_fromUtf8("buttonBox")) self.verticalLayout.addWidget(self.buttonBox) self.retranslateUi(StaticHelp) QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(_fromUtf8("accepted()")), StaticHelp.accept) QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(_fromUtf8("rejected()")), StaticHelp.reject) QtCore.QMetaObject.connectSlotsByName(StaticHelp)
def __init__(self, parent=None): QtGui.QWidget.__init__(self, parent) self.ui = abc_main_ui.Ui_Dialog() self.ui.setupUi(self) # Button's handlers self.connect(self.ui.runButton, QtCore.SIGNAL("clicked()"), self.run) self.connect(self.ui.cancelButton, QtCore.SIGNAL("clicked()"), self.cancel) self.connect(self.ui.addFieldButton, QtCore.SIGNAL("clicked()"), self.addField) self.connect(self.ui.deleteSelectedButton, QtCore.SIGNAL("clicked()"), self.deleteSelectedFields) self.connect(self.ui.deleteAllButton, QtCore.SIGNAL("clicked()"), self.deleteAllFields) self.connect(self.ui.vectorLayerComboBox, QtCore.SIGNAL("currentIndexChanged(const QString&)"), self.layerChanged) self.activateInterface() # Fill vector layers combobox vectorLayers = [layer.name() for layer in QgsMapLayerRegistry.instance().mapLayers().values() if (layer.type() == QgsMapLayer.VectorLayer)] self.ui.vectorLayerComboBox.addItems(vectorLayers) ### INTERFACE MANIPULATIONS
def showStables(self): fields = ['capacity', 'cost per km', 'lines'] if 'Substation' in self.sender().text(): field = self.view.scene().lines.substation_costs fields = ['line', 'cost'] elif 'Costs' in self.sender().text(): field = self.view.scene().lines.line_costs fields = ['line', 'cost per km'] elif 'Dispatchable' in self.sender().text(): field = self.view.scene().lines.d_line_table else: field = self.view.scene().lines.s_line_table dialog = displaytable.Table(field, fields=fields, title=self.sender().text(), save_folder=self.scenarios) dialog.exec_() comment = self.sender().text() + ' displayed.' self.view.emit(QtCore.SIGNAL('statusmsg'), comment)
def go_ToLoad(self): if len(self.view.scene().load_centre) == 1: j = 0 else: menu = QtGui.QMenu() ctrs = [] for ctr in self.view.scene().load_centre: ctrs.append(menu.addAction(ctr[0])) # ctrs[-1].setIconVisibleInMenu(True) x = self.frameGeometry().left() + 50 y = self.frameGeometry().y() + 50 action = menu.exec_(QtCore.QPoint(x, y)) if action is not None: for j in range(len(self.view.scene().load_centre)): if action.text() == self.view.scene().load_centre[j][0]: break if j < len(self.view.scene().load_centre): go_to = self.mapFromLonLat(QtCore.QPointF(self.view.scene().load_centre[j][2], self.view.scene().load_centre[j][1])) self.view.centerOn(go_to) comment = '(%s,%s) Centred on %s Load Centre' % ( '{:0.4f}'.format(self.view.scene().load_centre[j][1]), '{:0.4f}'.format(self.view.scene().load_centre[j][2]), self.view.scene().load_centre[j][0]) self.view.emit(QtCore.SIGNAL('statusmsg'), comment)
def spawn(self, who): if type(who) is list: if os.path.exists(who[0]): if sys.platform == 'win32' or sys.platform == 'cygwin': if who[0][-3:] == '.py': pid = subprocess.Popen(who, shell=True).pid else: pid = subprocess.Popen(who).pid else: pid = subprocess.Popen(['python', who[0], who[1]]).pid self.view.emit(QtCore.SIGNAL('statusmsg'), who[0] + ' invoked') else: if os.path.exists(who): if sys.platform == 'win32' or sys.platform == 'cygwin': if who[-3:] == '.py': pid = subprocess.Popen([who], shell=True).pid else: pid = subprocess.Popen([who]).pid else: pid = subprocess.Popen(['python', who]).pid self.view.emit(QtCore.SIGNAL('statusmsg'), who + ' invoked') return
def get_Power(self): self.view.scene().exitLoop = False self.escape.setVisible(True) if self.sender().text()[:4] == 'Powe': power = PowerModel(self.view.scene()._stations.stations, status=self.floatstatus, visualise=self) else: power = PowerModel(self.view.scene()._stations.stations, year=self.sender().text(), status=self.floatstatus, visualise=self) self.escape.setVisible(False) generated = power.getValues() if generated is None: comment = 'Power plot aborted' else: for stn in generated: station = self.view.scene()._stations.Get_Station(stn.name) station.generation = stn.generation self.view.scene().addGeneration(station) comment = 'Power plot completed' pct = power.getPct() if pct is not None: comment += ' (generation meets ' + pct[2:] del power self.view.emit(QtCore.SIGNAL('statusmsg'), comment)
def show_Capacity(self): comment = 'Capacity Circles Toggled' if self.view.scene().show_capacity: self.showCapacity.setIcon(QtGui.QIcon('blank.png')) self.view.scene().show_capacity = False self.view.scene()._capacityGroup.setVisible(False) self.view.scene()._fcapacityGroup.setVisible(False) comment += ' Off' else: self.showCapacity.setIcon(QtGui.QIcon(self.check_icon)) self.view.scene().show_capacity = True self.view.scene()._capacityGroup.setVisible(True) if self.view.scene().show_fossil: self.view.scene()._fcapacityGroup.setVisible(True) comment += ' On' self.reshow_FloatLegend() self.view.emit(QtCore.SIGNAL('statusmsg'), comment)
def show_Fossil(self): comment = 'Fossil-fueled Stations Toggled' if self.view.scene().show_fossil: self.showFossil.setIcon(QtGui.QIcon('blank.png')) self.view.scene().show_fossil = False self.view.scene()._fossilGroup.setVisible(False) self.view.scene()._fcapacityGroup.setVisible(False) self.view.scene()._fnameGroup.setVisible(False) comment += ' Off' else: self.showFossil.setIcon(QtGui.QIcon(self.check_icon)) self.view.scene().show_fossil = True self.view.scene()._fossilGroup.setVisible(True) if self.view.scene().show_capacity: self.view.scene()._fcapacityGroup.setVisible(True) if self.view.scene().show_station_name: self.view.scene()._fnameGroup.setVisible(True) comment += ' On' self.reshow_FloatLegend() self.view.emit(QtCore.SIGNAL('statusmsg'), comment)
def show_Resource(self): if self.resource is None: if self.sender().text()[:4] == 'Show': self.resource_year = self.base_year else: self.resource_year = str(self.sender().text()) self.escaper.setVisible(True) self.resource = Resource(self.resource_year, self.view.scene()) if not self.resource.be_open: self.escaper.setVisible(False) self.resource = None self.view.emit(QtCore.SIGNAL('statusmsg'), 'Resource grid not available') return self.resource.setWindowModality(QtCore.Qt.WindowModal) self.resource.setWindowFlags(self.resource.windowFlags() | QtCore.Qt.WindowSystemMenuHint | QtCore.Qt.WindowMinMaxButtonsHint) self.resource.procStart.connect(self.getResource) self.view.emit(QtCore.SIGNAL('statusmsg'), 'Resource Window opened') self.resource.exec_()
def show_FloatLegend(self, make_comment=True): if self.floatlegend is None: tech_data = {} flags = [self.view.scene().show_capacity, self.view.scene().show_generation, self.view.scene().station_square, self.view.scene().show_fossil] for key in self.view.scene().areas.keys(): tech_data[key] = [self.view.scene().areas[key], self.view.scene().colors[key], flags] self.floatlegend = FloatLegend(tech_data, self.view.scene()._stations.stations, flags) self.floatlegend.setWindowModality(QtCore.Qt.WindowModal) self.floatlegend.setWindowFlags(self.floatlegend.windowFlags() | QtCore.Qt.WindowSystemMenuHint | QtCore.Qt.WindowMinMaxButtonsHint) self.floatlegend.procStart.connect(self.getFloatLegend) if make_comment: self.view.emit(QtCore.SIGNAL('statusmsg'), 'Floating Legend opened') self.floatlegend.show() self.activateWindow() # self.floatmenu.exec_()
def showArea(self, event): if self.ignore: return if self.sender() == self.southSpin or self.sender() == self.eastSpin: if self.southSpin.value() > self.northSpin.value(): y = self.northSpin.value() self.northSpin.setValue(self.southSpin.value()) self.southSpin.setValue(y) if self.eastSpin.value() < self.westSpin.value(): x = self.westSpin.value() self.westSpin.setValue(self.eastSpin.value()) self.eastSpin.setValue(x) if self.worldwindow is None: return approx_area = self.worldwindow.view.drawRect([QtCore.QPointF(self.westSpin.value(), self.northSpin.value()), QtCore.QPointF(self.eastSpin.value(), self.southSpin.value())]) self.approx_area.setText(approx_area) merra_dims = worldwindow.merra_cells(self.northSpin.value(), self.westSpin.value(), self.southSpin.value(), self.eastSpin.value()) self.merra_cells.setText(merra_dims) if event != 'init': self.worldwindow.view.emit(QtCore.SIGNAL('statusmsg'), approx_area + ' ' + merra_dims)
def showArea(self, event): if self.ignore: return if self.sender() == self.southSpin or self.sender() == self.eastSpin: if self.southSpin.value() > self.northSpin.value(): y = self.northSpin.value() self.northSpin.setValue(self.southSpin.value()) self.southSpin.setValue(y) if self.eastSpin.value() < self.westSpin.value(): x = self.westSpin.value() self.westSpin.setValue(self.eastSpin.value()) self.eastSpin.setValue(x) if self.worldwindow is None: return approx_area = self.worldwindow.view.drawRect([QtCore.QPointF(self.westSpin.value(), self.northSpin.value()), QtCore.QPointF(self.eastSpin.value(), self.southSpin.value())]) self.approx_area.setText(approx_area) if event != 'init': self.worldwindow.view.emit(QtCore.SIGNAL('statusmsg'), approx_area)
def drawMany(self): grids = GetMany.getList() if grids is None: return self.clear_Rect() self.rect_items = [] color = QtGui.QColor() color.setNamedColor((self.scene().colors['border'])) pen = QtGui.QPen(color, self.scene().line_width) pen.setJoinStyle(QtCore.Qt.RoundJoin) pen.setCapStyle(QtCore.Qt.RoundCap) for g in range(len(grids)): fromm = self.mapFromLonLat(QtCore.QPointF(grids[g][1], grids[g][0])) too = self.mapFromLonLat(QtCore.QPointF(grids[g][3], grids[g][2])) self.rect_items.append(QtGui.QGraphicsRectItem(fromm.x(), fromm.y(), too.x() - fromm.x(), too.y() - fromm.y())) self.rect_items[-1].setPen(pen) self.rect_items[-1].setZValue(3) self.scene().addItem(self.rect_items[-1]) self.emit(QtCore.SIGNAL('statusmsg'), str(len(grids)) + ' Areas drawn')
def mouseMoveEvent(self, event): if QtCore.Qt.LeftButton == event.buttons() and self._drag_start: if self._rectangle: self._rectangle = None delta = event.pos() - self._drag_start val = self._sb_start - delta self.horizontalScrollBar().setValue(val.x()) self.verticalScrollBar().setValue(val.y()) return if QtCore.Qt.LeftButton == event.buttons() and self._rectangle: delta = event.pos() - self._rectangle val = self._sb_start - delta self.horizontalScrollBar().setValue(val.x()) self.verticalScrollBar().setValue(val.y()) else: p = self.mapToScene(event.pos()) x, y = map(int, [p.x(), p.y()]) pl = self.mapToLonLat(event.pos()) # self.emit(QtCore.SIGNAL('statusmsg'), p2str(pl) + ' ' + p2str(event.pos()))
def editSects(self): config = ConfigParser.RawConfigParser() config.read(self.config_file) sections = sorted(config.sections()) menu = QtGui.QMenu() stns = [] for section in sections: stns.append(menu.addAction(section)) x = self.frameGeometry().left() + 50 y = self.frameGeometry().y() + 50 action = menu.exec_(QtCore.QPoint(x, y)) if action is not None: section = str(action.text()) EditSect(section, None, ini_file=self.config_file) comment = section + ' Section edited. Reload may be required.' self.view.emit(QtCore.SIGNAL('statusmsg'), comment)
def save_View(self): outputimg = QtGui.QPixmap(self.view.width(), self.view.height()) painter = QtGui.QPainter(outputimg) targetrect = QtCore.QRectF(0, 0, self.view.width(), self.view.height()) sourcerect = QtCore.QRect(0, 0, self.view.width(), self.view.height()) self.view.render(painter, targetrect, sourcerect) fname = 'worldwindow_view.png' fname = QtGui.QFileDialog.getSaveFileName(self, 'Save image file', fname, 'Image Files (*.png *.jpg *.bmp)') if fname != '': fname = str(fname) i = fname.rfind('.') if i < 0: fname = fname + '.png' i = fname.rfind('.') outputimg.save(fname, fname[i + 1:]) try: comment = 'View saved to ' + fname[fname.rfind('/') + 1:] except: comment = 'View saved to ' + fname self.view.emit(QtCore.SIGNAL('statusmsg'), comment) painter.end()
def __init__(self, parent ,curveList,plot): super(AppWindow, self).__init__(parent) self.setupUi(self) self.connect(QtGui.QShortcut(QtGui.QKeySequence(QtCore.Qt.Key_Escape), self), QtCore.SIGNAL('activated()'), self.close) self.connect(QtGui.QShortcut(QtGui.QKeySequence(plotSave._translate("MainWindow", "Ctrl+P", None)), self), QtCore.SIGNAL('activated()'), self.printImage) self.connect(QtGui.QShortcut(QtGui.QKeySequence(plotSave._translate("MainWindow", "Ctrl+C", None)), self), QtCore.SIGNAL('activated()'), self.copyToClipboard) self.table.setColumnWidth(0,200) colnum=0;labels=[] self.maxRows=0 self.maxCols=0 for a in curveList: x,y = a.getData() name = a.name() if x!=None and y!=None: self.setColumn(colnum,x);colnum+=1 self.setColumn(colnum,y);colnum+=1 labels.append('%s(X)'%(name));labels.append('%s(Y)'%(name)); self.table.setHorizontalHeaderLabels(labels) self.plot = plot if plot: self.imageWidthBox.setEnabled(True) self.saveImageButton.setEnabled(True) self.imageWidthBox.setValue(self.plot.plotItem.width())
def initEditMenubar(self): """Creates entries of edit menubar and connects actions with gui methods. """ editMoleculeButton = QtGui.QAction('Edit Molecule', self) self.connect(editMoleculeButton, QtCore.SIGNAL('triggered()'), self.editMolecule) removeMoleculeButton = QtGui.QAction('Remove Molecule', self) self.connect(removeMoleculeButton, QtCore.SIGNAL('triggered()'), self.removeMolecule) openWizardButton = QtGui.QAction('PyFRAP Wizard', self) self.connect(openWizardButton, QtCore.SIGNAL('triggered()'), self.openWizard) self.mbEdit.addAction(editMoleculeButton) self.mbEdit.addAction(removeMoleculeButton) self.mbEdit.addAction(openWizardButton)
def initAnalysisMenubar(self): """Creates entries of analysis menubar and connects actions with gui methods. """ editAnalysisButton = QtGui.QAction('Analysis Settings', self) self.connect(editAnalysisButton, QtCore.SIGNAL('triggered()'), self.editAnalysis) analyzeEmbryoButton = QtGui.QAction('Analyze Embryo', self) self.connect(analyzeEmbryoButton, QtCore.SIGNAL('triggered()'), self.analyzeEmbryo) plotEmbryoAnalysisButton = QtGui.QAction('Plot Analysis Result of Embryo', self) self.connect(plotEmbryoAnalysisButton, QtCore.SIGNAL('triggered()'), self.plotAllDataTSOfEmbryo) self.mbAnalysis.addAction(editAnalysisButton) self.runAnalysisMB=self.mbAnalysis.addMenu('&Run Analysis') self.runAnalysisMB.addAction(analyzeEmbryoButton) self.plotAnalysisMB=self.mbAnalysis.addMenu('&Plotting') self.plotAnalysisMB.addAction(plotEmbryoAnalysisButton) return
def __init__(self,parent,List,leftTitle="",rightTitle="",itemsRight=[]): super(advancedListSelectorDialog,self).__init__(parent,List,leftTitle=leftTitle,rightTitle=rightTitle) #print type(self),type(parent) #raw_input() #listSelectorDialog.__init__(parent,List,leftTitle=leftTitle,rightTitle=rightTitle,itemsRight=itemsRight) self.btnUp=QtGui.QToolButton() self.btnUp.connect(self.btnUp, QtCore.SIGNAL('clicked()'), self.upItem) self.btnUp.setArrowType(QtCore.Qt.UpArrow) self.btnDown=QtGui.QToolButton() self.btnDown.connect(self.btnDown, QtCore.SIGNAL('clicked()'), self.downItem) self.btnDown.setArrowType(QtCore.Qt.DownArrow) self.vbox.addWidget(self.btnUp) self.vbox.addWidget(self.btnDown) self.setWindowTitle("advanced List Selector Dialog")
def __init__(self,parent): super(progressDialog,self).__init__(parent) #Labels self.lblName = QtGui.QLabel("Something in progress...", self) #Buttons self.btnCancel=QtGui.QPushButton('Cancel') self.btnCancel.connect(self.btnCancel, QtCore.SIGNAL('clicked()'), self.cancel) #ProgressBar self.progressbar = QtGui.QProgressBar() self.progressbar.setMinimum(1) self.progressbar.setMaximum(100) #Layout self.vbox = QtGui.QVBoxLayout() self.vbox.addWidget(self.lblName) self.vbox.addWidget(self.progressbar) self.vbox.addWidget(self.btnCancel) self.setLayout(self.vbox) self.setWindowTitle('Progress Dialog') self.show()
def __init__(self,parent): super(waitDialog,self).__init__(parent) #Labels self.lblName = QtGui.QLabel("Something in progress...", self) #Buttons self.btnCancel=QtGui.QPushButton('Cancel') self.btnCancel.connect(self.btnCancel, QtCore.SIGNAL('clicked()'), self.cancel) #Layout self.vbox = QtGui.QVBoxLayout() self.vbox.addWidget(self.lblName) self.vbox.addWidget(self.btnCancel) self.setLayout(self.vbox) self.setWindowTitle('Progress Dialog') self.show()
def plothist(self, img, fScale=False): #perhaps this should be called in a separate thread? bins=256 rangetop=1.0 if fScale else 256 imgsize=img.shape mask = getMask(img, mask_pct) bwimg=cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) bhist = cv2.calcHist([bwimg],[0],mask,[256],[0,rangetop]) bhist[0]=0 over = [0,0,0,0] over[3]=sum(bhist[:10]) px = imgsize[0]*imgsize[1]*mask_pct*mask_pct ylim=px/128 #arbitrary value to keep y limit consistent and reasonable hists=[] for i in range(0,3): hist = cv2.calcHist([img],[i],mask,[256],[0,rangetop]) over[i]=sum(hist[252:]) hists.append(hist) avg=int(cv2.mean(bwimg)[0]*100.0/rangetop) #logging.debug("Sending Signal") self.emit(qtcore.SIGNAL("plotHistogram(PyQt_PyObject, PyQt_PyObject, float)"), hists, bhist, px) self.emit(qtcore.SIGNAL("displayWashouts(PyQt_PyObject, float, float)"), over, px, avg)
def __init__(self): QtGui.QApplication.__init__(self, sys.argv) self.window = QtGui.QWidget() self.window.setGeometry(100, 100, 800, 600) self.window.setWindowTitle("Open Browser") self.grid = QtGui.QGridLayout() self.window.setLayout(self.grid) self.tab_stack = CQTabWidget() self.tab_stack.setTabShape(QtGui.QTabWidget.TabShape(QtGui.QTabWidget.Triangular)) self.tab_stack.connect(self.tab_stack, QtCore.SIGNAL("currentChanged(int)"), self.add_tab) self.tab_stack.connect(self.tab_stack, QtCore.SIGNAL("RELOAD_PAGE"), lambda: self.tabs[self.tab_stack.currentIndex()][2].reload()) self.tabs = [[QtGui.QWidget(), QtGui.QGridLayout()], [QtGui.QWidget(), QtGui.QGridLayout()]] self.tab_stack.addTab(self.tabs[0][0], '') self.tab_stack.addTab(self.tabs[1][0], '+') self.current_links = [] self.visited = [] self.bookmarks = Bookmarks() QtWebKit.QWebSettings.globalSettings().setAttribute(QtWebKit.QWebSettings.PluginsEnabled, True) QtWebKit.QWebSettings.globalSettings().setAttribute(QtWebKit.QWebSettings.JavascriptEnabled, True) self.create_widgets() self.current_index = 0 self.window.showMaximized() sys.exit(self.exec_())
def _read_in_chunks(self, file_object, shard_size, rowposition, blocksize=1024, chunks=-1, shard_index=None): """Lazy function (generator) to read a file piece by piece. Default chunk size: 1k.""" # chunk number (first is 0) i = 0 while chunks: data = file_object.read(blocksize) if not data: break yield data i += 1 t1 = float(shard_size) / float(blocksize) if shard_size <= blocksize: t1 = 1 percent_uploaded = int(round((100.0 * i) / t1)) # self.__logger.debug(i) chunks -= 1 # update progress bar in upload queue table self.emit(QtCore.SIGNAL("updateShardUploadProgress"), int(rowposition), percent_uploaded) self.shard_upload_percent_list[shard_index] = percent_uploaded self.emit(QtCore.SIGNAL("refreshOverallProgress"), 0.1) # update overall progress bar
def remove_bucket(self): self.bucket_name = self.bucket_create_ui.bucket_name.text() success = False try: self.storj_engine.storj_client.bucket_delete(str(self.bucket_id)) success = True except Exception as e: self.__logger.error(e) self.__logger.error('Unhandled exception while deleting bucket %s' % e) success = False if success: # show dialog - bucket deleted successfully self.dashboard_instance.createNewBucketResolveThread() self.emit(QtCore.SIGNAL('showBucketDeletedSuccessfully'), str(self.bucket_name))
def _add_shard_to_table(self, pointers_content, chapters): """ Add a row to the shard table and return the row number """ # Add items to shard queue table view # self.rowpositions_in_progress.append(False) tablerowdata = {} tablerowdata['farmer_address'] = pointers_content['farmer']['address'] tablerowdata['farmer_port'] = pointers_content['farmer']['port'] tablerowdata['farmer_id'] = pointers_content['farmer']['nodeID'] tablerowdata['hash'] = str(pointers_content['hash']) tablerowdata['state'] = 'Downloading...' tablerowdata['shard_index'] = str(chapters) self.__logger.debug('Resolved pointer for download: %s:%s' % ( pointers_content['farmer']['address'], pointers_content['farmer']['port'])) # Add row to table self.emit(QtCore.SIGNAL('addRowToDownloadQueueTable'), tablerowdata) rowcount = self.ui_single_file_download.shard_queue_table.rowCount() return rowcount
def __init__(self, parent=None): QtGui.QWidget.__init__(self, parent) self.ui_initial_window = Ui_InitialWindow() self.ui_initial_window.setupUi(self) self.storj_engine = StorjEngine() # Open login window QtCore.QObject.connect( self.ui_initial_window.login_bt, QtCore.SIGNAL('clicked()'), self.open_login_window) # Open registration window QtCore.QObject.connect( self.ui_initial_window.register_bt, QtCore.SIGNAL('clicked()'), self.open_register_window)
def __init__(self, parent=None): QtGui.QWidget.__init__(self, parent) self.bucket_manager_ui = Ui_BucketManager() self.bucket_manager_ui.setupUi(self) self.createNewBucketGetThread() # Open login window QtCore.QObject.connect(self.bucket_manager_ui.quit_bt, QtCore.SIGNAL('clicked()'), self.quit) # Delete bucket QtCore.QObject.connect(self.bucket_manager_ui.delete_bucket_bt, QtCore.SIGNAL('clicked()'), self.delete_bucket) # Open bucket create window QtCore.QObject.connect(self.bucket_manager_ui.create_new_bucket_bt, QtCore.SIGNAL('clicked()'), self.open_bucket_create_window) # Open bucket edit window QtCore.QObject.connect(self.bucket_manager_ui.edit_bucket_bt, QtCore.SIGNAL('clicked()'), self.open_bucket_edit_window)
def __init__(self, *args, **kwargs): super(CommandWidget,self).__init__(*args, **kwargs) ui.load('commandwidget.ui', self) self._process = QtCore.QProcess(self) QtCore.QObject.connect(self._process, QtCore.SIGNAL('readyReadStandardOutput()'), self.readStandardOutput) QtCore.QObject.connect(self._process, QtCore.SIGNAL('readyReadStandardError()'), self.readStandardError) QtCore.QObject.connect(self._process, QtCore.SIGNAL('finished(int,QProcess::ExitStatus)'), self.processExited) QtCore.QObject.connect(self._process, QtCore.SIGNAL('stateChanged(QProcess::ProcessState)'), self.processStateChanged)
def setupUi(self, Dialog): Dialog.resize(316, 238) Dialog.setWindowTitle("Select Resolution") self.verticalLayout = QtGui.QVBoxLayout(Dialog) self.frame = QtGui.QFrame(Dialog) self.frame.setFrameShape(QtGui.QFrame.StyledPanel) self.frame.setFrameShadow(QtGui.QFrame.Raised) self.verticalLayout_2 = QtGui.QVBoxLayout(self.frame) self.buttonGroup = QtGui.QButtonGroup(self.frame) if len(self.videos)>3: checked_btn = 2 else: checked_btn = len(self.videos)-1 for i, video in enumerate(self.videos): radioButton = QtGui.QRadioButton(self.frame) radioButton.setText(video.resolution + " (" + video.extension + ')') self.buttonGroup.addButton(radioButton) self.verticalLayout_2.addWidget(radioButton) if i==checked_btn : radioButton.setChecked(True) spacerItem = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding) self.verticalLayout_2.addItem(spacerItem) self.verticalLayout.addWidget(self.frame) self.buttonBox = QtGui.QDialogButtonBox(Dialog) self.buttonBox.setOrientation(QtCore.Qt.Horizontal) self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Cancel|QtGui.QDialogButtonBox.Ok) self.verticalLayout.addWidget(self.buttonBox) QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(_fromUtf8("accepted()")), Dialog.accept) QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(_fromUtf8("rejected()")), Dialog.reject) QtCore.QMetaObject.connectSlotsByName(Dialog)
def __init__(self): super(MyMainWindow, self).__init__() self.setupUi(self) for treeId in ['indiv', 'behav']: layoutItem = eval('self.verticalLayout_'+treeId) # Methods display exec('self.'+treeId+'ItemCode = Code_Editor(self.'+treeId+'_groupBox)') codeItem = eval('self.'+treeId+'ItemCode') codeItem.setObjectName(treeId+'ItemCode') codeItem.installEventFilter(self) exec('self.connect(codeItem, SIGNAL("textChanged()"), self.'+treeId+'ItemCode_modif)') exec('self.'+treeId+'Desc = QtGui.QLabel(self.'+treeId+'_groupBox)') descItem = eval('self.'+treeId+'Desc') descItem.setText('') descItem.setObjectName(treeId+'Desc') layoutItem.addWidget(descItem) layoutItem.addWidget(codeItem) # Attributs display exec('self.'+treeId+'AttrVerticalLayout = QtGui.QVBoxLayout()') attrVerticalLayout = eval('self.'+treeId+'AttrVerticalLayout') exec('self.'+treeId+'AttrList = QtGui.QListWidget(self.'+treeId+'_groupBox)') attrList = eval('self.'+treeId+'AttrList') attrList.setObjectName(treeId+'AttrList') attrVerticalLayout.addWidget(attrList) layoutItem.addLayout(attrVerticalLayout) self.__showMethodsInput(treeId, False) self.__showAttributsInput(treeId, False) self.__currentItems = {'behav':None, 'indiv':None} self.__codes = {} self.__updateAllTabs()
def __init__(self): self.targetSelect="All" self.pathSelect="All" self.variableSelect="All" self.timer = QtCore.QTimer() QtCore.QObject.connect(self.timer,QtCore.SIGNAL("timeout()"),self.timerFunc) self.timer.start(500) self.controller=Controller()
def initUI(self): device_data = get_iface_name() iface_num = len(device_data) iface_keys = device_data.keys() #???? self.radio_lists = [] self.gridlayout = QtGui.QGridLayout() self.label_name = QtGui.QLabel(u'???') self.label_ip = QtGui.QLabel(u'IP??') self.label_receive = QtGui.QLabel(u'????') self.label_send = QtGui.QLabel(u'????') self.gridlayout.addWidget(self.label_name, 1, 1) self.gridlayout.addWidget(self.label_ip, 1, 2) self.gridlayout.addWidget(self.label_receive, 1, 3) self.gridlayout.addWidget(self.label_send, 1, 4) self.setLayout(self.gridlayout) for i in range(iface_num): iface_name = iface_keys[i] self.iface_radio = QtGui.QRadioButton(iface_name) if iface_name == 'eth0': self.iface_radio.setChecked(True) self.gridlayout.addWidget(self.iface_radio, i+2, 1) self.radio_lists.append(self.iface_radio) self.ip_label = QtGui.QLabel(get_ip_address(iface_name)) self.gridlayout.addWidget(self.ip_label, i+2, 2) data = device_data[iface_name].split(';') self.receive_label = QtGui.QLabel(data[0]) self.send_label = QtGui.QLabel(data[1]) self.gridlayout.addWidget(self.receive_label, i+2, 3) self.gridlayout.addWidget(self.send_label, i+2, 4) self.setLayout(self.gridlayout) #???? self.start_but = QtGui.QPushButton(u'??', self) self.start_but.clicked.connect(self.exit_me) self.start_but.setCheckable(False) self.gridlayout.addWidget(self.start_but, iface_num + 2, 2) self.cancel_but = QtGui.QPushButton(u'??', self) self.connect(self.cancel_but, QtCore.SIGNAL('clicked()'), QtCore.SLOT('close()')) self.cancel_but.setCheckable(False) self.gridlayout.addWidget(self.cancel_but, iface_num + 2, 3)
def send(self, text, move_next = True): """ send a string to all selected terminals""" actives = self.elements.get_actives() any_closed = self.verify_selected() if any_closed: self.emit(SIGNAL('terminals_closed'), 'The following terminals are closed:\n' + ', '.join(any_closed)) else: for element in actives: if type(text) == utils.Var: self.elements.dic[element]['process'].send(text.stringOfElement(element).strip()) else: self.elements.dic[element]['process'].send(text.strip()) if move_next: self.emit(SIGNAL('move_next')) Kitty.show_main()
def call(self, line, move_next = True, decrement = 2): self.move_next = move_next error = False try: self.valid_command(line) if self.command: self.commanddict[self.command](line[len(self.command):]) else: self.send(line) except ValueError: error = True if not error and self.command != '#': self.emit(SIGNAL('set_tracking_mark'), decrement)
def close(self, arg): elements_to_close = self.kittysmanager.elements_to_close() if elements_to_close: self.emit(SIGNAL('close_terminals'), 'The following terminals are running:\n{}\nDo you want to close them?'.format(', '.join(elements_to_close)))
def set(self, arg): args = self.parse_line(arg) if len(args) < 2: self.emit(SIGNAL('wrong_set'), 'set require two parameters') raise ValueError('the instruction set require two parameters') else: key = args[0] value = arg[len(key)+1:].strip() self.var[key] = value self.verify_nextline()
def verify_nextline(self): if self.move_next: self.emit(SIGNAL('move_next'))
def paste(self): QsciScintilla.paste(self) self.emit(SIGNAL('paste'))
def __init__(self, parent = None): QDialog.__init__(self, parent) self.setupUi(self) self.setWindowTitle('Orquesta - new project') self.setFixedSize(self.WIDTH, self.HEIGHT) self.mainwindow = None self.project_name = '' self.lineedit_log_path.setText(self.default_log_path) for groups in os.listdir(self.cfg_path): self.combobox_term_group.addItem(groups.split('.')[0]) self.connect(self.button_log_path, SIGNAL('clicked()'), self.slot_change_log_path)