示例#1
0
    def on_file_doubleclicked(self, index):
        """ get files contents for revisions and start diff tool """

        patch = self.files_model.patches[index.row()]
        if not patch.old_file_id:
            msg_box = QMessageBox(self)
            msg_box.setText("Nothing to compare to.")
            msg_box.exec()
            return

        old_f = tempfile.NamedTemporaryFile(
            prefix=f'old_{self.old_c_id[:7]}__')
        old_f.write(self.repo[patch.old_file_id].data)
        old_f.flush()

        new_f = None
        if patch.new_file_id:
            # compare 2 revisions
            new_f = tempfile.NamedTemporaryFile(
                prefix=f'new_{self.new_c_id[:7]}__')
            new_f.write(self.repo[patch.new_file_id].data)
            new_f.flush()
            new_f_name = new_f.name
        else:
            # compare some revision with working copy
            new_f_name = self.repo.workdir + patch.path.strip()

        proc = subprocess.Popen(
            [self.settings.value('diff_tool', 'meld'), old_f.name, new_f_name])
        self.difftools.append(Proc(proc, old_f, new_f, True))
示例#2
0
 def showDialog(self, informacja):
     msgBox = QMessageBox()
     msgBox.setIcon(QMessageBox.Information)
     msgBox.setText(str(informacja))
     msgBox.setWindowTitle("Błąd")
     msgBox.setStandardButtons(QMessageBox.Ok)
     msgBox.exec()
示例#3
0
    def analyze_btn_clicked(self):
        client_id = self.ui.client_id.text().strip()
        isDigit = client_id.isdigit()

        if client_id and isDigit:
            dateset = pd.read_csv('data_for_demonstration.csv')
            data = dateset.iloc[:, :].values
            is_valid_client = False
            for row in data:
                row_id = row[1]
                if row_id == int(client_id):
                    client = np.array2string(row, separator=" ")
                    self.show_client_data(row)
                    result_from_prediction = self.neuralNetwork.predict(row)
                    self.show_result_message_box(result_from_prediction)
                    is_valid_client = True
                    break

            if is_valid_client is False:
                msgBox = QMessageBox()
                msgBox.setWindowTitle("Грешка")
                msgBox.setText("Не е открит клиент")
                ret = msgBox.exec()
        else:
            msgBox = QMessageBox()
            msgBox.setWindowTitle("Грешка")
            msgBox.setText("Моля въведете валиден номер")
            ret = msgBox.exec()
示例#4
0
    def goSaveExperiment(self, saveAs: bool = False):
        """
        Selection of path where experiment should be saved and saving it. If experiment
        was already saved or loaded from a path than this method automatically selects the path for saving.
        
        :param saveAs: If this parameter is true. Than path selection is forced.
        :type saveAs: bool
        """

        if saveAs or self._experiment.experiment.loadSavePath is None:
            file = QFileDialog.getSaveFileName(self._widget,
                                               self.tr("Save experiment"),
                                               ".e", self.tr("Any files (*)"))
            file = file[0]
        else:
            file = self._experiment.experiment.loadSavePath
        if file:
            #use selected file
            try:
                self._experiment.saveExperiment(file)

            except Exception as e:
                emsg = QMessageBox()
                emsg.setWindowTitle(
                    self.tr(
                        "There is a problem with saving your experiment :("))
                emsg.setText(str(e))
                emsg.setIcon(QMessageBox.Critical)
                emsg.exec()
示例#5
0
    def _dataStatsStart(self):
        """
        Starts statistics calculation.
        """
        if self._experiment.label is None:
            msgBox = QMessageBox()
            msgBox.setText(self.tr("Select the label first."))
            msgBox.exec()
            return

        self.__dataStatsStartHaveStats = False  #mark that we actual get the stats

        #create runner for
        self._statsRunner = ExperimentStatsRunner(self._experiment)
        self._statsRunner.finished.connect(self._dataStatsFinished)
        self._statsRunner.numberOfSteps.connect(
            self._widget.dataStatsRunProgressBar.setMaximum)
        self._statsRunner.step.connect(self._incDataStatsProgressBar)
        self._statsRunner.actInfo.connect(
            self._widget.dataStatsRunActInfo.setText)
        self._statsRunner.error.connect(self._showErrorMessageInBox)
        self._statsRunner.calcStatsResult.connect(self._newDataStatsResults)

        #clear the act info
        self._widget.dataStatsRunActInfo.setText("")

        #set the progress bar
        self._widget.dataStatsRunProgressBar.setValue(0)

        #change the page
        self._widget.dataStatsPager.setCurrentIndex(
            self.DataStatsPage.PAGE_RUNNING.value)

        self._statsRunner.start()
