Exemplo n.º 1
0
 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 _checkClientIdLineEdit(self):
     if len(self.clientIdLineEdit.text()) <= 0:
         QMessageBox.warning(
             QMessageBox(), "Data Extractor for reddit",
             "Please enter your client-id in the box and then press 'Enter Client-id'."
         )
         return False
     if not self._validClientId():
         QMessageBox.warning(
             QMessageBox(), "Data Extractor for reddit",
             "The client-id you entered does not appear to be valid. Check the value and try again."
         )
         return False
     self.accept()
     return True
    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 show_err_dialog(s):
    msg = QMessageBox()
    msg.setIcon(QMessageBox.Warning)
    msg.setText(s)
    msg.setWindowTitle("Warning!")
    msg.setStandardButtons(QMessageBox.Ok)
    msg.exec_()
 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_()
Exemplo n.º 6
0
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"
Exemplo n.º 7
0
 def viewRemainingImgurRequests(self):
     msgBox = QMessageBox()
     msgBox.setWindowTitle("Data Extractor for reddit")
     if self._rddtDataExtractor.imgurAPIClientID is not None:
         headers = {
             'Authorization':
             'Client-ID ' + self._rddtDataExtractor.imgurAPIClientID
         }
         apiURL = "https://api.imgur.com/3/credits"
         requestsSession = requests.session()
         requestsSession.headers[
             'User-Agent'] = 'Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2049.0 Safari/537.36'
         json = exceptionSafeJsonRequest(
             requestsSession,
             apiURL,
             headers=headers,
             stream=True,
             verify='RedditDataExtractor/cacert.pem')
         if json is not None and json.get('data') is not None and json.get(
                 'data').get('ClientRemaining'):
             msgBox.setText("You have " +
                            str(json.get('data').get('ClientRemaining')) +
                            " requests remaining.")
         else:
             msgBox.setText(
                 "A problem occurred using the Imgur API. Check that you are connected to the internet and make sure your client-id is correct."
             )
     else:
         msgBox.setText(
             "You do not currently have an Imgur client-id set. To set one, go to settings and check 'Change / Reset Client-id'"
         )
     msgBox.exec()
Exemplo n.º 8
0
 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)
Exemplo n.º 9
0
 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
Exemplo n.º 10
0
 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 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)
Exemplo n.º 12
0
 def SaveFile(self, Filenmame):
     if not SaveData(self.RecordingTmpFile, self.JointList,
                     self.ReferencePoint, Filenmame):
         QMessageBox(QMessageBox.Critical,
                     "Fehler",
                     "Speichern der Datei fehlgeschlagen",
                     buttons=QMessageBox.Ok).exec_()
     else:
         self.DataSaved = True
Exemplo n.º 13
0
def confirmDialog(message):
    """
    Make a simple Yes / No confirmation dialog box with a message
    :type message: str
    """
    msgBox = QMessageBox()
    msgBox.setText(message)
    msgBox.setStandardButtons(QMessageBox.Yes | QMessageBox.No)
    msgBox.setDefaultButton(QMessageBox.No)
    return msgBox
 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)
Exemplo n.º 15
0
 def msgbox(hsgui, title, msg):
     # Make a non modal critical QMessageBox
     msgBox = QMessageBox( hsgui );
     msgBox.setAttribute( Qt.WA_DeleteOnClose )
     msgBox.setStandardButtons( QMessageBox.Ok )
     msgBox.setWindowTitle( title )
     msgBox.setText( msg )
     msgBox.setModal( False )
     msgBox.open( msgBox.close )
     msgBox.show()
     hsgui.non_modal_qt_handles.append(msgBox)
Exemplo n.º 16
0
 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
Exemplo n.º 17
0
def emergency_msgbox(title, msg):
    'Make a non modal critical QMessageBox.'
    from PyQt4.Qt import QMessageBox
    msgBox = QMessageBox(None)
    msgBox.setAttribute(Qt.WA_DeleteOnClose)
    msgBox.setStandardButtons(QMessageBox.Ok)
    msgBox.setWindowTitle(title)
    msgBox.setText(msg)
    msgBox.setModal(False)
    msgBox.open(msgBox.close)
    msgBox.show()
    return msgBox
    def handleInfo(self):
            msg = QMessageBox()
            #msg.setFixedSize(500, 300)
            #msg.setGeometry(100,100, 400, 200)
            msg.setIcon(QMessageBox.Information)
            msg.setText("Axel Schneider")
            msg.setInformativeText(unicode(u"©2016"))
            msg.setWindowTitle("Cut Video")
            msg.setDetailedText("Python Qt4")
            msg.setStandardButtons(QMessageBox.Ok)
	
            retval = msg.exec_()
            print "value of pressed message box button:", retval
