def mark_all_as_read(self): msg = QMessageBox(self.app.window.ui) msg.setIcon(QMessageBox.Question) msg.setWindowTitle("Mark all as read ...") msg.setText("Are you sure you want all posts marked as read?") msg.setStandardButtons(QMessageBox.Yes | QMessageBox.No) if msg.exec_() == QMessageBox.Yes: self.app.window.update_messages_as_read() self.app.db.set_all_unread_status(False) self.update()
def _validate_create_filename(self, path=None, check=True): if path is None: path = str(self.wcreate.text()) # if we have already validated this path, then return the last validation result. # This is mostly to keep from bombarding the user with repeated error dialogs. if self._validated_create_path == path: return self._validated_result self._validated_create_path = path self._validated_result = False; # set to True if all checks pass # now process the path. Normalize it, and expand "~" path = os.path.expanduser(os.path.normpath(path)) # if not absolute, join to current directory if not os.path.isabs(path): path = os.path.join(self.dirname, path) # collapse to "~" (for error messages) path0 = Kittens.utils.collapseuser(path) if os.path.exists(path): QMessageBox.warning(self, "Can't create purrlog", """Unable to create purrlog <tt>%s</tt>: file or directory already exists. Please select another name""" % path0) self.create_path and self.wcreate.setText(Kittens.utils.collapseuser(self.create_path)) return False if not os.access(os.path.dirname(os.path.normpath(path)) or '.', os.W_OK): QMessageBox.warning(self, "Can't create purrlog", """Unable to create purrlog <tt>%s</tt>: can't write to parent directory. Please select another path.""" % path0) self.create_path and self.wcreate.setText(Kittens.utils.collapseuser(self.create_path)) return False self.create_path = path self.wcreate.setText(path0) self._validated_result = True; # set to True if all checks pass if check: self.checkCompleteness() return True
def _assignPeptideSequence(self): """ (private) Slot for the "editingFinished()" signal generated by the PM_TextEdit whenever the user presses the Enter key in the sequence text edit field. Assigns the amino acid sequence in the sequence editor text field to the current protein. @attention: this method is not implemented yet. If called, it will display a messagebox warning the user that this is not implement yet. """ if not self.current_protein: return sequenceString = self.getPlainSequence() sequenceString = str(sequenceString) #assign sequence only if it not the same as the current sequence seq = self.current_protein.protein.get_sequence_string() if seq != sequenceString: #self.current_protein.setSequence(sequenceString) #self.updateSequence(cursorPos = self.getCursorPosition()) msg = "We are sorry. You cannot change the sequence since "\ "this feature is not yet supported." QMessageBox.warning(self.win, "Warning!", msg) self._suppress_textChanged_signal = False self.updateSequence(self.current_protein) return
def displayDialog(message, detailedMessage=None, title=None, level=logging.CRITICAL, dialogWidth=150): ''' A generic function to display the dialog in a QMessageBox message: Primary message to be displayed detailedMessage: detail message that is shown after user clicks on the button level: Message level dialogWidth: width of the messageBox ''' width = dialogWidth mainWin = WorkbenchHelper.window msgBox = QMessageBox (parent=mainWin) if detailedMessage: detailedMessage = 'Application ' + " encountered following problem :" + detailedMessage if len(message) < width: message += ' ' * (width - len(message)) msgBox.setWindowTitle(__getTitleFromLevel(level)) msgBox.setIcon(__getIconFromLevel(level)) msgBox.setText(message) if detailedMessage: msgBox.setDetailedText(detailedMessage) ret = msgBox.exec_()
def apply(self): #validate newcachedir = unicode(self.generalCacheLocation.text()) newcachedir = newcachedir.strip() if newcachedir.endswith(os.path.sep): newcachedir = newcachedir[:-1] if not os.path.isdir(newcachedir): QMessageBox.information(self, "QOSM Error", "'%s' is not a directory" % newcachedir) return False if (not len(os.listdir(newcachedir)) == 0) and \ ((newcachedir != s._defaultsetting(s.CACHE_DIRECTORY)) and (newcachedir != s.get(s.CACHE_DIRECTORY))): if QMessageBox.Ok != QMessageBox.question(self, "Question", "Use non-emtpy directory for cache?", QMessageBox.Ok | QMessageBox.Cancel): return False if newcachedir == s._defaultsetting(s.CACHE_DIRECTORY): s.reset(s.CACHE_DIRECTORY) self.generalCacheLocation.setText(s.get(s.CACHE_DIRECTORY)) else: s.put(s.CACHE_DIRECTORY, newcachedir) self.generalCacheLocation.setText(newcachedir) if self.generalMaxTiles.value() == s._defaultsetting(s.MAX_TILES): s.reset(s.MAX_TILES) else: s.put(s.MAX_TILES, self.generalMaxTiles.value()) s.put(s.AUTODOWNLOAD, self.autoDownload.isChecked()) self.apply_customtypes() self.calculate_cachesize() return True
def load_wallet(self, wallet): self.wallet = wallet if self.trezor_is_connected(): if not self.wallet.check_proper_device(): QMessageBox.information(self.window, _('Error'), _("This wallet does not match your Trezor device"), _('OK')) else: QMessageBox.information(self.window, _('Error'), _("Trezor device not detected.\nContinuing in watching-only mode."), _('OK'))
def popupWindow(self, title, message): self.msg = QMessageBox() self.msg.setIcon(QMessageBox.Information) self.msg.setWindowTitle(title) self.msg.setText(message) self.msg.setStandardButtons(QMessageBox.Ok) self.msg.exec_()
def createNewFolder(self, folderName, currentItem, parentDirectoryId): #Invoked by onNewFolderAction() on a worker thread from AppController import AppController bloopTreeController = AppController.getInstance().getMainViewController().getBloopTreeController() mainView = AppController.getInstance().getMainView() mainView.statusBar().showMessage(i18n.LABEL_BLOOPTREE_STATUS_BAR_CREATING_FOLDER) remoteSession = AppController.getInstance().getRemoteSession() # Setting the new folder as public by default. We could contorl this by either having # a checkbox option in the Settings dialog or showing a [x] Mark Private field on the # QInputDialog? Will learn how to do that later. result = remoteSession.createFolder(folderName, parentDirectoryId, False) print remoteSession.getCallStatus() # If the call failed, the result will contain the response message. if remoteSession.getCallStatus() == '0': from PyQt4.Qt import QMessageBox QMessageBox.critical(mainView, i18n.LABEL_CONFIRM_RENAME_FILE_FAILED_TITLE, result); mainView.statusBar().showMessage("") return # Update the folder contents bloopTreeController.addItems(currentItem) # Open up the folder if it's not open already currentItem.setExpanded(True) mainView.statusBar().showMessage(i18n.LABEL_BLOOPTREE_STATUS_BAR_FOLDER_CREATED) return
def renameItem(self,currentItem, itemData, itemType, itemId, newName): from AppController import AppController AppController.getInstance().getMainView().statusBar().showMessage(i18n.LABEL_BLOOPTREE_STATUS_BAR_RENAMING) remoteSession = AppController.getInstance().getRemoteSession() result = remoteSession.renameItem(itemType, itemId, str(newName)) # If it was unsuccessful then lets display an error message if result['status'] == '0': from PyQt4.Qt import QMessageBox QMessageBox.critical(AppController.getInstance().getMainView(), i18n.LABEL_CONFIRM_RENAME_FILE_FAILED_TITLE, result['response'], QMessageBox.Ok, QMessageBox.Ok); AppController.getInstance().getMainView().statusBar().showMessage("") return # Update the data of the item in the list if currentItem.isFile(): currentItem.setText(0, result['fileName']) itemData['fileName'] = result['fileName'] itemData['fileURL'] = result['fileURL'] currentItem.setItemData(itemData) elif currentItem.isDirectory(): currentItem.setText(0, result['directoryName']) itemData['directoryName'] = result['directoryName'] currentItem.setItemData(itemData) AppController.getInstance().getMainView().statusBar().showMessage(i18n.LABEL_BLOOPTREE_STATUS_BAR_RENAMING_FINISHED) return
def load_wallet(self, wallet, window): self.print_error("load_wallet") self.wallet = wallet self.window = window self.wallet.plugin = self self.trezor_button = StatusBarButton(QIcon(":icons/trezor.png"), _("Trezor"), self.settings_dialog) self.window.statusBar().addPermanentWidget(self.trezor_button) if self.handler is None: self.handler = TrezorQtHandler(self.window.app) try: self.get_client().ping("t") except BaseException as e: QMessageBox.information( self.window, _("Error"), _("Trezor device not detected.\nContinuing in watching-only mode." + "\n\nReason:\n" + str(e)), _("OK"), ) self.wallet.force_watching_only = True return if self.wallet.addresses() and not self.wallet.check_proper_device(): QMessageBox.information( self.window, _("Error"), _("This wallet does not match your Trezor device"), _("OK") ) self.wallet.force_watching_only = True
def searchForPassphrase(): # Get the selected wallet from the main screen wlt = self.getSelectedWlt() if wlt and not wlt.watchingOnly and wlt.isLocked: self.resultStr = '' self.passPhraseFinder = PassPhraseFinder(wlt) self.resultsDisplay.setText(QString('')) self.main.extraHeartbeatAlways.append(updateDisplay) if len(self.segOrdStrSet) > 0: # From self.segOrdStrList, create a list of lists of indexes that describe the segment orderings to search # In other words convert all of the strings in orderings list to lists of integers segOrdIntListList = [] for ordStr in self.segOrdStrSet: # The indexes provided by the users are 1 based, and the list indexes ought to be 0 based segOrdIntListList.append([int(indexStr)-1 for indexStr in ordStr.split(',')]) self.searchThread = PyBackgroundThread(self.passPhraseFinder.searchForPassPhrase, [segDef.getSegList() for segDef in self.segDefList], segOrdIntListList, updateResults, terminateSearch ) # Reset the isSearchOver flag self.isSearchOver = False self.searchThread.start() # Disable search button adn enabled stop button self.stopButton.setEnabled(True) self.searchButton.setEnabled(False) else: QMessageBox.warning(self.main, tr('Invalid'), tr(""" There are no valid segment combinations to search. Please add at least one segment and ordering to search."""), QMessageBox.Ok) else: QMessageBox.warning(self.main, tr('Invalid'), tr(""" No valid wallet is selected. Please select a locked non-watching-only from Available Wallets."""), QMessageBox.Ok)
def callback_PassphraseRequest(self, req): msg = _("Please enter your Trezor passphrase.") passphrase = trezor_passphrase_dialog(msg) if passphrase is None: QMessageBox.critical(None, _('Error'), _("Password request canceled"), _('OK')) return proto.Cancel() return proto.PassphraseAck(passphrase=passphrase)
def _fileSelected(self, filename, quiet=False): self.wokbtn.setEnabled(False) if not filename: return None # check that filename matches model if not os.path.samefile(self._model_dir, os.path.dirname(filename)): self.wfile.setFilename('') if not quiet: QMessageBox.warning( self, "Directory mismatch", """<P>The FITS file must reside in the same directory as the current sky model.</P>""") self.wfile.setDirectory(self._model_dir) return None # if filename is not in model already, enable the "add to model" control for src in self.model.sources: if isinstance(getattr(src, 'shape', None), ModelClasses.FITSImage): if os.path.exists(src.shape.filename) and os.path.samefile( src.shape.filename, filename): if not quiet: QMessageBox.warning( self, "Already in model", "This FITS brick is already present in the model.") self.wfile.setFilename('') return None if not str(self.wname.text()): self.wname.setText( os.path.splitext(os.path.basename(str(filename)))[0]) self.wokbtn.setEnabled(True) return filename
def load_wallet(self, wallet, window): self.print_error("load_wallet") self.wallet = wallet self.window = window self.wallet.plugin = self self.keepkey_button = StatusBarButton(QIcon(":icons/keepkey.png"), _("KeepKey"), self.settings_dialog) if type(window) is ElectrumWindow: self.window.statusBar().addPermanentWidget(self.keepkey_button) if self.handler is None: self.handler = KeepKeyQtHandler(self.window) try: self.get_client().ping('t') except BaseException as e: QMessageBox.information( self.window, _('Error'), _("KeepKey device not detected.\nContinuing in watching-only mode." + '\n\nReason:\n' + str(e)), _('OK')) self.wallet.force_watching_only = True return if self.wallet.addresses() and not self.wallet.check_proper_device(): QMessageBox.information( self.window, _('Error'), _("This wallet does not match your KeepKey device"), _('OK')) self.wallet.force_watching_only = True
def QuestionDialog(title, text, info = None, dontAsk = False): msgBox = QMessageBox() buttonYes = msgBox.addButton(_("Yes"), QMessageBox.ActionRole) buttonNo = msgBox.addButton(_("No"), QMessageBox.ActionRole) answers = {buttonYes:"yes", buttonNo :"no"} if dontAsk: buttonDontAsk = msgBox.addButton(_("Don't ask again"), QMessageBox.ActionRole) answers[buttonDontAsk] = "dontask" msgBox.setText(text) if not info: info = _("Do you want to continue?") msgBox.setInformativeText(info) dialog = Dialog(_(title), msgBox, closeButton = False, isDialog = True, icon="question") dialog.resize(300,120) dialog.exec_() ctx.mainScreen.processEvents() if msgBox.clickedButton() in answers.keys(): return answers[msgBox.clickedButton()] return "no"
def load_wallet(self, wallet, window): self.print_error("load_wallet") self.wallet = wallet self.wallet.plugin = self self.keepkey_button = StatusBarButton( QIcon(":icons/keepkey.png"), _("KeepKey"), partial(self.settings_dialog, window) ) if type(window) is ElectrumWindow: window.statusBar().addPermanentWidget(self.keepkey_button) if self.handler is None: self.handler = KeepKeyQtHandler(window) try: self.get_client().ping("t") except BaseException as e: QMessageBox.information( window, _("Error"), _("KeepKey device not detected.\nContinuing in watching-only mode." + "\n\nReason:\n" + str(e)), _("OK"), ) self.wallet.force_watching_only = True return if self.wallet.addresses() and not self.wallet.check_proper_device(): QMessageBox.information(window, _("Error"), _("This wallet does not match your KeepKey device"), _("OK")) self.wallet.force_watching_only = True
def canvasReleaseEvent(self, event): x = event.pos().x() y = event.pos().y() # TODO layer automatisch speichern damit das polygon eine id von der db kriegt # Ugly hack to identify the clicked element. For some reasons if InfoPointTool inherits from QgsMapToolIdentify, # canvasRealeaseEvent isn't called. tool = QgsMapToolIdentify(self.canvas) results = tool.identify(x,y, tool.ActiveLayer, tool.AllLayers) if not results: return guiName = self.canvas.currentLayer().name() dbName = self.canvas.currentLayer().dataProvider().dataSourceUri().split(' ')[0].split('=')[1].replace("'", '') result = results[0] feat = result.mFeature attrs = feat.attributes() fields = feat.fields().toList() fieldId = None for i, attr in enumerate(attrs): name = fields[i].name() if name == 'id' and attr is not None: fieldId = str(attr) break if fieldId is None: QMessageBox.warning(None, "Ungespeicherte Aenderungen", "Sie muessen das Polygon zuerst speichern") return DynamicGuiLoader(dbName, guiName, fieldId)
def displayAbout(self): msgBox = QMessageBox() msgBox.setTextFormat(Qt.RichText) msgBox.setWindowTitle("Data Extractor for reddit") msgBox.setText(""" <p>This program uses the following open source software:<br> <a href="http://www.riverbankcomputing.co.uk/software/pyqt/intro">PyQt</a> under the GNU GPL v3 license <br> <a href="https://praw.readthedocs.org/en/v2.1.16/">PRAW (Python Reddit API Wrapper)</a> under the GNU GPL v3 license <br> <a href="http://docs.python-requests.org/en/latest/">Requests</a> under the Apache2 license <br> <a href="http://www.crummy.com/software/BeautifulSoup/">Beautiful Soup</a> under a simplified BSD licence <br> <a href="https://github.com/rg3/youtube-dl">youtube-dl</a> under an unlicense (public domain) </p> <p>This program makes use of a modified version of <a href="https://www.videolan.org/vlc/">VLC's</a> logo:<br> Copyright (c) 1996-2013 VideoLAN. This logo or a modified version may<br> be used or modified by anyone to refer to the VideoLAN project or any<br> product developed by the VideoLAN team, but does not indicate<br> endorsement by the project. </p> <p>This program makes use of a modified version of Microsoft Window's<br> .txt file icon. This is solely the property of Microsoft Windows<br> and I claim no ownership. </p> <p>This program is released under the GNU GPL v3 license<br> <a href="https://www.gnu.org/licenses/quick-guide-gplv3.html">GNU GPL v3 license page</a><br> See <a href="https://github.com/NSchrading/redditDataExtractor/blob/master/LICENSE.txt">LICENSE.txt</a> for more information. </p> """) msgBox.exec()
def removeLst(self): name = self._lstChooser.currentText() if len(name) <= 0: return msgBox = confirmDialog("Are you sure you want to delete the " + self.objectName() + " list: " + name + "?") ret = msgBox.exec_() if ret == QMessageBox.Yes: if len(self._chooserDict) <= 0: QMessageBox.information( QMessageBox(), "Data Extractor for reddit", "There are no more lists left to delete.") return self._lstChooser.removeItem(self._lstChooser.currentIndex()) del self._chooserDict[name] defaultName = self._rddtDataExtractor.defaultSubredditListName # if default is not being removed, just remove and switch to default if name != defaultName: self.removeNonDefaultLst() else: if len(self._chooserDict) > 0: # just choose the first model self.removeDefaultLst() else: self.removeLastLst() self._gui.setUnsavedChanges(True)
def callback_PassphraseRequest(self, msg): confirmed, p, passphrase = self.password_dialog() if not confirmed: QMessageBox.critical(None, _('Error'), _("Password request canceled"), _('OK')) return proto.Cancel() if passphrase is None: passphrase='' # Even blank string is valid Trezor passphrase return proto.PassphraseAck(passphrase=passphrase)
def configure(self): super(SDEPlugin, self).configure() while self.optimize_enabled and \ self.maximum_kernel <= self.minimum_kernel: QMessageBox.warning(None, 'Unable to set parameters', 'Maximum kernel size needs to be larger than ' + 'minimum kernel size!') super(SDEPlugin, self).configure()
def give_error(self, message, clear_client = False): if not self.signing: QMessageBox.warning(QDialog(), _('Warning'), _(message), _('OK')) else: self.signing = False if clear_client: self.client.bad = True raise Exception(message)
def load_wallet(self, wallet): if self.btchip_is_connected(): if not self.wallet.check_proper_device(): QMessageBox.information(self.window, _('Error'), _("This wallet does not match your BTChip device"), _('OK')) self.wallet.force_watching_only = True else: QMessageBox.information(self.window, _('Error'), _("BTChip device not detected.\nContinuing in watching-only mode."), _('OK')) self.wallet.force_watching_only = True
def restore_from_archive(self, parent=None): """Function to restore a DP from archived copy Asks for confirmation along the way if parent is not None (in which case it will be the parent widget for confirmation dialogs) """ from PyQt4.Qt import QMessageBox exists = os.path.exists(self.sourcepath) if parent: msg = """<P>Do you really want to restore <tt>%s</tt> from this entry's copy of <tt>%s</tt>?</P>""" % (self.sourcepath, self.filename) exists = os.path.exists(self.sourcepath) if exists: msg += """<P>Current file exists, and will be overwritten.</P>""" if QMessageBox.warning(parent, "Restoring from archive", msg, QMessageBox.Yes, QMessageBox.No) != QMessageBox.Yes: return False else: if QMessageBox.question(parent, "Restoring from archive", msg, QMessageBox.Yes, QMessageBox.No) != QMessageBox.Yes: return False busy = Purr.BusyIndicator() # remove file if in the way if exists: if os.system("/bin/rm -fr '%s'" % self.sourcepath): busy = None if parent: QMessageBox.warning(parent, "Error removing file", """<P> There was an error removing %s. Archived copy was not restored. The text console may have more information.</P>""" % self.sourcepath, QMessageBox.Ok, 0) return False # unpack archived file if self.fullpath.endswith('.tgz'): parent_dir = os.path.dirname(self.sourcepath.rstrip('/')) os.system("/bin/rm -fr %s" % self.sourcepath) if os.system("tar zxf '%s' -C '%s'" % (self.fullpath, parent_dir)): busy = None if parent: QMessageBox.warning(parent, "Error unpacking file", """<P> There was an error unpacking the archived version to %s. The text console may have more information.</P>""" % self.sourcepath, QMessageBox.Ok, 0) return False # else simply copy over else: if os.system("/bin/cp -a '%s' '%s'" % (self.fullpath, self.sourcepath)): busy = None if parent: QMessageBox.warning(parent, "Error copying file", """<P> There was an error copying the archived version to %s. The text console may have more information.</P>""" % self.sourcepath, QMessageBox.Ok, 0) return False busy = None if parent: QMessageBox.information(parent, "Restored file", """<P>Restored %s from this entry's archived copy.</P>""" % self.sourcepath, QMessageBox.Ok, 0) return True
def getTitleData(self, titleToGet): data = json.dumps({'command':'get_title', 'title':titleToGet}) data = requests.post('http://shinowa.tk/lab6/add_book.php', data) if(data.status_code != 200): QMessageBox.warning(None, "Failure", "Connection failure") return "Empty" return data.json()[0]
def addToList(self): if self._rddtDataExtractor.currentlyDownloading: QMessageBox.warning(QMessageBox(), "Data Extractor for reddit", "Cannot add while currently downloading. Please wait.") return model = self.model() if model is not None: model.insertRows(model.rowCount(), 1) self._gui.setUnsavedChanges(True)
def addOrdering(): if len(self.segDefList) > 0: dlgSpecifyOrdering = DlgSpecifyOrdering(main, main, len(self.segDefList)) if dlgSpecifyOrdering.exec_(): self.segOrdStrSet.add(str(dlgSpecifyOrdering.parseOrderingList()).strip('[]')) self.updateOrderingListBox() else: QMessageBox.warning(self.main, tr('Not Ready'), tr(""" No segments have been entered. You must enter some segments before you can order them."""), QMessageBox.Ok)
def give_error(self, message, clear_client = False): if not self.signing: QMessageBox.warning(QDialog(), _('Warning'), _(message), _('OK')) else: self.signing = False if clear_client and self.client is not None: self.client.bad = True self.device_checked = False raise Exception(message)
def LoadAction(self): if not self.MainProgramm.DataSaved : msgbox = QMessageBox(QMessageBox.Question, "Frage", "Soll die vorherige Messung ueberschrieben werden ?", QMessageBox.No| QMessageBox.Yes) if not msgbox.exec_() == QMessageBox.Yes: return filename = QFileDialog.getOpenFileName(self,"Messung laden") if not filename == '': self.MainProgramm.LoadFile(filename) return
def configure(self): super(SDEPlugin, self).configure() while self.optimize_enabled and \ self.maximum_kernel <= self.minimum_kernel: QMessageBox.warning( None, 'Unable to set parameters', 'Maximum kernel size needs to be larger than ' 'minimum kernel size!') super(SDEPlugin, self).configure()
def give_error(self, message, clear_client=False): if not self.signing: QMessageBox.warning(QDialog(), _('Warning'), _(message), _('OK')) else: self.signing = False if clear_client and self.client is not None: self.client.bad = True self.device_checked = False raise Exception(message)
def installwizard_restore(self, wizard, storage): if storage.get('wallet_type') != 'btchip': return wallet = MUEhipWallet(storage) try: wallet.create_main_account(None) except BaseException as e: QMessageBox.information(None, _('Error'), str(e), _('OK')) return return wallet
def installwizard_restore(self, wizard, storage): if storage.get("wallet_type") != "btchip": return wallet = BTChipWallet(storage) try: wallet.create_main_account(None) except BaseException as e: QMessageBox.information(None, _("Error"), str(e), _("OK")) return return wallet
def removeTitle(titleToRemove): data = json.dumps({'command':'remove_book', 'titleToRemove':titleToRemove}) r = requests.post('http://shinowa.tk/lab6/add_book.php', data) print r.status_code if(r.status_code == 200): QMessageBox.warning(None, "Success", "Title removed successfully") elif(r.status_code == 404): QMessageBox.warning(None, "Failure", "Failed to remove title")
def installwizard_restore(self, wizard, storage): if storage.get('wallet_type') != 'trezor': return wallet = TrezorWallet(storage) try: wallet.create_main_account(None) except BaseException as e: QMessageBox.information(None, _('Error'), str(e), _('OK')) return return wallet
def _get_int(self, i, j): try: if not self._is_empty(i,j): int_val = int(float(self.two_by_two_table.item(i, j).text())) return int_val except: # Should never appear.... msg = "Could not convert %s to integer" % self.two_by_two_table.item(i, j) QMessageBox.warning(self.parent(), "whoops", msg) raise Exception("Could not convert %s to int" % self.two_by_two_table.item(i, j))
def viewDownloadedContent(self): """ Show the downloaded content dialog GUI for the selected user / subreddit """ if self._rddtDataExtractor.currentlyDownloading: QMessageBox.warning( QMessageBox(), "Data Extractor for reddit", "Cannot view downloads while currently downloading. Please wait." ) return model = self.model() index = self.getCurrentSelectedIndex() if model is not None and index is not None: selected = model.getObjectInLst(index) downloadedContent = selected.redditSubmissions if downloadedContent is not None and len(downloadedContent) > 0: downloadedContentGUI = DownloadedContentGUI( selected, self.model(), confirmDialog, self._gui.saveState) downloadedContentGUI.exec_() else: QMessageBox.information( QMessageBox(), "Data Extractor for reddit", selected.name + " has no downloaded content. Download some by hitting the download button." ) elif index is None: QMessageBox.information( QMessageBox(), "Data Extractor for reddit", "To view a " + self.objectName() + "'s downloaded content, please select a " + self.objectName() + " in the " + self.objectName() + " list.")
def _save_dialog(self, parent, title, msg, det_msg=''): d = QMessageBox(parent) d.setWindowTitle(title) d.setText(msg) d.setStandardButtons(QMessageBox.Yes | QMessageBox.No | QMessageBox.Cancel) return d.exec_()
def _onConflictSaveAsButton(self): filePath = QFileDialog.getSaveFileName(self.conflictDialog, QApplication.translate('VectorLayerSaveConflictController', 'Save File'), "", QApplication.translate('VectorLayerSaveConflictController', 'Files (*.csv *.tsv *.*)')); if filePath: self.conflictDialog.accept() try: self.csvDataSourceHandler.moveDataSourcesToPath(filePath) self.csvDataSourceHandler.syncFeaturesWithCsv(self.csvVectorLayer().vectorLayerDescriptor, self.features, filePath) self.csvVectorLayer().updateGeoCsvPath(filePath) NotificationHandler.pushSuccess(QApplication.translate('VectorLayerSaveConflictController', 'CSV File updated'), QApplication.translate('VectorLayerSaveConflictController', 'Changes to layer "{}" successfully stored in csv file.').format(self.csvVectorLayer().qgsVectorLayer.name())) except: QMessageBox.information(None, QApplication.translate('VectorLayerSaveConflictController', 'Invalid path'), QApplication.translate('VectorLayerSaveConflictController', 'An error occured while trying to save file on new location. Please try again.'))
def deleteFromList(self): if self._rddtDataExtractor.currentlyDownloading: QMessageBox.warning(QMessageBox(), "Data Extractor for reddit", "Cannot remove while currently downloading. Please wait.") return model = self.model() index = self.getCurrentSelectedIndex() if model is not None and index is not None: row = index.row() model.removeRows(row, 1) self._gui.setUnsavedChanges(True)
def load_scenarios(self): if not self.project.load_tranus_folder(self.tranus_project): self.tranus_workspace.setText('') self.save_settings() QMessageBox.warning(None, "Invalid Tranus project", "Please select a valid workspace") print "Invalid Tranus project , Please select a valid workspace" self.reload_scenarios() self.activate_launch_button()
def _select_other_dialog(self): path = str(QFileDialog.getExistingDirectory(self, "Select purrlog", self.dirname)) if not path: return if not Purr.Purrer.is_purrlog(path): QMessageBox.warning(self, "Invalid purrlog", "The path you have selected, <tt>%s</tt>, does not refer to a valid purrlog." % Kittens.utils.collapseuser( path)) return self.load_path = path self.wother.setText(Kittens.utils.collapseuser(path)) self.checkCompleteness()
def LoadAction(self): if not self.MainProgramm.DataSaved: msgbox = QMessageBox( QMessageBox.Question, "Frage", "Soll die vorherige Messung ueberschrieben werden ?", QMessageBox.No | QMessageBox.Yes) if not msgbox.exec_() == QMessageBox.Yes: return filename = QFileDialog.getOpenFileName(self, "Messung laden") if not filename == '': self.MainProgramm.LoadFile(filename) return
def load_wallet(self, wallet, window): self.wallet = wallet self.wallet.plugin = self if self.handler is None: self.handler = BTChipQTHandler(window) if self.btchip_is_connected(): if not self.wallet.check_proper_device(): QMessageBox.information(window, _('Error'), _("This wallet does not match your Ledger device"), _('OK')) self.wallet.force_watching_only = True else: QMessageBox.information(window, _('Error'), _("Ledger device not detected.\nContinuing in watching-only mode."), _('OK')) self.wallet.force_watching_only = True
def deleteServer(self): """Delete a server. """ if len(self.servers) == 1: msg = "At least 1 server must exist. After deleting the last one, "\ "a default new server will be created." QMessageBox.information(self, "Deleting a server", msg, QMessageBox.Ok) item = self.server_listview.currentIndex() self.server_listview.takeItem(item) del self.servers[self.items.index(item)] self.items.remove(item) print "After deleting." return
def about(self): # Get the about text from a file inside the plugin zip file # The get_resources function is a builtin function defined for all your # plugin code. It loads files from the plugin zip file. It returns # the bytes from the specified file. # # Note that if you are loading more than one file, for performance, you # should pass a list of names to get_resources. In this case, # get_resources will return a dictionary mapping names to bytes. Names that # are not found in the zip file will not be in the returned dictionary. text = get_resources('about.txt') QMessageBox.about(self, 'About the Interface Plugin Demo', text.decode('utf-8'))
def _deleteContent(self, downloadedContentType): """ Delete the selected content :type downloadedContentType: RedditDataExtractor.downloader.DownloadedContentType """ currentLstModelObj = self._getCurrentLstModelObj() currentTab = self.tabWidget.currentWidget() currentTabLst = currentTab.findChild(QListWidget) currentTabLstItem = currentTabLst.currentItem() submissionURL = currentTabLstItem.text() downloadedContentForSubmission = currentLstModelObj.redditSubmissions.get( submissionURL) for content in downloadedContentForSubmission: if content.type == downloadedContentType: files = content.files numFiles = len(files) if numFiles <= 20: # avoid making a super long list that is hard to read fileStr = "".join([str(file) + "\n" for file in files]) else: fileStr = "".join( [str(file) + "\n" for file in files[:20]]) fileStr += "\n...\nand " + str(numFiles - 20) + " others. " msgBox = self._confirmDialog( "This will delete these files: \n" + fileStr + "Are you sure you want to delete them?") ret = msgBox.exec_() if ret == QMessageBox.Yes: downloadedContentForSubmission.remove(content) if (len(downloadedContentForSubmission) <= 0): del currentLstModelObj.redditSubmissions[submissionURL] else: currentLstModelObj.redditSubmissions[ submissionURL] = downloadedContentForSubmission if downloadedContentType is not DownloadedContentType.JSON_DATA: for externalURL in content.externalDownloadURLs: if externalURL in currentLstModelObj.externalDownloads: currentLstModelObj.externalDownloads.remove( externalURL) item = currentTabLst.takeItem(currentTabLst.currentRow()) del item # PyQt documentation says the item won't be garbage collected automatically after using takeItem() content.deleteFiles() del content QMessageBox.information( QMessageBox(), "Data Extractor for reddit", "Successfully removed requested files.") self._saveState() return True return False return False
def passphrase_dialog(self): from electrum_oracoin_gui.qt.password_dialog import make_password_dialog, run_password_dialog d = QDialog() d.setModal(1) d.setLayout(make_password_dialog(d, None, self.message, False)) confirmed, p, passphrase = run_password_dialog(d, None, None) if not confirmed: QMessageBox.critical(None, _('Error'), _("Password request canceled"), _('OK')) self.passphrase = None else: if passphrase is None: passphrase = '' # Even blank string is valid Trezor passphrase self.passphrase = unicodedata.normalize('NFKD', unicode(passphrase)) self.done.set()
def run(self, path_to_ebook): from calibre.gui2 import is_ok_to_use_qt from PyQt4.Qt import QMessageBox PID = self.site_customization data_file = file(path_to_ebook, 'rb').read() ar = PID.split(',') for i in ar: try: unlocked_file = DrmStripper(data_file, i).getResult() except DrmException: # ignore the error pass else: of = self.temporary_file('.mobi') of.write(unlocked_file) of.close() return of.name if is_ok_to_use_qt(): d = QMessageBox( QMessageBox.Warning, "MobiDeDRM Plugin", "Couldn't decode: %s\n\nImporting encrypted version." % path_to_ebook) d.show() d.raise_() d.exec_() return path_to_ebook
def importFromIOSFile(assy, fileName1): """ Imports optimized sequences to NE-1 from IOS file @param assy: the NE1 assy. @type assy: L{assembly} @param fileName1: IOS Import file @type fileName1: string @return: Returns True or False based on whether import was successful @note: Since DNA Strand Chunks do not get stored in the mmp file, there's no way, chunk by chunk info can be verified between the structure on the NE-1 window and that in the IOS file. The most that can be done is to verify the name of the strand Name info and their lengths. For instance if two NE-1 structures have the same name and number of strands,each of same length, but their pairing info is different, there's no way to check that and the sequences will get imported anyways. There IOS import happens at the user's risk. """ strandsOnScreen = checkStrandsOnNE_1Window(assy) if strandsOnScreen == False: msg = "Cannot import since currently IOS import is supported only for DNA strands and there are no DNA strands on the screen. There is also no support for importing into clipboard." QMessageBox.warning(assy.win, "Warning!", msg) return False fileName2 = doInitialProcessingOnXMLFile(fileName1) strandNameSeqDict = getHybridizationInfo(fileName2) if strandNameSeqDict is None: # Can remove the temp file if os.path.exists(fileName2): os.remove(fileName2) return False infoCorrect = verifyStructureInfo(assy, strandNameSeqDict) if infoCorrect: #import optimized bases from the IOS file importBases(assy, strandNameSeqDict) else: if os.path.exists(fileName2): os.remove(fileName2) return False if os.path.exists(fileName2): os.remove(fileName2) return True
def simAbort(self): """ Slot for Abort button. """ if debug_flags.atom_debug and self.sim_abort_button_pressed: #bruce 060106 print "atom_debug: self.sim_abort_button_pressed is already True before we even put up our dialog" # Added confirmation before aborting as part of fix to bug 915. Mark 050824. # Bug 915 had to do with a problem if the user accidently hit the space bar or espace key, # which would call this slot and abort the simulation. This should no longer be an issue here # since we aren't using a dialog. I still like having this confirmation anyway. # IMHO, it should be kept. Mark 060106. ret = QMessageBox.warning( self, "Confirm", "Please confirm you want to abort.\n", "Confirm", "Cancel", "", 1, # The "default" button, when user presses Enter or Return (1 = Cancel) 1) # Escape (1= Cancel) if ret == 0: # Confirmed for abortHandler in self.abortableCommands.values(): abortHandler.pressed()