def quit_application(self): # Stops animation (updating changing elements of the Figure) self.anim._stop() # Stops the two threads updating the GUI labels and updating the state of Cart instance self.run_set_labels_thread = False self.terminate_experiment_or_replay_thread = True self.pause_experiment_or_replay_thread = False # Closes the GUI window self.close() # The standard command # It seems however not to be working by its own # I don't know how it works QApplication.quit()
def test_sanity(tmp_path): # Segfault test app = QApplication([]) ex = Example() assert app # Silence warning assert ex # Silence warning for mode in ("1", "RGB", "RGBA", "L", "P"): # to QPixmap im = hopper(mode) data = ImageQt.toqpixmap(im) assert isinstance(data, QPixmap) assert not data.isNull() # Test saving the file tempfile = str(tmp_path / f"temp_{mode}.png") data.save(tempfile) # Render the image qimage = ImageQt.ImageQt(im) data = QPixmap.fromImage(qimage) qt_format = QImage.Format if ImageQt.qt_version == "6" else QImage qimage = QImage(128, 128, qt_format.Format_ARGB32) painter = QPainter(qimage) image_label = QLabel() image_label.setPixmap(data) image_label.render(painter, QPoint(0, 0), QRegion(0, 0, 128, 128)) painter.end() rendered_tempfile = str(tmp_path / f"temp_rendered_{mode}.png") qimage.save(rendered_tempfile) assert_image_equal_tofile(im.convert("RGBA"), rendered_tempfile) # from QPixmap roundtrip(hopper(mode)) app.quit() app = None
def test_sanity(tmp_path): # Segfault test app = QApplication([]) ex = Example() assert app # Silence warning assert ex # Silence warning for mode in ("1", "RGB", "RGBA", "L", "P"): # to QPixmap data = ImageQt.toqpixmap(hopper(mode)) assert isinstance(data, QPixmap) assert not data.isNull() # Test saving the file tempfile = str(tmp_path / f"temp_{mode}.png") data.save(tempfile) # from QPixmap roundtrip(hopper(mode)) app.quit() app = None
def __init__(self, parent=None): super().__init__(parent) self.setupUi(self) self.TRAY = QSystemTrayIcon(self) self.TRAY.setIcon(QApplication.style().standardIcon( QStyle.StandardPixmap.SP_MessageBoxInformation)) self.TRAY.setToolTip('FGO-py') self.MENU_TRAY = QMenu(self) self.MENU_TRAY_QUIT = QAction('退出', self.MENU_TRAY) self.MENU_TRAY.addAction(self.MENU_TRAY_QUIT) self.MENU_TRAY_FORCEQUIT = QAction('强制退出', self.MENU_TRAY) self.MENU_TRAY.addAction(self.MENU_TRAY_FORCEQUIT) self.TRAY.setContextMenu(self.MENU_TRAY) self.TRAY.show() self.reloadTeamup() self.config = Config({ 'stopOnDefeated': (self.MENU_SETTINGS_DEFEATED, fgoKernel.schedule.stopOnDefeated), 'stopOnKizunaReisou': (self.MENU_SETTINGS_KIZUNAREISOU, fgoKernel.schedule.stopOnKizunaReisou), 'closeToTray': (self.MENU_CONTROL_TRAY, None), 'stayOnTop': (self.MENU_CONTROL_STAYONTOP, lambda x: self.setWindowFlag( Qt.WindowType.WindowStaysOnTopHint, x)), 'notifyEnable': (self.MENU_CONTROL_NOTIFY, None) }) self.notifier = ServerChann(**self.config['notifyParam']) self.worker = Thread() self.signalFuncBegin.connect(self.funcBegin) self.signalFuncEnd.connect(self.funcEnd) self.TRAY.activated.connect(lambda reason: self.show( ) if reason == QSystemTrayIcon.ActivationReason.Trigger else None) self.MENU_TRAY_QUIT.triggered.connect(lambda: QApplication.quit() if self.askQuit() else None) self.MENU_TRAY_FORCEQUIT.triggered.connect(QApplication.quit) self.getDevice()
def quit(self): "保险起见,为了完整的退出" self.setVisible(False) self.parent().exit() QApplication.quit() sys.exit()
def shutdown(self): self.close() QApplication.quit()