By Maskely
Hectopat
- Katılım
- 12 Aralık 2020
- Mesajlar
- 109
Daha fazla
- Cinsiyet
- Erkek
Python:
import numpy as np
import matplotlib.pyplot as plt
from tkinter import *
import tkinter as tk # Tkinter modülünü içe aktar
class FunctionPlotter:
def __init__(self, root):
self.root = root
self.root.title("Fonksiyon Grafiği Çizici")
self.input_frame = Frame(self.root)
self.input_frame.pack(side=LEFT)
self.plot_frame = Frame(self.root)
self.plot_frame.pack(side=RIGHT)
self.functions = []
self.create_input_widgets()
self.create_plot_widgets()
def create_input_widgets(self):
self.function_entry = Entry(self.input_frame, width=20)
self.function_entry.pack(pady=10)
self.add_button = Button(self.input_frame, text="Fonksiyon Ekle", command=self.add_function)
self.add_button.pack()
self.finish_button = Button(self.input_frame, text="Bitti", command=self.plot_functions)
self.finish_button.pack(pady=10)
def add_function(self):
function_entry = Entry(self.input_frame, width=20)
function_entry.pack(pady=5)
self.functions.append(function_entry)
def plot_functions(self):
x = np.linspace(-10, 10, 400)
colors = ['r', 'g', 'b', 'c', 'm', 'y'] # Farklı renkler
plt.figure()
for i, function_entry in enumerate(self.functions):
try:
function_str = function_entry.get()
y = eval(function_str)
plt.plot(x, y, label='f(x) = ' + function_str, color=colors[i % len(colors)])
except Exception as e:
print("Hata: Geçersiz fonksiyon!")
plt.axhline(0, color='black', linewidth=1) # y=0 çizgisi
plt.axvline(0, color='black', linewidth=1) # x=0 çizgisi
plt.title('Girilen Fonksiyonların Grafikleri')
plt.xlabel('x')
plt.ylabel('f(x)')
plt.grid(True)
plt.legend()
plt.show()
def create_plot_widgets(self):
# Burada isteğinize göre plot_frame'e grafik oluşturulabilir.
root = Tk() <----------- HATA BU SATIRDA
function_plotter = FunctionPlotter(root)
root.mainloop()
Satır 63'de Expected indented block hatası veriyor ve root kelimesinin altını kırmızı bir şekilde çiziyor. Bunu nasıl düzeltebilirim? Chat GPT'ye sordum yapamadı.