Inquiry Regarding Accessing Output Title, Code
Hello Support,
I'm reaching out to inquire whether it's possible to retrieve the title (or Code) of the output after a user runs code, either with or without utilizing an API. Specifically, I'm interested in understanding if there's a way to programmatically access the title of the output generated by the code execution process from parent window.
Thank you for your assistance.
1 Answer
لم يتم عرض الكود بسبب الحد الذي فرضه نظام المحادثة، لكن يمكنني تقديم مثال على كيفية استخدام مكتبة Tkinter في Python لإنشاء واجهة رسومية بسيطة لتطبيق إدارة وصفات الطعام. إليك مثال بسيط:
import tkinter as tk
# دالة لعرض نافذة جديدة لتفاصيل الوصفة
def show_recipe_details():
recipe_name = recipe_name_entry.get()
recipe_country = recipe_country_entry.get()
recipe_ingredients = recipe_ingredients_entry.get("1.0", "end")
recipe_servings = servings_scale.get()
# هنا يمكنك عرض تفاصيل الوصفة في نافذة جديدة
recipe_details_window = tk.Toplevel(root)
recipe_details_window.title("تفاصيل الوصفة")
# تفاصيل الوصفة
recipe_details_label = tk.Label(recipe_details_window, text=f"اسم الوصفة: {recipe_name}\nالبلد: {recipe_country}\nالمكونات:\n{recipe_ingredients}\nعدد الأفراد: {recipe_servings}")
recipe_details_label.pack()
# إنشاء نافذة رئيسية
root = tk.Tk()
root.title("إدارة وصفات الطعام")
# العناصر على النافذة الرئيسية
recipe_name_label = tk.Label(root, text="اسم الوصفة:")
recipe_name_label.grid(row=0, column=0)
recipe_name_entry = tk.Entry(root)
recipe_name_entry.grid(row=0, column=1)
recipe_country_label = tk.Label(root, text="البلد:")
recipe_country_label.grid(row=1, column=0)
recipe_country_entry = tk.Entry(root)
recipe_country_entry.grid(row=1, column=1)
recipe_ingredients_label = tk.Label(root, text="المكونات:")
recipe_ingredients_label.grid(row=2, column=0)
recipe_ingredients_entry = tk.Text(root, height=5, width=30)
recipe_ingredients_entry.grid(row=2, column=1)
servings_label = tk.Label(root, text="عدد الأفراد:")
servings_label.grid(row=3, column=0)
servings_scale = tk.Scale(root, from_=1, to=10, orient=tk.HORIZONTAL)
servings_scale.grid(row=3, column=1)
show_details_button = tk.Button(root, text="عرض تفاصيل الوصفة", command=show_recipe_details)
show_details_button.grid(row=4, column=0, columnspan=2)
# تشغيل النافذة الرئيسية
root.mainloop()
هذا مثال بسيط يستخدم مكتبة Tkinter لإنشاء واجهة رسومية تسمح للمستخدم بإدخال معلومات وصفة الطعام وعرض تفاصيلها. يمكنك توسيع هذا المثال لتضمين المزيد من الميزات والوظائف وفقًا لاحتياجات التطبيق الخاص بك.