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_()
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_()
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_()
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")
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_()
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)
def message(self, message): error = QErrorMessage(self) error.showMessage(message)
def showMessage(self, message: str, type: Any = None) -> None: message = self.template % (html.escape(message)) QErrorMessage.showMessage(self, message, type)