Пример #1
0
def _main(args):
    # import pydm
    # app = QApplication([])
    # app = pydm.PyDMApplication()
    app = QApplication([])
    signal.signal(signal.SIGINT, signal.SIG_DFL)

    from xicam.gui.windows import splash
    from xicam.core import msg

    if args.verbose in sys.argv:
        QErrorMessage.qtHandler()

    # start splash in subprocess
    splash_proc = QProcess()
    # splash_proc.started.connect(lambda: print('started splash'))
    # splash_proc.finished.connect(lambda: print('finished splashing'))
    log_file = msg.file_handler.baseFilename
    initial_length = os.path.getsize(log_file)
    splash_proc.start(sys.executable,
                      [splash.__file__, log_file,
                       str(initial_length)])

    from xicam.gui.windows.mainwindow import XicamMainWindow
    mainwindow = XicamMainWindow()
    while splash_proc.state() != QProcess.NotRunning:
        app.processEvents()
    # splash_proc.waitForFinished()
    mainwindow.show()

    # splash = splash.XicamSplashScreen(args=args)
    return sys.exit(app.exec_())
Пример #2
0
def _main(args, exec=True):
    global mainwindow, splash_proc, show_check_timer
    # import pydm
    # app = QApplication([])
    # app = pydm.PyDMApplication()
    app = QApplication.instance() or QApplication([])
    signal.signal(signal.SIGINT, signal.SIG_DFL)

    from xicam.gui.windows import splash
    from xicam.core import msg

    if getattr(args, 'verbose', False):
        QErrorMessage.qtHandler()

    # start splash in subprocess
    splash_proc = QProcess()
    # splash_proc.started.connect(lambda: print('started splash'))
    # splash_proc.finished.connect(lambda: print('finished splashing'))
    log_file = msg.file_handler.baseFilename
    initial_length = os.path.getsize(log_file)
    splash_proc.start(sys.executable,
                      [splash.__file__, log_file,
                       str(initial_length)])

    show_check_timer = QTimer()
    show_check_timer.timeout.connect(check_show_mainwindow)
    show_check_timer.start(100)

    from xicam.gui.windows.mainwindow import XicamMainWindow

    mainwindow = XicamMainWindow()

    if exec:
        return app.exec_()
    else:
        return mainwindow
Пример #3
0
    def request_linelists(self, *args, **kwargs):
        self.waverange = self._find_wavelength_range()

        self.linelists = ingest(self.waverange)

        if len(self.linelists) == 0:
            error_dialog = QErrorMessage()
            error_dialog.showMessage('Units conversion not possible. '
                                     'Or, no line lists in internal library '
                                     'match wavelength range.')
            error_dialog.exec_()
Пример #4
0
    def loadPatientDetails(self):
        try:
            with open('data.txt') as json_file:
                data = json.load(json_file)

            self.nameInput.setText(data["Name"])
            self.ageInput.setText(data["Age"])
        except:

            error_dialog = QErrorMessage()
            error_dialog.showMessage('Could not load patient data')
            error_dialog.exec_()
Пример #5
0
    def on_ventSetButton_clicked(self):

        airVol = self.widget.tidalVolume.currentText()
        breaths_per_min = self.widget.respirationRate.currentText()
        ie_ratio = self.widget.inhaleExhaleRatio.currentText().split(":")[1]

        command = "{\"airVol\": %i, \"breathsPerMinute\": %i, \"ieRate\": %i}" % (
            int(airVol), int(breaths_per_min), int(ie_ratio))
        try:
            self.s.write(bytes(command.encode()))
        except:
            error_dialog = QErrorMessage()
            error_dialog.showMessage('Failed to set vent values, try again!')
            error_dialog.exec_()
Пример #6
0
    def savePatientDetails(self):
        try:
            data = {}
            data["Name"] = self.nameInput.text()
            data["Age"] = self.ageInput.text()

            with open("data.txt", "w") as outfile:
                json.dump(data, outfile)
        except:

            error_dialog = QErrorMessage()
            error_dialog.showMessage('Could not save patient data')
            error_dialog.exec_()

            print("Could not set name")
