def onLoginErrored(self, message): AppLog.debug('onLoginErrored') self._isLogin = False self.buttonLogin.showWaiting(False) self.setEnabled(True) AppLog.error(message) if message: self.labelNotice.setText(message)
def loadTheme(cls): """根据配置加载主题 :param cls: :param parent: """ cls.ThemeName = Setting.value('theme', 'Default', str) # 加载主题中的字体 path = cls.fontPath() AppLog.info('fontPath: {}'.format(path)) if os.path.exists(path): QFontDatabase.addApplicationFont(path) # 加载主题取样式 path = cls.stylePath() AppLog.info('stylePath: {}'.format(path)) try: QApplication.instance().setStyleSheet( open(path, 'rb').read().decode('utf-8', errors='ignore')) except Exception as e: AppLog.error(str(e))
def loadFestivalTheme(cls, image=None): """根据配置加载主题 :param cls: :param parent: :param image: 背景图片 """ cls.ThemeName = Setting.value('theme', 'Default', str) # 加载主题取样式 path = cls.stylePath() AppLog.info('stylePath: {}'.format(path)) try: styleSheet = open(path, 'rb').read().decode('utf-8', errors='ignore') # 需要替换部分样式 if image and os.path.isfile(image): # 获取图片主色调 color_thief = ColorThief(image) color = color_thief.get_color() AppLog.info('dominant color: {}'.format(str(color))) styleSheet += StyleTemplate.format( os.path.abspath(image).replace('\\', '/'), *color) QApplication.instance().setStyleSheet(styleSheet) except Exception as e: AppLog.error(str(e))