def assign_var_text_changed(text = None): if text == None: text = self.assign_var.text() font = self.assign_var.font() fm = QFontMetrics(font); pixelsWide = fm.width(text); # pixelsHigh = fm.height(); self.assign_var.setFixedSize(pixelsWide + 10, self.assign_var.height()) text = self.assign_var.text() text = text.replace(" ", "") self.assign_var.setText(text)
def createEditor(self, parent, option, index): editor = QTextEdit(parent) highlight = syntax.PythonHighlighter(editor.document()) font = QFont("Courier") font.setFamily("Courier"); font.setStyleHint(QFont.Monospace); font.setFixedPitch(True); font.setPointSize(10); editor.setFont(font) tab_stop = 4; # 4 characters metrics = QFontMetrics(font) editor.setTabStopWidth(tab_stop * metrics.width(' ')); return editor