ich arbeite gerade an einem Projekt, bei dem ich mir das Erstellen von wissenschaftlichen Dokumenten erleichtern will und will nun gerne zu Python statt zu Java greifen.
Bisher sieht der Editor sehr primitiv aus: Er hat ein Entry, um Formeln einzugeben und ein Textfeld.
Was mir fehlt ist die Implementierung der "Converter"-Funktion von sympy.
Ich gehe davon aus, dass ich mir ein Image aus einem String (Latex String zb: \sum_{i=0}^n i^2 = \frac{(n^2+n)(2n+1)}{6}) erzeugen lassen muss, das ich dann zu dem TextFeld hinzufügen muss.
Das Bild sollte "noch" nirgendwo abgespeichert werden, sondern direkt in das Textfeld hinzugefügt werden, sobald der Benutzer Enter drückt.
Über Hilfe wäre ich sehr dankbar
Mein bisheriger Code:
Code: Alles auswählen
from Tkinter import *
def evaluate(event):
text = entry.get()
if(text.startswith("\\n")):
text = text.replace("\\n", "", 1)
T.insert(END, "\n")
if(text.startswith("\\")):
#hier muss die Convert-Function hin...
print ("Is convertable. So pass to a sympy and convert to latex?")
T.insert(END, text)
root = Tk()
entry = Entry(root)
entry.bind("<Return>", evaluate)
entry.pack()
S = Scrollbar(root)
T = Text(root)
S.pack(side=RIGHT)
T.pack(side=LEFT)
#S.config(command=T.yview)
#T.config(yscrollcommand=S.set)
quote = """HAMLET: To be, or not to be--that is the question:
Whether 'tis nobler in the mind to suffer
The slings and arrows of outrageous fortune
Or to take arms against a sea of troubles
And by opposing end them. To die, to sleep--
No more--and by a sleep to say we end
The heartache, and the thousand natural shocks
That flesh is heir to. 'Tis a consummation
Devoutly to be wished."""
T.insert(END, quote)
mainloop( )