示例#6
0
    def startScan(self):
        try:
            from watchdog.observers import Observer
        except ImportError:
            msgBox = QMessageBox()
            msgBox.setText("The 'watchdog' package not installed")
            msgBox.setInformativeText(
                "In order to use directory scanning, install watchdog package\n  pip install watchdog")
            msgBox.exec()
            return

        self.lastScanedFits = None
        fileName = QFileDialog.getExistingDirectory(None, 'Select directory')
        if fileName:
            self.setNewestFits(fileName)
            self.createWorkerThread()
            self.scanAct.setVisible(False)
            self.stopAct.setVisible(True)
            self.pauseAct.setVisible(True)
            self.worker_thread.start() #powinno tu być ale jest w create
            self.worker.setActive(True)
            self.activeScan = True
            self.worker.setFileName(fileName)
            self.BtnStartScan.trigger()
            if self.enableAutopause:
                self.obserwableValue.autopauseFlag = True
            self.showAutopauseButton()
示例#7
0
class Lock(Module):
    def __init__(self, stbar, parent_bar):
        Module.__init__(self, 'Lock', stbar, parent_bar, DEFAULT_CONFIG)

        self.setText('')

        self.init_menu()
        self.add_menu_action('Lock', self.on_click)
        self.add_menu_action('Shutdown', self.shutdown)
        self.add_menu_action('Restart', self.restart)
        self.add_menu_action('Logout', self.logout)

        self.dialog = QMessageBox()
        self.dialog.setDefaultButton(QMessageBox.No)
        self.dialog.setStandardButtons(QMessageBox.Yes | QMessageBox.No)

    def on_click(self):
        self.exec(self.config[self.name]['exec'])

    def shutdown(self):
        self.dialog.setText("Shutdown computer?")
        if self.dialog.exec() == QMessageBox.Yes:
            self.exec('shutdown -h now')

    def restart(self):
        self.dialog.setText("Restart computer?")
        if self.dialog.exec() == QMessageBox.Yes:
            self.exec('shutdown -r now')

    def logout(self):
        self.dialog.setText("Logout?")
        if self.dialog.exec() == QMessageBox.Yes:
            session = self.exec(
                "loginctl session-status | head -n 1 | awk '{print $1}'")
            self.exec('loginctl terminate-session ' + session)
示例#8
0
 def save_file(self):
     if self._save_loc is None:
         self.save_file_as()
         return
     if not os.path.isdir(self._save_loc):
         os.mkdir(self._save_loc)
     if self._file_name is None:
         files = os.listdir(self._save_loc)
         self._file_name = str(len(files) + 1) + '.txt'
         while os.path.isfile(os.path.join(self._save_loc,
                                           self._file_name)):
             self._file_name = str(int(self._file_name.rstrip('.txt')) +
                                   1) + '.txt'
     try:
         with open(os.path.join(self._save_loc, self._file_name), 'w') as f:
             sudoku = [
                 str(cell.value())
                 for cell in self.centralWidget().grid.cells
             ]
             text = ','.join(sudoku)
             f.write(text)
     except OSError:
         msg_box = QMessageBox()
         msg_box.setWindowTitle('Failure')
         msg_box.setText(
             'Something went wrong when saving your file, please retry.')
         msg_box.exec()
示例#9
0
    def showabout(self, **kwargs):
        msgBox = QMessageBox(self._window)
        msgBox.setTextFormat(Qt.RichText)
        msgBox.setWindowTitle('About poliBeePSync')
        text = """
<html>
<head/>
<body>
  <p>
    poliBeePsync is a program written by Davide Olianas and Raffaele Di Campli
    released under GNU GPLv3+.
    More information is available on the
    <a href=\"https://github.com/Jacotsu/polibeepsync\">
    <span style=\" text-decoration: underline; color:#0000ff;\">
    official github</span></a>.
    Feel free to contact us at
    <a href=\"mailto:[email protected]\">[email protected]</a> for
    suggestions and bug reports.
  </p>
  <p>
  Want to learn how to make softwares like this? Then join <br>
    <a href='https://poul.org/'>
      <img src=':/root/imgs/PinguiniStilNovoFullLogoBlack.svg'>
    </a>
  </p>
  <p>
    <a href='https://liberapay.com/jacotsu/donate'>
        Want to offer me a sandwich?
    </a>
  </p>
</body>
</html>
"""
        msgBox.setInformativeText(text)
        msgBox.exec()
