def load_data():
    file_name = GlobalElements.LoadFilesDialog.findChild(QLineEdit, "lineEditFilename").text()
    dir_path = GlobalElements.LoadFilesDialog.findChild(QLineEdit, "lineEditDirectory").text()
    file_path = os.path.join(dir_path, file_name)
    if os.path.isfile(file_path):
        msgBox = QMessageBox()
        msgBox.setText(u"Plik o podanej nazwie już istnieje.")
        msgBox.setInformativeText(u"Czy chcesz go nadpisać?")
        msgBox.addButton(u"Tak", QMessageBox.AcceptRole)
        abortButton = msgBox.addButton(u"Nie", QMessageBox.Abort)
        msgBox.exec_()
        if msgBox.buttonClicked() == abortButton:
            return
    if file_name:
        update_load_data_config()
        data_reader = DataReader(GlobalElements.Config["start_channel"],
                                 GlobalElements.Config["end_channel"],
                                 GlobalElements.Config["output_format"],
                                 GlobalElements.Config["line_numbers"],
                                 file_path,
                                 GlobalElements.LoadFilesDialog.findChild(QPlainTextEdit, "plainTextEditDescription").toPlainText())
        data_reader.start()
        GlobalElements.LoadFilesDialog.findChild(QLineEdit, "lineEditFilename").clear()
        GlobalElements.LoadFilesDialog.findChild(QPlainTextEdit, "plainTextEditDescription").clear()
        GlobalElements.LoadFilesDialog.accept()
    else:
        msgBox = QMessageBox()
        msgBox.setText(u"Niepoprawna nazwa pliku!")
        msgBox.exec_()
Beispiel #2
0
    def askWhichAction(self):
        """
        Ask the user what to do if no chunk worked:
         - Try again
         - Re-test the current last working chunk
         - Cancel

        :return: An integer value indicating the pressed button:
         - 0 if the user wants to try again
         - 1 if the user wants to re-test
         - 2 if the user wants to cancel
        """

        messageBox = QMessageBox()
        messageBox.setWindowTitle(Strings.searcherTabAskActionMessageBoxTitle)
        messageBox.setText(Strings.searcherTabAskActionMessageBoxText)

        tryAgainButton = messageBox.addButton(
            Strings.searcherTabAskActionMessageBoxButtonTryAgainText,
            QMessageBox.RejectRole)
        reTestButton = messageBox.addButton(
            Strings.searcherTabAskActionMessageBoxButtonReTestText,
            QMessageBox.NoRole)
        cancelButton = messageBox.addButton(
            Strings.searcherTabAskActionMessageBoxButtonCancelText,
            QMessageBox.YesRole)
        messageBox.exec_()

        if messageBox.clickedButton() == tryAgainButton:
            return 0
        elif messageBox.clickedButton() == reTestButton:
            return 1
        elif messageBox.clickedButton() == cancelButton:
            return 2
Beispiel #3
0
    def eventFilter(self, obj, event):
        if not event:
            return False

        if event.type() != QEvent.KeyPress:
            return False

        if event.key() not in (Qt.Key_Return, Qt.Key_Enter):
            return False

        print "Obj", obj
        if obj == self.loginEdit:
            print "Changing focus"
            self.passwordEdit.setFocus(Qt.OtherFocusReason)
        elif obj == self.passwordEdit:
            message = ""
            icon = None

            if not (self.loginEdit.text() or self.passwordEdit.text()):
                message = "Please enter your credentials"
                icon = QMessageBox.Warning
            else:
                message = "Login Successfull"
                icon = QMessageBox.Information

            messageBox = QMessageBox()
            messageBox.setText(message)
            messageBox.addButton("OK", QMessageBox.AcceptRole)
            messageBox.setIcon(icon)
            messageBox.exec_()

        return False
Beispiel #4
0
 def getMsgBox(self, text, nRoom):
     msgBox = QMessageBox()
     msgBox.setWindowTitle("Room: " + str(nRoom))
     msgBox.setText(text)
     msgBox.addButton(QMessageBox.Ok)
     msgBox.show()
     msgBox.exec_()
Beispiel #5
0
def user_choice(text, windowtitle, icon, acceptbutton="OK"):
    choice_dialog = QMessageBox()
    choice_dialog.setWindowIcon(QPixmap("../icons/desuratools_256.png"))
    choice_dialog.setText(text)
    choice_dialog.setIcon(icon)
    choice_dialog.setStandardButtons(QMessageBox.Cancel)
    choice_dialog.setWindowTitle(windowtitle)
    choice_dialog.addButton(acceptbutton, QMessageBox.AcceptRole)
    return choice_dialog