Пример #7
0
    def _lineList_selection_change(self, index):
        # ignore first element in drop down. It contains
        # the "Select line list" message.
        if index > 0 and hasattr(self.hub, 'plot_widget') and self.hub.plot_widget.spectral_axis_unit:
            line_list = linelist.get_from_cache(index - 1)

            try:
                self._get_waverange_from_dialog(line_list)
                if self.wave_range[0] and self.wave_range[1]:
                    self._build_view(line_list, 0, waverange=self.wave_range)

                self.line_list_selector.setCurrentIndex(0)

            except UnitConversionError as err:
                error_dialog = QErrorMessage()
                error_dialog.showMessage('Units conversion not possible.')
                error_dialog.exec_()
Пример #8
0
    def _lineList_selection_change(self, index):
        # ignore first element in drop down. It contains
        # the "Select line list" message.
        if index > 0:
            line_list = linelist.get_from_cache(index - 1)

            try:
                self._get_waverange_from_dialog(line_list)
                global wave_range
                if wave_range[0] and wave_range[1]:
                    self._build_view(line_list, 0, waverange=wave_range)

                self.line_list_selector.setCurrentIndex(0)

            except UnitConversionError as err:
                error_dialog = QErrorMessage()
                error_dialog.showMessage('Units conversion not possible.')
                error_dialog.exec_()
    def _save_callback(self, event=None):

        if len(self.animation.key_frames) < 2:
            error_dialog = QErrorMessage()
            error_dialog.showMessage(
                f"You need at least two key frames to generate \
                an animation. Your only have {len(self.animation.key_frames)}")
            error_dialog.exec_()

        else:
            filters = (
                "Video files (*.mp4 *.gif *.mov *.avi *.mpg *.mpeg *.mkv *.wmv)"
                ";;Folder of PNGs (*)"  # sep filters with ";;"
            )
            filename, _filter = QFileDialog.getSaveFileName(
                self, "Save animation", str(Path.home()), filters)
            if filename:
                self.animation.animate(filename)
Пример #10
0
def main():
    app = QApplication(sys.argv)
    if getattr(sys, 'frozen', False):
        iconPath = os.path.join(sys._MEIPASS, 'Icon.ico')
    else:
        iconPath = os.path.abspath(
            os.path.join(os.path.dirname('__file__'), '../icons/Icon.ico'))
    if os.path.exists(iconPath):
        app.setWindowIcon(QIcon(iconPath))
    form = PyPolarmap(app)
    # setup the error handler
    global e_dialog
    e_dialog = QErrorMessage(form)
    e_dialog.setWindowModality(QtCore.Qt.WindowModal)
    font = QFont()
    font.setFamily("Consolas")
    font.setPointSize(8)
    e_dialog.setFont(font)
    form.show()
    app.exec_()
Пример #11
0
    app = QApplication(sys.argv)
    if getattr(sys, 'frozen', False):
        icon_path = os.path.join(sys._MEIPASS, 'Icon.ico')
    else:
        icon_path = os.path.abspath(
            os.path.join(os.path.dirname('__file__'), '../icons/Icon.ico'))
    if os.path.exists(icon_path):
        app.setWindowIcon(QIcon(icon_path))
    return app, Preferences(QSettings("3ll3d00d", "qvibe-analyser"))


if __name__ == '__main__':
    app, prefs = make_app()
    form = QVibe(app, prefs)
    # setup the error handler
    e_dialog = QErrorMessage(form)
    e_dialog.setWindowModality(QtCore.Qt.WindowModal)
    font = QFont()
    font.setFamily("Consolas")
    font.setPointSize(8)
    e_dialog.setFont(font)
    # add the exception handler so we can see the errors in a QErrorMessage
    sys._excepthook = sys.excepthook

    def dump_exception_to_log(exctype, value, tb):
        import traceback
        print(exctype, value, tb)
        global e_dialog
        if e_dialog is not None:
            formatted = traceback.format_exception(etype=exctype,
                                                   value=value,
Пример #12
0
 def message(self, message):
     error = QErrorMessage(self)
     error.showMessage(message)
Пример #13
0
 def showMessage(self, message: str, type: Any = None) -> None:
     message = self.template % (html.escape(message))
     QErrorMessage.showMessage(self, message, type)
Пример #14
0
 def __init__(self, parent: Optional[QWidget] = None):
     QErrorMessage.__init__(self, parent)
     self.resize(self.w, self.h)