Darstellung von Latexcode mit PyQt
Verfasst: Montag 21. März 2016, 14:10
Hallo, ich habe eine Möglichkeit gefunden eine Latexdarstellung eines Vektors zu bilden. Allerdings weiß ich nicht, wie ich das in einem Label von PyQt ausgebe. Folgenden Code habe ich nicht zum Laufen gebracht:
Inbsbesondere die Zeile: labelPT.setText("$\langle" + a1 + "\\rangle$")
funktioniert nicht.
Code: Alles auswählen
from PyQt4 import QtGui, QtCore
import sys
from sympy.matrices import *
from sympy.printing import *
from IPython.display import display, HTML, Math, Latex, clear_output
# from ipywidgets import widgets
from random import randint
if __name__ == '__main__':
app = QtGui.QApplication(sys.argv)
mw = QtGui.QWidget()
x = Matrix()
x = Matrix([randint(-20,20), randint(-20,20), randint(-20,20)])
a1 = latex(x)
a1 = a1.replace("left[", "left(")
a1 = a1.replace("right]", "right)")
print (a1)
labelPT = QtGui.QLabel()
labelPT.setText("$\langle" + a1 + "\\rangle$")
labelPT.setAlignment(QtCore.Qt.AlignRight)
labelRT = QtGui.QLabel()
labelRT.setText('one two three four <b>five</b> six seven eight nine ten')
labelRT.setAlignment(QtCore.Qt.AlignRight)
vbox = QtGui.QVBoxLayout()
vbox.addWidget(labelPT)
vbox.addWidget(labelRT)
mw.setLayout(vbox)
mw.setMinimumWidth(30)
mw.show()
sys.exit(app.exec_())
funktioniert nicht.