Ejemplo n.º 1
0
    def initDB(self):
        # ---------------------------------------------------------------------
        #  DATABASE CONNECTION
        # ---------------------------------------------------------------------
        # Config for Database
        config_db = self.config['Database']
        dbname = config_db['DBNAME']

        # get database instance
        self.db = SqlDB(dbname)
        if not os.path.exists(dbname):
            # If database does not exist, create new database.
            self.db.init()

            # 'New DB is created.' dialog
            QMessageBox.warning(
                self,
                'New DB',
                'New DB is created.',
                QMessageBox.Ok,
                QMessageBox.Ok
            )
Ejemplo n.º 2
0
    def _remove_node(self):
        if self._check_for_edit_dialog():
            return

        current_node = self.current_node

        if not isinstance(current_node, GenericNode):
            if not self._warning_dialogs_disabled:
                QMessageBox.warning(self, "Delete Node",
                                    "Can only remove Generic Nodes")
            return

        user_response = QMessageBox.warning(
            self, "Delete Node",
            "Are you sure you want to delete the node '{}'?".format(
                current_node.name), QMessageBox.Yes | QMessageBox.No,
            QMessageBox.No)

        if user_response != QMessageBox.Yes:
            return

        self.editor.remove_node(self.current_area, current_node)
        self.on_select_area()
Ejemplo n.º 3
0
    def _delete(self) -> None:
        """Deletes the currently selected dataset."""
        self.setEnabled(False)
        name = self._model.currentText()

        warning = f'Are you sure you want to delete {name}?'

        response = QMessageBox.warning(self, self.tr("Delete Model"), warning,
                                       QMessageBox.Yes, QMessageBox.No)

        if response == QMessageBox.Yes:
            data_ingest.delete_data(name, file_type='model')
            self._refresh_lists()

        self.setEnabled(True)
Ejemplo n.º 4
0
    def accepting(self):

        # Check that no mandatory input is empty
        if self.standard_name_header.text() != '' and self.fma_id_header.text(
        ) != '' and self.organ_header.text() != '':
            # Check validation
            if re.match(r'^([\s\d]+)$', self.fma_id_header.text()):
                self.accept()

            # The FMA ID field do not contain just numbers
            else:
                button_reply = QMessageBox.warning(
                    self, "Error Message",
                    "The FMA ID field should to be a number!", QMessageBox.Ok)
                if button_reply == QMessageBox.Ok:
                    pass

        # Atleast one input field was left empty
        else:
            button_reply = QMessageBox.warning(
                self, "Error Message", "None of the fields should be empty!",
                QMessageBox.Ok)
            if button_reply == QMessageBox.Ok:
                pass
Ejemplo n.º 5
0
    def maybeSave(self):
        if self.document().isModified():
            ret = QMessageBox.warning(
                self, "MDI",
                "'%s' has been modified.\nDo you want to save your "
                "changes?" % self.userFriendlyCurrentFile(),
                QMessageBox.Save | QMessageBox.Discard | QMessageBox.Cancel)

            if ret == QMessageBox.Save:
                return self.save()

            if ret == QMessageBox.Cancel:
                return False

        return True
Ejemplo n.º 6
0
 def RequestCloseTab(self, index):
     tab: ProgramEditorTab = self._tabWidget.widget(index)
     self._tabWidget.setCurrentWidget(tab)
     if tab.modified:
         ret = QMessageBox.warning(
             self, "Confirm", "'" + tab.program.name +
             "' has been modified.\nDo you want to save changes?",
             QMessageBox.Save | QMessageBox.Discard | QMessageBox.Cancel,
             QMessageBox.Save)
         if ret is QMessageBox.Save:
             tab.SaveProgram()
         elif ret is QMessageBox.Cancel:
             return False
     self._tabWidget.removeTab(index)
     if not self._tabWidget.count():
         self.close()
     return True
    def _delete(self) -> None:
        """Deletes the currently selected dataset."""
        self.setEnabled(False)
        name = self._lists['data'].selectedItems()

        if len(name) != 0:
            name = name[0].text()

            warning = f'Are you sure you want to delete {name}?'

            response = QMessageBox.warning(self, self.tr("Delete Dataset"),
                                           warning, QMessageBox.Yes,
                                           QMessageBox.No)
            if response == QMessageBox.Yes:
                data_ingest.delete_data(name, file_type='data')
                self._refresh_lists()

        self.setEnabled(True)
Ejemplo n.º 8
0
    def closeEvent(self, event):
        sender = self.sender()

        reply = QMessageBox.warning(
            self,
            'Quit App',
            'Are you sure you want to quit?',
            QMessageBox.Yes | QMessageBox.No,
            QMessageBox.No
        )

        if sender is not None:
            # Exit button is clicked
            if reply == QMessageBox.Yes:
                #QApplication.quit()
                sys.exit()
            return
        else:
            # 'X' on the window is clicked
            if reply == QMessageBox.Yes:
                event.accept()
            else:
                event.ignore()