示例#10
0
文件: gui.py 项目: ptrbortolotti/WEIS
    def disable_ui_and_execute_wisdem(self):
        """
        This method disables all widgets on the UI and executes WISDEM. It
        displays message boxes depending on whether WISDEM executed
        successfully.
        """
        self.main_widget.setEnabled(False)
        self.status_label.setText("Running WISDEM")

        try:
            wt_opt, modeling_options, analysis_options = run_wisdem(
                self.geometry_filename, self.modeling_filename, self.analysis_filename
            )
        except Exception as err:
            short_error_message = f"{type(err)}: {err}. More details on command line."
            traceback.print_exc(file=sys.stdout)
            self.status_label.setText("Execution error")
            msg = QMessageBox()
            msg.setText("WISDEM execution error")
            msg.setInformativeText(short_error_message)
            msg.addButton(QMessageBox.Ok)
            msg.exec()
            self.main_widget.setEnabled(True)
        else:
            self.status_label.setText("Execution success")
            msg = QMessageBox()
            msg.setText("WISDEM executed successfully")
            msg.addButton(QMessageBox.Ok)
            msg.exec()
            self.main_widget.setEnabled(True)
 def check_victory(self):
     if all([c.content == 'bomb' for c in self.cells if c.mode == 'flag']):
         msg_box = QMessageBox()
         msg_box.setWindowTitle('Victory!')
         msg_box.setText('You identified all bombs!')
         self.end_game()
         msg_box.exec()
    def __init__(self, width: int, height: int, bomb_count: int, parent=None):
        super(BoardWidget, self).__init__(parent)
        self.setFrameStyle(QFrame.Panel | QFrame.Sunken)
        self.setLineWidth(3)
        self.setMidLineWidth(3)

        if bomb_count > height * width:
            msg_box = QMessageBox()
            msg_box.setWindowTitle('Nuh')
            msg_box.setText('Too many bombs for your board!')
            msg_box.exec()
            sys.exit()

        p = self.palette()
        p.setColor(QPalette.Background, QColor(192, 192, 192))
        self.setPalette(p)
        self.setAutoFillBackground(True)

        self.center = parent
        self.height = height
        self.width = width
        self.cells = [
            CellWidget(i, parent=self) for i in range(width * height)
        ]
        self.generate_layout()
        self.flag_count = 0
        self.bomb_count = bomb_count
        self.init_board()

        self.in_progress = False
示例#13
0
 def reset_timer(self):
     self.play_sound("start/goodluckyoullneedit.wav")
     mbox = QMessageBox()
     mbox.setText("Time starts when you press enter")
     mbox.exec()
     self.play_sound("start/letsgo.wav")
     self.time_started = time.time()
     self.time_ending = self.time_started + 3 * 60
 def showErrorDialog(self, messege):
     msgBox = QMessageBox()
     msgBox.setIcon(QMessageBox.Warning)
     msgBox.setText(str(messege))
     msgBox.setWindowTitle("Błąd")
     msgBox.setStandardButtons(QMessageBox.Ok)
     msgBox.setStyleSheet(
         "background-color: rgb(40, 40, 40); color: rgb(255, 255, 255)")
     msgBox.exec()
示例#15
0
 def show_error_dialog(self, text: str):
     '''
     Show a error QMessageBox with text = text
     '''
     msg_box = QMessageBox()
     msg_box.setWindowTitle("Error")
     msg_box.setStandardButtons(QMessageBox.Ok)
     msg_box.setText(text)
     msg_box.setIcon(QMessageBox.Critical)
     msg_box.exec()
示例#16
0
 def item_changed(self, Qitem: QTableWidgetItem):
     if not Qitem.text() or Qitem.column() == 0:
         return
     try:
         int(Qitem.text())
     except ValueError:
         Msgbox = QMessageBox()
         Msgbox.setText("Error, Pixel ID must be an integer!")
         Msgbox.exec()
         Qitem.setData(Qt.DisplayRole, None)
示例#17
0
    def pop_up(self, title, message):
        """Displays a message with the title and message."""

        # Generate pop up with title, message, an info icon, and an OK button
        pop_up = QMessageBox(self)
        pop_up.setWindowTitle(title)
        pop_up.setText(message)
        pop_up.setStandardButtons(QMessageBox.Ok)
        pop_up.setIcon(QMessageBox.Information)

        pop_up.exec()
示例#18
0
    def login(self):
        user_name = self.window.findChild(QLineEdit, 'userNameLineEdit').text()
        password = self.window.findChild(QLineEdit, 'passwordLineEdit').text()
        payload = {'user_name': user_name, 'password': password}
        result = requests.post(url=self._login_route, data=payload)

        message = QMessageBox()
        if result.text == "success":
            message.setText("Login successful.")
        else:
            message.setText("Bad user name or password.")
        message.exec()
