def closeEvent(self, event): database = QtSql.QSqlDatabase.addDatabase('QSQLITE') database.setDatabaseName('data.db') database.close() self._client.stop() asyncio.get_event_loop().stop() asyncio.get_event_loop().close() QApplication.instance().closingDown() os._exit(0)
def changeSkin(self): from PyQt5.Qt import QApplication if self.origan_skin: skin = "skin2.qss" self.origan_skin = False else: skin = "skin.qss" self.origan_skin = True QApplication.instance().setStyleSheet( utils.StyleReader.readQssFromFile(skin))
def get_application(): """Get the singleton QApplication""" from quamash import QApplication if not len(_application_): application = QApplication.instance() if not application: import sys application = QApplication(sys.argv) _application_.append( application ) return _application_[0]
def get_application(): """Get the singleton QApplication""" from quamash import QApplication if not len(_application_): application = QApplication.instance() if not application: import sys application = QApplication(sys.argv) _application_.append(application) return _application_[0]
def get_application(): """Get the singleton QApplication""" from quamash import QApplication if not len(_application_): application = QApplication.instance() if not application: import sys application = QApplication(sys.argv) application.setQuitOnLastWindowClosed(False) _application_.append(application) return _application_[0]
def load(cls): app = QApplication.instance() theme = LocalStorage.themeGet() skin_qss = '{qss_path}/theme/{theme}/skin.qss'.format( qss_path=Config().qss_path, theme=theme) style_qss = '{qss_path}/theme/{theme}/style.qss'.format( qss_path=Config().qss_path, theme=theme) qss_string = '' # 0).资源文件 skin_rc = importlib.import_module( 'resources.qss.theme.{theme}.skin_rc'.format(theme=theme)) style_rc = importlib.import_module( 'resources.qss.theme.{theme}.style_rc'.format(theme=theme)) skin_rc.qInitResources() style_rc.qInitResources() # 1).自带皮肤 app.setStyle('Fusion') # 2).调色板 palette_module = importlib.import_module( 'resources.qss.theme.{theme}.palette'.format(theme=theme)) cls.palette = getattr(palette_module, 'Palette') cls.palette.render(app) # 3).通用样式表 with open(COMMON_STYLE) as stylesheet: qss_string += stylesheet.read() # 4).皮肤样式表 with open(skin_qss) as stylesheet: qss_string += stylesheet.read() # 5).界面样式表 with open(style_qss, encoding='utf-8') as stylesheet: qss_string += stylesheet.read() # 6).设置样式 app.setStyleSheet(qss_string) # 7).抗锯齿 font = app.font() font.setStyleStrategy(QFont.PreferAntialias) app.setFont(font)