Exemplo n.º 19
0
 def startDeleting(self):
     reply = QtGui.QMessageBox.warning(
         self, "Caution: Deleting Permanently",
         "You are about to PERMANENTLY remove accounts and ALL the saved data related to those accounts.  Are you sure you want to continue?",
         QtGui.QMessageBox.Yes, QtGui.QMessageBox.No)
     if reply == QtGui.QMessageBox.Yes:
         delDate = self.ui.delDate.date().toPyDate()
         UsrFuncs.cleanOutDeletedAccounts(delDate)
         alert = QMessageBox()
         alert.setWindowTitle("Complete")
         alert.setText("Clean up completed")
         alert.exec_()
         return
Exemplo n.º 20
0
    def LoadFile(self, Filename):
        data = LoadData(Filename)
        if data[0]:  #Wurde allles korrekt gelesen?
            self.RecordingTmpFile, self.JointList, self.ReferencePoint = data[
                1]
            self.Window.playback_radio.setEnabled(True)
            self.Window.playback_radio.setChecked(True)

        else:
            QMessageBox(QMessageBox.Critical,
                        "Fehler",
                        "Laden der Datei fehlgeschlagen",
                        buttons=QMessageBox.Ok).exec_()
    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
Exemplo n.º 22
0
 def _typicalErrorDLG(self, exc=None):
     """
     not sure if this is necessary yet
     """
     qapp = QtGui.QApplication(sys.argv)
     qm = QtGui.QMessageBox()
     if exc is None:
         exc = ""
     qm = QMessageBox(QMessageBox.Critical, "Pref error.",
                      "Preferences Critical Issue: " + exc)
     #             qm.setStandardButtons(QMessageBox.Ok);
     qm.setIcon(QMessageBox.Critical)
     qm.show()
     qapp.exec_()
 def makeNewList(self):
     listName, okay = QInputDialog.getText(QInputDialog(), self.objectName().capitalize() + " List Name",
                                           "New " + self.objectName().capitalize() + " List Name:",
                                           QLineEdit.Normal, "New " + self.objectName().capitalize() + " List")
     if okay and len(listName) > 0:
         if any([listName in lst for lst in self._rddtDataExtractor.subredditLists]):
             QMessageBox.information(QMessageBox(), "Data Extractor for reddit",
                                     "Duplicate subreddit list names not allowed.")
             return
         self._lstChooser.addItem(listName)
         self._lstChooser.setCurrentIndex(self._lstChooser.count() - 1)
         self._chooserDict[listName] = ListModel([], self._classToUse)
         self.chooseNewList(self._lstChooser.count() - 1)
         if self._rddtDataExtractor.defaultSubredditListName is None:  # becomes None if user deletes all subreddit lists
             self._rddtDataExtractor.defaultSubredditListName = listName
         self._gui.setUnsavedChanges(True)
Exemplo n.º 24
0
 def checkFilterTable(self):
     """
     Make sure the user entered a value in the textedit field
     """
     if self.filterExternalContentCheckBox.isChecked(
     ) or self.filterSubmissionContentCheckBox.isChecked():
         for row in range(self.filterTable.rowCount()):
             if self.filterTable.cellWidget(
                     row, self.filtTableValCol) is None or len(
                         self.filterTable.cellWidget(
                             row, self.filtTableValCol).toPlainText()) <= 0:
                 QMessageBox.warning(
                     QMessageBox(), "Data Extractor for reddit",
                     "Please enter text in the value column or uncheck that you would like to filter content."
                 )
                 return False
     return True
Exemplo n.º 25
0
    def RecButtonToggled(self):
        if self.rec.text() == 'Aufnehmen':
            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
            self.MainProgramm.StartRecording()
            self.Panel.setRecFrame(True)
            self.rec.setText('Stop')

        else:
            self.MainProgramm.StopRecording()
            self.rec.setText("Aufnehmen")
            self.Panel.setRecFrame(False)
            self.playback_radio.setEnabled(True)