Ejemplo n.º 9
0
    def wiiload_button(self):
        data = self.ui.listAppsWidget.currentItem().data(Qt.UserRole)
        app_name = data["internal_name"]
        app_display_name = data["display_name"]

        ip, ok = QInputDialog.getText(self, 'Send to Wii: Enter IP address',
                                      'Enter the IP address of your Wii.\n'
                                      'The selected app will be sent through the network to your Wii.\n\n'
                                      f'App to send: {app_display_name}\n\n'
                                      'To find your Wii\'s IP address:\n'
                                      '1) Enter the Homebrew Channel.\n'
                                      '2) Press the home button on the Wii Remote.\n'
                                      '3) Copy the IP address written in the top left corner.\n\n'
                                      'IP address (e.g. 192.168.1...):',
                                      QLineEdit.Normal)
        if not ok:
            return

        ip_match = wiiload.validate_ip_regex(ip)

        if ip_match is None:
            logging.warning('Invalid IP Address: ' + ip)
            QMessageBox.warning(self, 'Invalid IP Address', 'This IP address is invalid.')
            return

        self.status_message("Downloading " + app_name + " from Open Shop Channel..")
        self.ui.progressBar.setValue(25)

        # get app
        path_to_app = self.download_button()

        with open(path_to_app, 'rb') as f:
            content = f.read()

        zipped_app = io.BytesIO(content)
        zip_buf = io.BytesIO()

        # Our zip file should only contain one directory with the app data in it,
        # but the downloaded file contains an apps/ directory. We're removing that here.
        wiiload.organize_zip(zipped_app, zip_buf)

        # preparing
        prep = wiiload.prepare(zip_buf)

        file_size = prep[0]
        compressed_size = prep[1]
        chunks = prep[2]

        # connecting
        self.status_message('Connecting to the HBC...')
        self.ui.progressBar.setValue(50)

        try:
            conn = wiiload.connect(ip)
        except socket.error as e:
            logging.error('Error while connecting to the HBC. Please check the IP address and try again.')
            QMessageBox.warning(self, 'Connection error',
                                'Error while connecting to the HBC. Please check the IP address and try again.')
            print(f'WiiLoad: {e}')
            self.ui.progressBar.setValue(0)
            self.status_message('Error: Could not connect to the Homebrew Channel. :(')

            # delete application zip file
            os.remove(path_to_app)

            return

        wiiload.handshake(conn, compressed_size, file_size)

        # Sending file
        self.status_message('Sending app...')

        chunk_num = 1
        for chunk in chunks:
            conn.send(chunk)

            chunk_num += 1
            progress = round(chunk_num / len(chunks) * 50) + 50
            self.ui.progressBar.setValue(progress)
            try:
                app.processEvents()
            except NameError:
                pass

        file_name = f'{app_name}.zip'
        conn.send(bytes(file_name, 'utf-8') + b'\x00')

        # delete application zip file
        os.remove(path_to_app)

        self.ui.progressBar.setValue(100)
        self.status_message('App transmitted!')
        logging.info(f"App transmitted to HBC at {ip}")
 def load(self):
     axSelect = QAxSelect(self)
     if axSelect.exec_() == QDialog.Accepted:
         clsid = axSelect.clsid()
         if not self.axWidget.setControl(clsid):
             QMessageBox.warning(self, "AxViewer", "Unable to load " + clsid + ".")
Ejemplo n.º 11
0
        start = 0
        if (availableSamples < sampleCount):
            start = sampleCount - availableSamples
            for s in range(start):
                self.buffer[s].setY(self.buffer[s + availableSamples].y())

        dataIndex = 0
        for s in range(start, sampleCount):
            value = (ord(data[dataIndex]) - 128) / 128
            self.buffer[s].setY(value)
            dataIndex = dataIndex + resolution
        self.series.replace(self.buffer)


if __name__ == '__main__':
    app = QApplication(sys.argv)

    inputDevice = QAudioDeviceInfo.defaultInputDevice()
    if (inputDevice.isNull()):
        QMessageBox.warning(None, "audio",
                            "There is no audio input device available.")
        sys.exit(-1)

    mainWin = MainWindow(inputDevice)
    mainWin.setWindowTitle("audio")
    availableGeometry = app.desktop().availableGeometry(mainWin)
    size = availableGeometry.height() * 3 / 4
    mainWin.resize(size, size)
    mainWin.show()
    sys.exit(app.exec_())
Ejemplo n.º 12
0
 def show_warning(self, title: str, text: str) -> None:
     QMessageBox.warning(self.main_window, title, text)
Ejemplo n.º 13
0
 def warning(self, *args, **kwargs):
     response = QMessageBox.warning(self, *args, **kwargs)
     return response
Ejemplo n.º 14
0
 def show_warning(text, parent):
     QMessageBox.warning(parent, Message.LEVEL_NAMES[Level.Warning.value],
                         text)