fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone
  9. {
  10. public static void main (String[] args) throws java.lang.Exception
  11. {
  12. // your code goes here
  13. }
  14. }
Success #stdin #stdout 0.12s 54724KB
stdin
import tkinter as tk

# إنشاء نافذة التطبيق
root = tk.Tk()
root.title("آلة حاسبة بسيطة")

# إدخال البيانات
entry = tk.Entry(root, width=40, borderwidth=5)
entry.grid(row=0, column=0, columnspan=4, padx=10, pady=10)

# دالة لإضافة الأرقام إلى المدخلات
def button_click(number):
    current = entry.get()
    entry.delete(0, tk.END)
    entry.insert(0, current + str(number))

# دالة لتنفيذ العملية الحسابية
def button_equal():
    try:
        result = eval(entry.get())
        entry.delete(0, tk.END)
        entry.insert(0, str(result))
    except:
        entry.delete(0, tk.END)
        entry.insert(0, "خطأ")

# دالة لمسح المدخلات
def button_clear():
    entry.delete(0, tk.END)

# إنشاء الأزرار
buttons = [
    ('7', 1, 0), ('8', 1, 1), ('9', 1, 2), ('/', 1, 3),
    ('4', 2, 0), ('5', 2, 1), ('6', 2, 2), ('*', 2, 3),
    ('1', 3, 0), ('2', 3, 1), ('3', 3, 2), ('-', 3, 3),
    ('0', 4, 0), ('.', 4, 1), ('=', 4, 2), ('+', 4, 3),
]

# إضافة الأزرار إلى الواجهة
for text, row, col in buttons:
    if text == "=":
        btn = tk.Button(root, text=text, width=10, height=2, command=button_equal)
    else:
        btn = tk.Button(root, text=text, width=10, height=2, command=lambda t=text: button_click(t))
    btn.grid(row=row, column=col, padx=5, pady=5)

# زر مسح البيانات
btn_clear = tk.Button(root, text="C", width=10, height=2, command=button_clear)
btn_clear.grid(row=5, column=0, columnspan=4, padx=5, pady=5, sticky="we")

# تشغيل التطبيق
root.mainloop()
stdout
Standard output is empty