示例#19
0
    def Initialize(self):
        msgBox = QMessageBox()
        msgBox.setIcon(QMessageBox.Information)

        if (self.account_sid == 'enter_account_sid' or self.auth_token == 'enter_auth_token' or self.smsFrom == 'enter_phone_number'):
            msgBox.setWindowTitle("API Key Required!")
            msgBox.setText("Please fill up the api.txt with your TWILIO Account details.")
            msgBox.exec()
        else:
            t = threading.Thread(target=self.SEND_SMS)
            t.daemon = True
            t.start()
示例#20
0
    def show_err(self, errmsg):
        """
        Generic messagebox with critical error displayed.

        :param str errmsg: Error message to display
        """
        msgBox = QMessageBox()
        msgBox.setIcon(QMessageBox.Critical)
        msgBox.setText(errmsg)
        msgBox.setWindowTitle("Error")
        msgBox.setStandardButtons(QMessageBox.Ok)
        msgBox.exec()
示例#21
0
 def startProcess(self, process):
     if not self.processRunning:
         self.process = process
         logger.info("Started process " + str(self.process))
         self.processRunning = True
         self.processstarted.emit(self.process.remainingtime)
         self.saveprocesstimer.start(1000)
         self.connectProcessToSignals()
         self.process.start()
     else:
         error = QMessageBox()
         error.setText("A process is already running.")
         error.exec()
示例#22
0
    def _view_input_seed(self):
        current_trace_stats = self.trace.am_obj
        input_id = current_trace_stats.input_id

        inputSeed = self.multi_trace.am_obj.get_input_seed_for_id(input_id)
        msgText = "%s" % inputSeed
        msgDetails = "Input for [%s]" % current_trace_stats.id
        msgbox = QMessageBox()
        msgbox.setWindowTitle("Seed Input")
        msgbox.setDetailedText(msgDetails)
        msgbox.setText(msgText)
        msgbox.setStandardButtons(QMessageBox.Ok)
        msgbox.exec()
示例#23
0
 def confirmSupprEle(self):
     print("confirm suppr")
     msgSuppr = QMessageBox()
     msgSuppr.setWindowTitle("Suppression")
     msgSuppr.setText("Confirmer la suppression de l'élève: {}".format(self.ui2.BDcbEleSupprSelectNom.currentText()))
     msgSuppr.setStandardButtons(QMessageBox.Yes| QMessageBox.No)
     buttonY = msgSuppr.button(QMessageBox.Yes)
     buttonN = msgSuppr.button(QMessageBox.No)
     msgSuppr.exec()
     if msgSuppr.clickedButton() == buttonY:
         self.supprEle()
     elif msgSuppr.clickedButton() == buttonN:
         pass
 def e_ok_clicked(self):
     x = self.ui.e_x.text()
     y = self.ui.e_y.text()
     print(x)
     print(y)
     if isVar(x) and isVar(y):
         code = f"MouseGetPos {x}, {y}  ;当前鼠标的位置坐标将会被保存到{x}和{y}中\n"
     else:
         msgBox = QMessageBox()
         msgBox.setText("x和y填的应该是要保存到的变量名\n检查一下?")
         msgBox.exec()
         return
     self.ui.code_text.insertPlainText(code)
示例#25
0
    def setUseCase(self, index):
        '''A function is triggered by the DropDown Menu labelled, UseCase.'''
        selected_usecase = self.usecase_list[index]

        if selected_usecase == 'Classification':
            if not self.debug:
                msgBox = QMessageBox()
                msgBox.setText('[Classification] Selected.'
                               'No other configuration required.')
                msgBox.exec()
            print('Wrote to ../data/usecase_config.txt')
            with open(self._path_to_usecase_config, 'w') as filehandle:
                filehandle.write('0\n')
        elif selected_usecase == 'Counting':
            self.counting_window = CountingWindow(self._path_to_label_list,
                                                  self._path_to_usecase_config)
            self.counting_window.show()
        elif selected_usecase == 'Localization':
            with open(self._path_to_usecase_config, 'w') as filehandle:
                filehandle.write('3\n')
        elif selected_usecase == 'Tracking':
            self.tracking_window = TrackingWindow(self._path_to_usecase_config)
            self.tracking_window.show()
        else:
            if not self.debug:
                input_refimage_filepath, ok = (QFileDialog.getOpenFileName(
                    self, 'Set the .png/.jpg color image to use',
                    os.path.abspath('../data'),
                    'Image Files (*.png *.jpg *.jpeg)'))
            else:
                input_refimage_filepath = 'dummy_filepath_to_refimage'
                ok = True

            self.usecase_config.clear()
            self.usecase_config.append(str(2))
            if ok:

                filepath_index = input_refimage_filepath.find('/data')

                self.usecase_config.append(
                    '.' + input_refimage_filepath[filepath_index:])
            else:
                print('No reference color template set.')
                return
            print('Wrote to ../data/usecase_config.txt')
            with open(self._path_to_usecase_config, 'w') as filehandle:
                for ele in self.usecase_config:
                    filehandle.write('%s\n' % ele)

        self.usecase_config_button.setStyleSheet(
            'background-color: rgba(0,150,10,255);')
