Вот пример тригонометрического калькулятора с использованием библиотеки Tkinter на Python:
import math
import tkinter as tk
def calculate():
angle = float(angle_entry.get())
radians = math.radians(angle)
sin_value = math.sin(radians)
cos_value = math.cos(radians)
tan_value = math.tan(radians)
sin_label.config(text=f"Sin: {sin_value:.4f}")
cos_label.config(text=f"Cos: {cos_value:.4f}")
tan_label.config(text=f"Tan: {tan_value:.4f}")
# Create the main window
window = tk.Tk()
window.title("Trig Calculator")
# Create the angle input entry
angle_entry = tk.Entry(window)
angle_entry.pack()
# Create the calculate button
calculate_button = tk.Button(window, text="Calculate", command=calculate)
calculate_button.pack()
# Create the labels to display the results
sin_label = tk.Label(window, text="Sin: ")
sin_label.pack()
cos_label = tk.Label(window, text="Cos: ")
cos_label.pack()
tan_label = tk.Label(window, text="Tan: ")
tan_label.pack()
# Run the main window loop
window.mainloop()
Этот код создает простое окно графического интерфейса Tkinter с полем для ввода угла. При нажатии кнопки «Рассчитать» происходит вычисление и отображение значений синуса, косинуса и тангенса введенного угла.