für ein Schulprojekt bin ich dabei einen Funtionsplotter zu programmieren.
Aus einem Tkinter-entry soll die vorher eingegebene Funktion ausgelesen und geplottet werden.
Allerdings hat matplotlib bzw numpy ein problem damit, wenn ichs mit "get text " auslesen will.
Hier mal mein Programmcode bisher:
Code: Alles auswählen
import matplotlib.pyplot as plt
import numpy as np
import Tkinter
import pylab as p
root = Tkinter.Tk()
root.title("Projekt")
f1 = Tkinter.Frame(root, bg = "red")
f1.pack()
l1 = Tkinter.Label(f1, text = "Funktion")
l1.pack()
e1 = Tkinter.Entry(f1, width = 30)
e1.pack()
l2 = Tkinter.Label(f1, text = "Startwert der Funktion")
l2.pack()
e2 = Tkinter.Entry(f1, width = 15)
e2.pack()
l3 = Tkinter.Label(f1, text = "Endwert der Funktion")
l3.pack()
e3 = Tkinter.Entry(f1, width = 15)
e3.pack()
l4 = Tkinter.Label(f1, text = "Abstand zwischen zu berechnenden Punkten")
l4.pack()
e4 = Tkinter.Entry(f1, width = 15)
e4.pack()
def plot():
x = p.arange (int(e2.get()),int( e3.get()),int( e4.get()))
y = p.sin(x)
p.plot(x,y)
## pass
b1 = Tkinter.Button(f1, text = "Funktion Plotten", command = plot())
b1.pack()
danke schonmal im vorraus!