import tkinter as tk from tkinter import messagebox, ttk import math import cmath class CasioBakMode: def __init__(self, root): self.root = root self.root.title("Casio fx-991ES Plus - Baccalaureate Edition") self.root.geometry("450x700") self.root.configure(bg="#1e1e1e") # لون داكن احترافي # شاشة العرض الأساسية self.display = tk.Entry(root, font=("DS-Digital", 30), bg="#9eb29d", fg="#1a1a1a", justify="right", bd=15, relief="sunken") self.display.pack(fill="x", padx=20, pady=20) # منطقة عرض النتائج التفصيلية (للمعادلات والأعداد المركبة) self.info_label = tk.Label(root, text="جاهز للعمليات العلمية", bg="#1e1e1e", fg="#00ff00", font=("Arial", 10)) self.info_label.pack() self.create_interface() def create_interface(self): # إطار الأزرار btn_frame = tk.Frame(self.root, bg="#1e1e1e") btn_frame.pack(pady=10) # أزرار الوظائف الخاصة بالبكالوريا special_ops = [ ('Solve ax²+b', self.solve_quad), ('Complex Z', self.complex_mode), ('Integral', self.show_integral_msg), ('Clear AC', self.clear) ] for i, (text, cmd) in enumerate(special_ops): btn = tk.Button(btn_frame, text=text, width=12, bg="#d35400", fg="white", font=("Arial", 10, "bold"), command=cmd) btn.grid(row=0, column=i, padx=2, pady=5) # لوحة الأرقام والعمليات الأساسية buttons = [ 'sin', 'cos', 'tan', 'log', '7', '8', '9', '/', '4', '5', '6', '*', '1', '2', '3', '-', '0', '.', '=', '+' ] row, col = 1, 0 for btn_text in buttons: action = lambda x=btn_text: self.click_event(x) tk.Button(btn_frame, text=btn_text, width=6, height=2, bg="#34495e", fg="white", font=("Arial", 14), command=action).grid(row=row, column=col, padx=5, pady=5) col += 1 if col > 3: col = 0 row += 1 def click_event(self, key): if key == "=": try: # تحويل التعبيرات لتناسب بايثون exp = self.display.get().replace('sin', 'math.sin').replace('cos', 'math.cos') res = eval(exp) self.display.delete(0, tk.END) self.display.insert(tk.END, str(res)) except: messagebox.showerror("خطأ", "تأكد من كتابة العملية بشكل صحيح") else: self.display.insert(tk.END, key) def clear(self): self.display.delete(0, tk.END) # ميزة حل معادلة من الدرجة الثانية (مهمة جداً للطلاب) def solve_quad(self): try: # نطلب من الطالب إدخال المعاملات في خانة العرض مفصولة بفاصلة data = self.display.get().split(',') a, b, c = float(data[0]), float(data[1]), float(data[2]) delta = b**2 - 4*a*c if delta > 0: x1 = (-b + math.sqrt(delta)) / (2*a) x2 = (-b - math.sqrt(delta)) / (2*a) self.info_label.config(text=f"Δ={delta} | x1={round(x1,2)}, x2={round(x2,2)}") elif delta == 0: x = -b / (2*a) self.info_label.config(text=f"Δ=0 | حل مضاعف: {x}") else: self.info_label.config(text="Δ < 0 | لا توجد حلول حقيقية (حلول مركبة)") except: messagebox.showinfo("طريقة الاستخدام", "أدخل المعاملات هكذا: a,b,c ثم اضغط Solve\nمثال: 1,-5,6") # ميزة الأعداد المركبة def complex_mode(self): try: z = complex(self.display.get()) r, phi = cmath.polar(z) self.info_label.config(text=f"الطويلة (r): {round(r,2)} | العمدة (θ): {round(phi,2)} rad") except: messagebox.showinfo("طريقة الاستخدام", "أدخل العدد المركب: 3+4j (استخدم j بدل i)") def show_integral_msg(self): messagebox.showinfo("قريباً", "ميزة حساب التكامل العددي قيد التطوير في النسخة القادمة!") if __name__ == "__main__": root = tk.Tk() app = CasioBakMode(root) root.mainloop()