def updateWidth(self, text: str, font_metrics: QFontMetricsF): """обновление ширины""" # rect = font_metrics.boundingRect(text) size = font_metrics.size(Qt.TextSingleLine, text) width = size.width() if width > self.width: self.width = round(width) + 0
def changeTheme(self): """ Simple forwarding of selected theme. """ self.colorPane.clear() desc = lookupTheme(self.optionsPane.comboTheme.currentText()).getDesc() self.colorPane.insertHtml(desc) font = self.colorPane.document().defaultFont() fmF = QFontMetricsF(font) text = self.colorPane.document().toPlainText() textSize = fmF.size(0, text) hgt = textSize.height() + 10 self.colorPane.setFixedHeight(hgt) del desc, font, fmF, text, textSize, hgt if self.optionsPane.comboTheme.currentText() == "Conservation": self.optionsPane.checkConsv.setChecked(True) if self._currentWindow: self.optionsPane.comboReference.setCurrentIndex(1) self._currentWindow.widget().setTheme( self.optionsPane.comboTheme.currentText())