示例#26
0
 def confirmModifEle(self):
     print("confirm modif")
     msgModif = QMessageBox()
     msgModif.setWindowTitle("Modification")
     msgModif.setText(
         "Confirmer la modification de l'élève: {}".format(self.ui2.BDcbEleModifSelectNom.currentText()))
     msgModif.setStandardButtons(QMessageBox.Yes | QMessageBox.No)
     buttonY= msgModif.button(QMessageBox.Yes)
     buttonN= msgModif.button(QMessageBox.No)
     msgModif.exec()
     if msgModif.clickedButton() == buttonY:
         self.modifEle()
     elif msgModif.clickedButton() == buttonN:
         pass
示例#27
0
    def ask(
        parent,
        title_txt: str = _('Frage'),
        message: str = '',
        ok_btn_txt: str = _('OK'),
        abort_btn_txt: str = _('Abbrechen')
    ) -> bool:
        """ Pop-Up Warning Box ask to continue or break, returns False on abort """
        msg_box = QMessageBox(QMessageBox.Question,
                              title_txt,
                              message,
                              parent=parent)

        msg_box.setStandardButtons(QMessageBox.Ok | QMessageBox.Abort)

        msg_box.button(QMessageBox.Ok).setText(ok_btn_txt)
        msg_box.button(QMessageBox.Abort).setText(abort_btn_txt)

        # Block until answered
        answer = msg_box.exec()

        if answer == QMessageBox.Abort:
            # User selected abort
            return False

        # User selected -Ok-, continue
        return True
示例#28
0
    def save_image_dialog(self):
        raw_image = False

        checkBox = QCheckBox("Save raw image")
        checkBox.setChecked(True)
        msgBox = QMessageBox(self)
        msgBox.setWindowTitle("Save Image")
        msgBox.setText(
            "Save the image displayed in the preview or the raw image from the camera"
        )
        msgBox.setIcon(QMessageBox.Question)
        msgBox.addButton(QMessageBox.Ok)
        msgBox.addButton(QMessageBox.Cancel)
        msgBox.setDefaultButton(QMessageBox.Cancel)
        msgBox.setCheckBox(checkBox)

        val = msgBox.exec()
        if val == QMessageBox.Cancel:
            return

        raw_image = msgBox.checkBox().isChecked()
        now = datetime.now().strftime("%y-%m-%d_%H-%M")
        save_path, filter = QFileDialog.getSaveFileName(
            self, "Choose save file",
            f"{userpaths.get_my_pictures()}/screenshot_{now}.png",
            "Images (*.png *.jpg *.bmp)")
        if save_path is None:
            return

        qimg = self.ui.camera_prev.grab_image(raw=raw_image)
        if qimg is None:
            return

        qimg.save(save_path, quality=100)
示例#29
0
 def on_btn(self):
     '''Creates buttons on click'''
     basedir = ROOT_PATH
     try:
         create_dirs(
             self.conf, basedir,
             range(int(self.start_box.text()), int(self.stop_box.text())))
     except ValueError:
         msg = QMessageBox()
         msg.setText('Error! Invalid numbers in text boxes!')
         msg.exec()
     except FileExistsError as file_ex:
         msg = QMessageBox()
         msg.setText(
             f'Error! Directory already exists! Exception: {str(file_ex)}')
         msg.exec()
示例#30
0
    def about(self):
        icon = QIcon()
        icon.addPixmap(QPixmap('../../../images/icons/icon.png'))

        message_box = QMessageBox(parent=self)
        message_box.setWindowTitle('Título da caixa de texto')
        message_box.setWindowIcon(icon)
        message_box.setText(
            'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do '
            'eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim '
            'ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut '
            'aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit '
            'in voluptate velit esse cillum dolore eu fugiat nulla pariatur. '
            'Excepteur sint occaecat cupidatat non proident, sunt in culpa '
            'qui officia deserunt mollit anim id est laborum.'
        )
        message_box.exec()