import tkinter as tk
from tkinter import ttk
import matplotlib.pyplot as plt
from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg
import numpy as np
def calculate_neutronsys(x):
# 예시 방정식입니다. 실제 뉴트론시스 방정식을 알고 계시면 이 부분을 수정하세요.
return np.sin(x) * np.exp(-x / 5)
def plot_graph():
try:
x_value = float(entry_x.get())
x_values = np.linspace(0, x_value, 100)
y_values = calculate_neutronsys(x_values)
ax.clear()
ax.plot(x_values, y_values, label="Neutronsys Equation Result")
ax.set_xlabel("X")
ax.set_ylabel("Y")
ax.set_title("Neutronsys Equation Graph")
ax.legend()
canvas.draw()
except ValueError:
error_label.config(text="숫자를 입력해주세요.")
root = tk.Tk()
root.title("Neutronsys Equation Grapher")
frame = ttk.Frame(root, padding="10")
frame.grid(row=0, column=0)
ttk.Label(frame, text="X 값 입력:").grid(row=0, column=0)
entry_x = ttk.Entry(frame)
entry_x.grid(row=0, column=1)
plot_button = ttk.Button(frame, text="그래프 생성", command=plot_graph)
plot_button.grid(row=1, column=0, columnspan=2)
error_label = ttk.Label(frame, text="", foreground="red")
error_label.grid(row=2, column=0, columnspan=2)
fig, ax = plt.subplots()
canvas = FigureCanvasTkAgg(fig, master=root)
canvas.get_tk_widget().grid(row=1, column=0)
root.mainloop()
https://www.tistory.com/event/write-challenge-2024
'정보통신기술(ICT)' 카테고리의 다른 글
파이썬-기반 GUI 볼텍스 형상화(Python-based GUI Vortex Visualization) (0) | 2024.11.11 |
---|---|
초연공학(Conscious Engineering) (0) | 2024.11.10 |
반데르발스 헤테르구조(Vanderwaals Heterostructures) (3) | 2024.11.06 |
양자역학: 터널링 효과(Quantum Tunneling Effect) (4) | 2024.11.05 |
상미분 방정식: 로렌츠 방정식(Lorenz Equations) (3) | 2024.11.04 |