Beispiel #6
0
 def showMessageBox(self, msg):
     warning = QMessageBox(self)
     warning.setFont(View.labelsFont())
     warning.setStyleSheet('QMessageBox {background: white}')
     warning.setWindowTitle("Error")
     warning.setText(msg)
     warning.setIcon(QMessageBox.Warning)
     warning.addButton("Ok", QMessageBox.AcceptRole).setFont(View.editsFont())
     warning.exec_()
Beispiel #7
0
 def showMessageBox(self, msg):
     warning = QMessageBox(self)
     warning.setFont(View.labelsFont())
     warning.setStyleSheet('QMessageBox {background: white}')
     warning.setWindowTitle("Error")
     warning.setText(msg)
     warning.setIcon(QMessageBox.Warning)
     warning.addButton("Ok",
                       QMessageBox.AcceptRole).setFont(View.editsFont())
     warning.exec_()
def query_user(platform):
    msg_box = QMessageBox()
    msg_box.setWindowTitle("This plaform is not installed!")
    ok = msg_box.addButton("Install now", QMessageBox.AcceptRole)
    later = msg_box.addButton("Install later", QMessageBox.RejectRole)
    msg_box.setEscapeButton(later)
    msg_box.setDefaultButton(ok)
    msg_box.setIcon(QMessageBox.Warning)
    msg_box.setText("Do you want to install target\n{} ?".format(platform))
    msg_box.exec_()
    return msg_box.clickedButton() == ok
Beispiel #9
0
def getWarningMessageBox(text, informative_text):
    message_box = QMessageBox()
    h_spacer = QSpacerItem(500, 0)
    gl = message_box.layout()
    gl.addItem(h_spacer, gl.rowCount(), 0, 1, gl.columnCount())
    message_box.setWindowTitle(constants.APPLICATION_TITLE)
    message_box.addButton(QMessageBox.Ok)
    message_box.setText('<b>{}'.format(text))
    message_box.setInformativeText(informative_text)
    message_box.setIcon(QMessageBox.Critical)
    return message_box
Beispiel #10
0
def copy_details_box(icon, title, text, details):
    """Shows a QMessageBox with a detail box and a 'Copy details' button
    """
    box = QMessageBox(icon, title, text)
    box.setDetailedText(details)
    copy_button = box.addButton('Copy details', QMessageBox.HelpRole)

    # QMessageBox connects the clicked signal of the new button to a close
    # action - disconnect this and connect to copy_to_clipboard
    copy_button.clicked.disconnect()
    copy_button.clicked.connect(partial(copy_to_clipboard, details))
    box.addButton('OK', QMessageBox.AcceptRole)
    return box.exec_()
Beispiel #11
0
 def check_dir_is_empty(self, dir_path):
     if len(os.listdir(dir_path)) > 0:
         msgBox = QMessageBox()
         msgBox.setWindowTitle("Directory not empty")
         msgBox.setText(
             "The selected directory is not empty.\n"
             "For a new Component you usually want a new directory.\n"
             "Do you want to use this directory anyway?")
         msgBox.setStandardButtons(QMessageBox.Yes)
         msgBox.addButton(QMessageBox.No)
         msgBox.setDefaultButton(QMessageBox.No)
         if msgBox.exec_() == QMessageBox.Yes:
             return True
         else:
             return False
     else:
         return True
Beispiel #12
0
def getCriticalMessageBox(text, informative_text, detailed_text=None):
    message_box = QMessageBox()
    h_spacer = QSpacerItem(500, 0)
    gl = message_box.layout()
    gl.addItem(h_spacer, gl.rowCount(), 0, 1, gl.columnCount())
    message_box.setWindowTitle(constants.APPLICATION_TITLE)
    message_box.addButton(QMessageBox.Ok)
    message_box.setText('<b>{}'.format(text))
    message_box.setInformativeText(informative_text)
    if detailed_text is not None:
        message_box.setDetailedText(detailed_text)
    else:
        excType, excValue, tracebackobj = sys.exc_info()
        tb_list = traceback.format_exception(excType, excValue, tracebackobj)
        tb_str = ''.join(tb_list)
        message_box.setDetailedText(tb_str)
    message_box.setIcon(QMessageBox.Critical)
    return message_box