Exemplo n.º 26
0
def atom_limit_exceeded_and_confirmed(parent, natoms, limit = 200):
    """
    Displays a warning message if 'natoms' exceeds 'limit'.
    Returns False if the number of atoms does not exceed the limit or if the
    user confirms that the jigs should still be created even though the limit
    was exceeded.
    If parent is 0, the message box becomes an application-global modal dialog
    box. 
    If parent is a widget, the message box becomes modal relative to parent.
    """
    if natoms < limit:
        return False # Atom limit not exceeded.

    wmsg = "Warning: Creating a jig with " + str(natoms) \
        + " atoms may degrade performance.\nDo you still want to add the jig?"
    
    dialog = QMessageBox("Warning", wmsg, 
                    QMessageBox.Warning, 
                    QMessageBox.Yes, 
                    QMessageBox.No, 
                    QMessageBox.NoButton, 
                    parent)

    # We want to add a "Do not show this message again." checkbox to the dialog
    # like this:
    #     checkbox = QCheckBox("Do not show this message again.", dialog)
    # The line of code above works, but places the checkbox in the upperleft
    # corner of the dialog, obscuring important text.  I'll fix this later.
    # Mark 051122.

    ret = dialog.exec_()

    if ret != QMessageBox.Yes:
        return True
    
    # Print warning msg in history widget whenever the user adds new jigs with
    # more than 'limit' atoms.
    wmsg = "Warning: " + str(natoms) + " atoms selected.  A jig with more " \
        "than " + str(limit) + " atoms may degrade performance."
    env.history.message(orangemsg(wmsg))
        
    return False # from atom_limit_exceeded_and_confirmed
Exemplo n.º 27
0
def InfoDialog(text, button=None, title=None, icon="info"):
    if not title:
        title = _("Information")
    if not button:
        button = _("OK")

    msgBox = QMessageBox()

    buttonOk = msgBox.addButton(button, QMessageBox.ActionRole)

    msgBox.setText(text)

    dialog = Dialog(_(title),
                    msgBox,
                    closeButton=False,
                    isDialog=True,
                    icon=icon)
    dialog.resize(300, 120)
    dialog.exec_()
    ctx.mainScreen.processEvents()
 def checkSaveState(self):
     close = False
     if self._unsavedChanges:
         msgBox = QMessageBox()
         msgBox.setText("A list or setting has been changed.")
         msgBox.setInformativeText("Do you want to save your changes?")
         msgBox.setStandardButtons(QMessageBox.Save | QMessageBox.Discard | QMessageBox.Cancel)
         msgBox.setDefaultButton(QMessageBox.Save)
         ret = msgBox.exec_()
         if ret == QMessageBox.Save:
             self.saveState()
             close = True
         elif ret == QMessageBox.Discard:
             close = True
         elif ret == QMessageBox.Cancel:
             close = False
         else:
             close = False
     else:
         close = True
     return close
 def _initContentLsts(self):
     downloadedContent = self._startingLstModelObj.redditSubmissions
     if downloadedContent is not None and len(downloadedContent) > 0:
         for submissionURL in downloadedContent:
             for submission in downloadedContent.get(submissionURL):
                 if submission.type is DownloadedContentType.JSON_DATA:
                     self._addToTab(submission, submissionURL,
                                    self.submissionJSONLst)
                 elif submission.type is DownloadedContentType.EXTERNAL_SUBMISSION_DATA:
                     self._addToTab(submission, submissionURL,
                                    self.submissionExternalLst)
                 elif submission.type is DownloadedContentType.EXTERNAL_COMMENT_DATA:
                     self._addToTab(submission, submissionURL,
                                    self.commentLst)
                 elif submission.type is DownloadedContentType.EXTERNAL_SELFTEXT_DATA:
                     self._addToTab(submission, submissionURL,
                                    self.selftextLst)
     else:
         QMessageBox.information(
             QMessageBox(), "Data Extractor for reddit",
             self._startingLstModelObj.name +
             " has no downloaded submissions. Download some by hitting the download button."
         )
Exemplo n.º 30
0
def step_dialog(parent, title, msg, det_msg=''):
    d = QMessageBox(parent)
    d.setWindowTitle(title)
    d.setText(msg)
    d.setStandardButtons(QMessageBox.Ok | QMessageBox.Cancel)
    return d.exec_() & QMessageBox.Cancel