Beispiel #13
0
 def closeEvent(self, event):
     if self.process is not None:
         msg = QMessageBox()
         msg.setIcon(QMessageBox.Warning)
         msg.setWindowTitle('Confirm process interruption')
         msg.setText('Closing the window will terminate the running process. '
                     'Do you really want to exit?')
         msg.setInformativeText('Interrupting the process may leave partly '
                                'created files that cannot be used for '
                                'further analysis.')
         close_button = msg.addButton("Stop and close", QMessageBox.YesRole)
         cancel_button = msg.addButton("Cancel", QMessageBox.NoRole)
         msg.setDefaultButton(cancel_button)
         msg.exec_()
         if msg.clickedButton() == close_button:
             self.stop(force=True)
             super(LaunchGUI, self).closeEvent(event)
         else:
             event.ignore()
Beispiel #14
0
    def stop(self, force=False):
        if self.process is not None:

            if not force:
                msg = QMessageBox()
                msg.setIcon(QMessageBox.Warning)
                msg.setWindowTitle('Confirm process termination')
                msg.setText(
                    'This will terminate the running process. Are you sure '
                    'you want to do this?')
                msg.setInformativeText(
                    'Interrupting the process may leave partly '
                    'created files that cannot be used for '
                    'further analysis.')
                msg.addButton('Stop process', QMessageBox.YesRole)
                cancel_button = msg.addButton('Cancel', QMessageBox.NoRole)
                msg.setDefaultButton(cancel_button)
                msg.exec_()
                if msg.clickedButton() == cancel_button:
                    # Continue to run
                    return

            self._interrupted = True
            # Terminate child processes as well
            pid = int(self.process.pid())
            if sys.platform == 'win32' and pid != 0:
                # The returned value is not a PID but a pointer
                lp = ctypes.cast(pid, LPWinProcInfo)
                pid = lp.contents.dwProcessID

            if pid != 0:
                process = psutil.Process(pid)
                children = process.children(recursive=True)
                for proc in children:
                    proc.terminate()
                gone, alive = psutil.wait_procs(children, timeout=3)
                for proc in alive:
                    proc.kill()

                self.process.terminate()
                self.process = None
Beispiel #15
0
    def append_output(self):
        if self.process is None:  # Can happen when manually interrupting
            return
        lines = strip_ansi_codes(to_str(self.process.readAllStandardOutput()))
        self.add_output_lines(lines)
        # We manually deal with keyboard input in the output
        if 'Export already made! Do you want to erase everything? (y)es / (n)o' in lines:
            msg = QMessageBox()
            msg.setIcon(QMessageBox.Question)
            msg.setWindowTitle('Erase everything?')
            msg.setText(
                'Export already made! Do you want to erase everything?')
            msg.setStandardButtons(QMessageBox.Yes | QMessageBox.No)
            answer = msg.exec_()
            if answer == QMessageBox.Yes:
                answer_string = 'y'
            else:
                answer_string = 'n'
        elif 'Do you want SpyKING CIRCUS to export PCs? (a)ll / (s)ome / (n)o' in lines:
            msg = QMessageBox()
            msg.setIcon(QMessageBox.Question)
            msg.setWindowTitle('Export PCs?')
            msg.setText('Do you want SpyKING CIRCUS to export PCs?')
            no_button = msg.addButton('No', QMessageBox.NoRole)
            some_button = msg.addButton('Some', QMessageBox.YesRole)
            all_button = msg.addButton('All', QMessageBox.YesRole)
            msg.exec_()
            if msg.clickedButton() == no_button:
                answer_string = 'n'
            elif msg.clickedButton() == some_button:
                answer_string = 's'
            elif msg.clickedButton() == all_button:
                answer_string = 'a'
            else:
                answer_string = 'n'
        else:
            answer_string = ''

        if answer_string:
            self.process.write(answer_string + '\n')
            self.add_output_lines(answer_string + '\n')
 def __abortComputationBox(self):
     tit = self.tr("Aborting Batch Computation")
     txt = self.tr("Reduce is currently evaluating several groups in "
                   "batch. Do you want to interrupt only the current "
                   "computation or all?")
     diag = QMessageBox(self.model.controller.mainWindow)
     diag.setWindowTitle(tit)
     diag.setIcon(QMessageBox.Question)
     diag.setText(txt)
     abortAll = diag.addButton("Abort All",QMessageBox.YesRole)
     abortCurrent = diag.addButton("Abort Current",QMessageBox.YesRole)
     cancel = diag.addButton(QMessageBox.StandardButton.Cancel)
     diag.setDefaultButton(abortAll)
     diag.setEscapeButton(cancel)
     diag.setWindowModality(Qt.WindowModal)
     diag.exec_()
     ans = diag.clickedButton()
     if ans == abortAll:
         return 'all'
     elif ans == abortCurrent:
         return 'current'
     elif ans == cancel:
         return 'cancel'
     traceLogger.critical("unidentifiable button %s" % ans)