اذهب إلى المحتوى

Ahmed Ahmed64

الأعضاء
  • المساهمات

    222
  • تاريخ الانضمام

  • تاريخ آخر زيارة

كل منشورات العضو Ahmed Ahmed64

  1. السلام عليكم ما لمقصود بهذا الخطأ وكيف أستطيع معالجته معالجة هذا الخطأ pandas.errors.InvalidIndexError: Reindexing only valid with uniquely valued Index objects
  2. السلام عليكم مامفهوم هذا الخطأ AttributeError: 'DataFrame' object has no attribute 'append_df_to_excel' حيث أن لدي def وظيفته أنه يقرأ أعمدة من اكسل وأجري عليها بعض العمليات ومن ثم تحويلها إلى DataFrame وتخزينها في ملف جديد الفكرة التي أحاول الوصول إليها عند تنفيذ الكود مجدداً أريده أن يخزن البيانات الجديدة بحث يستكمل على أخر سطر في نفس الملف التخزين في نفس
  3. ما مشكلة هذا الخطأ _tkinter.TclError: window ".!menu" isn't a top-level window الكود كامل هنا import customtkinter import tkinter as tk from tkinter import filedialog, messagebox, ttk import pandas as pd from pathlib import Path class App(customtkinter.CTk): def __init__(self): super().__init__() self.title("App-v1") self.grid_columnconfigure(0, weight = 1) self.grid_rowconfigure(1, weight = 1) Menu(self) def File_dialog(self): self.filename = filedialog.askopenfilename(initialdir="C:\\Users\\Cakow\\PycharmProjects\\Main", title="Open file okay?", filetypes=(("text files", "*.xlsx"),("all files", "*.*"))) self.label_file["text"] = self.filename return None def Load_excel_data(self): file_path = self.label_file["text"] try: excel_filename = r"{}".format(file_path) if excel_filename[-4:] == ".csv": df = pd.read_csv(excel_filename) else: df = pd.ExcelFile(excel_filename) self.optionmenu1.configure(values = df.sheet_names) self.label2["text"] = df.sheet_names except ValueError: tk.messagebox.showerror("Information", "The file you have chosen is invalid") return None except FileNotFoundError: tk.messagebox.showerror("Information", f"No such file as {file_path}") return None class Menu(customtkinter.CTkFrame,App): def __init__(self, master): super().__init__(master) self.grid(row=0, column=0, padx=(10, 10), pady=(10, 10), sticky="e") self.columnconfigure(0, weight = 1) self.rowconfigure(1, weight = 1) self.create_widgets() def create_widgets(self): self.button1 = customtkinter.CTkButton(self, text = 'Button 1',command=self.File_dialog) self.button1.grid(row = 0, column = 0, sticky = 'e') self.label_file = ttk.Label(self, text="") self.label_file.grid(row = 1, column = 0, sticky = 'e') self.button2 = customtkinter.CTkButton(self, text = 'Button 1',command=self.Load_excel_data) self.button2.grid(row = 2, column = 0, sticky = 'e') self.label2 = ttk.Label(self, text="") self.label2.grid(row = 3, column = 0, sticky = 'e') self.optionmenu1 = customtkinter.CTkOptionMenu(self,values=["إختر ورقة العمل"], font=customtkinter.CTkFont(family="Calibri", size=12, weight="bold")) self.optionmenu1.grid(row=4, column=0, padx=(10, 10), pady=(10, 10), sticky="e") app = App() app.mainloop()
  4. أخي ماهي مشكلة هذا الخطأ _tkinter.TclError: window ".!menu" isn't a top-level window هذا الكود كامل import customtkinter import tkinter as tk from tkinter import filedialog, messagebox, ttk import pandas as pd from pathlib import Path class App(customtkinter.CTk): def __init__(self): super().__init__() self.title("App-v1") self.grid_columnconfigure(0, weight = 1) self.grid_rowconfigure(1, weight = 1) Menu(self) def File_dialog(self): self.filename = filedialog.askopenfilename(initialdir="C:\\Users\\Cakow\\PycharmProjects\\Main", title="Open file okay?", filetypes=(("text files", "*.xlsx"),("all files", "*.*"))) self.label_file["text"] = self.filename return None def Load_excel_data(self): file_path = self.label_file["text"] try: excel_filename = r"{}".format(file_path) if excel_filename[-4:] == ".csv": df = pd.read_csv(excel_filename) else: df = pd.ExcelFile(excel_filename) self.optionmenu1.configure(values = df.sheet_names) self.label2["text"] = df.sheet_names except ValueError: tk.messagebox.showerror("Information", "The file you have chosen is invalid") return None except FileNotFoundError: tk.messagebox.showerror("Information", f"No such file as {file_path}") return None class Menu(customtkinter.CTkFrame,App): def __init__(self, master): super().__init__(master) self.grid(row=0, column=0, padx=(10, 10), pady=(10, 10), sticky="e") self.columnconfigure(0, weight = 1) self.rowconfigure(1, weight = 1) self.create_widgets() def create_widgets(self): self.button1 = customtkinter.CTkButton(self, text = 'Button 1',command=self.File_dialog) self.button1.grid(row = 0, column = 0, sticky = 'e') self.label_file = ttk.Label(self, text="") self.label_file.grid(row = 1, column = 0, sticky = 'e') self.button2 = customtkinter.CTkButton(self, text = 'Button 1',command=self.Load_excel_data) self.button2.grid(row = 2, column = 0, sticky = 'e') self.label2 = ttk.Label(self, text="") self.label2.grid(row = 3, column = 0, sticky = 'e') self.optionmenu1 = customtkinter.CTkOptionMenu(self,values=["إختر ورقة العمل"], font=customtkinter.CTkFont(family="Calibri", size=12, weight="bold")) self.optionmenu1.grid(row=4, column=0, padx=(10, 10), pady=(10, 10), sticky="e") app = App() app.mainloop()
  5. السلام عليكم ورحمة الله وبركاته ما الفرق بين (parent) و (master) ومتى تستخدم كلا منهما class Menu(ttk.Frame): def __init__(self, parent): super().__init__(parent)
  6. السلام عليكم import tkinter as tk from tkinter import filedialog, messagebox, ttk import pandas as pd class App(tk.Tk): def __init__(self): super().__init__() self.title("App-v1") self.columnconfigure(0, weight = 1) self.rowconfigure(1, weight = 1) Menu(self) Load_excel_data() def File_dialog(self): """This Function will open the file explorer and assign the chosen file path to label_file""" filename = filedialog.askopenfilename(initialdir="/", title="Select A File", filetype=(("xlsx files", "*.xlsx"),("All Files", "*.*"))) label_file["text"] = filename return None def Load_excel_data(): """If the file selected is valid this will load the file into the Treeview""" file_path = label_file["text"] try: excel_filename = r"{}".format(file_path) if excel_filename[-4:] == ".csv": df = pd.read_csv(excel_filename) else: df = pd.read_excel(excel_filename) except ValueError: tk.messagebox.showerror("Information", "The file you have chosen is invalid") return None except FileNotFoundError: tk.messagebox.showerror("Information", f"No such file as {file_path}") return None class Menu(ttk.Frame): def __init__(self, parent): super().__init__(parent) self.grid(row=0, column=0, padx=(10, 10), pady=(10, 10), sticky="e") self.columnconfigure(0, weight = 1) self.rowconfigure(1, weight = 1) self.create_widgets() def create_widgets(self): self.menu_button1 = ttk.Button(self, text = 'Button 1',command=File_dialog) self.menu_button1.grid(row = 0, column = 0, sticky = 'e') app = App() app.mainloop()
  7. تصحيح للكود في ربط الكلاس ببعض import customtkinter from tkinter import filedialog from pathlib import Path import pandas as pd class App(customtkinter.CTk): def __init__(self): super().__init__() self.FilePath = None self.sh = None self.title("App-v1") self.grid_columnconfigure(0, weight=1) self.grid_rowconfigure(1, weight=1) customtkinter.set_appearance_mode("dark") customtkinter.set_default_color_theme("green") Frame_A = Frame1(self) Frame_A.grid(row=0, column=0, padx=(10, 10), pady=(10, 10), sticky="ew",columnspan=2) Frame_A.grid_columnconfigure(0, weight=1) Frame_A.configure(border_width=1,border_color="#0087f2") Frame_B = Frame2(self) Frame_B.grid(row=1, column=0, padx=(10, 10), pady=(10, 10), sticky="news") Frame_B.grid_columnconfigure(0, weight=1) Frame_B.configure(border_width=1,border_color="#0087f2") def LoadFile(self): self.FilePath = filedialog.askopenfilename(initialdir="C:\\Users\\Cakow\\PycharmProjects\\Main", title="Open file okay?", filetypes=(("text files", "*.xlsx"), ("all files", "*.*"))) return(self.FilePath) def LoadFile1(self): df = pd.ExcelFile(self.FilePath) self.sh= df.sheet_names print(self.sh) class Frame1(customtkinter.CTkFrame): def __init__(self, master): super().__init__(master) self.label1 = customtkinter.CTkLabel(self, text="Welcome", fg_color="transparent", font=customtkinter.CTkFont(family="Calibri", size=18, weight="bold"),justify="center") self.label1.grid(row=0, column=0, padx=(10, 10), pady=(10, 10), sticky="n") class Frame2(customtkinter.CTkFrame): def __init__(self, master): super().__init__(master) self.button1 = customtkinter.CTkButton(self, text="Open File", font=customtkinter.CTkFont(family="Calibri", size=12, weight="bold"),command=App.LoadFile) self.button1.grid(row=0, column=0, padx=(10, 10), pady=(10, 10), sticky="e") self.button2 = customtkinter.CTkButton(self, text="Open File", font=customtkinter.CTkFont(family="Calibri", size=12, weight="bold"),command=App.LoadFile1) self.button2.grid(row=0, column=0, padx=(10, 10), pady=(10, 10), sticky="e") app = App() app.mainloop()
  8. السلام عليكم أود أن أفهم بعض المصطلخات التي تستخدم ولماذا توضع في الكود الثالي على سبيل المثال class Frame_A(customtkinter.CTkFrame): def __init__(self, master): super().__init__(master) ما هي الفائدة من كلمة master كذلك كلمة super في حالة أردت ربط كلاس أخر مع هذا الكلاس أين يوضع اسم الكلاس المراد الربط به
  9. السلام عليكم ورحمة الله وبركاته لدي سؤال أود طرحة عليكم عند وجود أكثر مع أكثر من class كيف يتم الوصول للمتغيرات فمثلا لدينا class A وهذا الكلاس به دالة تقوم بعملية وترجع الناتج داخل متغير واحتاج أن أتعامل مع هذا المتغير داخل class B مثلا سؤالي أحتاج شرح مبسط كيف أقوم بذلك
  10. السلام عليكم أود مراجعة كتابة الكود والتصحيح عليه class Frame2(customtkinter.CTkFrame): def __init__(self, master): super().__init__(master) def LoadFile(): filepath = filedialog.askopenfilename(initialdir="C:\\Users\\Cakow\\PycharmProjects\\Main", title="Open file okay?", filetypes=(("text files", "*.xlsx"), ("all files", "*.*"))) filepathA = Path(filepath) df = pd.ExcelFile(filepathA) return df self.optionmenu1.configure(values = sht()) def sht(): A1=self.Frame2.LoadFile B1 =A1.sheet_names return B1 self.button1 = customtkinter.CTkButton(self, text="إختيار ملف", font=customtkinter.CTkFont(family="Calibri", size=12, weight="bold"), command=LoadFile) self.button1.grid(row=0, column=1, padx=(10, 10), pady=(10, 10), sticky="e") self.optionmenu1 = customtkinter.CTkOptionMenu(self,values=["إختر ورقة العمل"], font=customtkinter.CTkFont(family="Calibri", size=12, weight="bold")) self.optionmenu1.grid(row=0, column=0, padx=(10, 10), pady=(10, 10), sticky="e")
  11. في الحقيقة الأمر صعب ولم أفهم طريقة شرح الكود أخي هل من شرح على الكود الخاص بي لتضح لي الفكرة أكثر وجزاك الله خيراَ
  12. السلام عليكم إخوتي لدي هذا الكلاس class Frame2(customtkinter.CTkFrame): def __init__(self, master, border_color, border_width): super().__init__(master) self.configure(border_width=border_width,border_color=border_color) self.df = None def LoadFile(): filepath = filedialog.askopenfilename(initialdir="C:\\Users\\Cakow\\PycharmProjects\\Main", title="Open file okay?", filetypes=(("text files", "*.xlsx"), ("all files", "*.*"))) filepathA = Path(filepath) self.df = pd.ExcelFile(filepathA) def optionmenu_callback(choice): #print("optionmenu dropdown clicked:", choice) self.label2.configure(text=choice) self.optionmenu1.configure(values = self.sht(),command=optionmenu_callback) self.button1 = customtkinter.CTkButton(self, text="إختيار ملف", font=customtkinter.CTkFont(family="Calibri", size=12, weight="bold"), command=LoadFile) self.button1.grid(row=0, column=1, padx=(10, 10), pady=(10, 10), sticky="nw") self.optionmenu1 = customtkinter.CTkOptionMenu(self,values=["إختر ورقة العمل"], font=customtkinter.CTkFont(family="Calibri", size=12, weight="bold")) self.optionmenu1.grid(row=0, column=0, padx=(10, 10), pady=(10, 10), sticky="nw") self.label2 = customtkinter.CTkLabel(self, text="", text_color="#0087f2", font=customtkinter.CTkFont(family="Calibri", size=14, weight="bold")) self.label2.grid(row=1, column=0, padx=(10, 10), pady=(10, 10), sticky="nw") self.label3 = customtkinter.CTkLabel(self, text="إسم ورقة العمل المختارة :", fg_color="transparent", font=customtkinter.CTkFont(family="Calibri", size=14, weight="bold")) self.label3.grid(row=1, column=1, padx=(10, 10), pady=(10, 10), sticky="nw") def sht(self): AD = self.df.sheet_names return AD ولدي هذا الكلاس class Frame4(customtkinter.CTkFrame): def __init__(self, master, border_color, border_width): super().__init__(master) self.configure(border_width=border_width,border_color=border_color) def cooll(): selected_column_1 = self.df.iloc[8::2, [0,1,2,3,4,5,6]] selected_column_1.reset_index(drop=True, inplace=True) A = pd.DataFrame(selected_column_1) print(A) self.checkbox_1 = customtkinter.CTkCheckBox(self, text="checkbox 1") self.checkbox_1.grid(row=0, column=0, padx=(10, 10), pady=(10, 10), sticky="news") self.button3 = customtkinter.CTkButton(self, text="طباعة العمود", font=customtkinter.CTkFont(family="Calibri", size=12, weight="bold"),command=cooll) self.button3.grid(row=1, column=0, padx=(10, 10), pady=(10, 10), sticky="nw") السؤال كيف أصل إلى الكلاس الأول من داخل الكلاس الثاني مثلا أريد أن أصل إلى self.df الموجودة في الكلاس الأول داخل الكلاس الثاني
  13. السلام عليكم أخي قمت بتجربة ذلك ولاكن يبقى الزر في يسار الشاشة وأنا أريده في يمين الشاشة كما تعلم أخي أن شبكة الشاشة مقسمة إلى أعمدة وصفوف فا العمود 0 والصف 0 مكانهم في الجانب العلوي الأيسر من الشاشة كيف أقلبهم ناحية اليمين
  14. السلام عليكم أداة CTkFrame أخذت الصف 0 والعمود 0 بداخلها أداة label أخذت الصف 0 والعمود 0 طبعا استخدمت grid في ترتيب الأدوات سؤالي الأن كيف أجعل أداة label في محاذات الشاشة من اليمين ولا تظهر على اليسار وهل من طريقة لقلب النافذة الرئيسة
  15. هذا الخطأ ظهر عند إضافة هذا الكود self.button1.pack(side="right") هل من طريقة لقلب واجهة البرنامج ليصبح عربي
  16. لدي هذا الخطأ tkinter.TclError: cannot use geometry manager grid inside .!frame1 which already has slaves managed by pack
  17. أخي من الممكن أن سؤالي كان غير مفهوم لديك أقصد لماذا لم أمرر من خلال class App بحيث كتب مثلا border_color = " red لدي سؤال أخر كيف أستطيع أن أجعل واجهة التطبيق تقرأ العمود 0 من ناحية اليمين وليس الشمال المقصود أخي تعريب الواجهة
  18. أحسنت أخي بارك الله فيك إذا يجب إستخدام configure لذلك سؤال لماذا لايتم التمرير مباشرة داخل كلاس class App وهل يمكن ذلك self.Frame_A = Frame1(self) self.Frame_A.grid(row=0, column=0, padx=1, pady=(1, 0), sticky="nswe")
  19. السلام عليكم كيفه نطبق خصائص CTkFrame مثل border_width أو border_color على كود مكتوب بهذه الكيفية حاولت ولاكن لم تنجح الرجاء التوضيح لو سمحتم import customtkinter class Frame1(customtkinter.CTkFrame): def __init__(self, master,border_color,border_width,fg_color): super().__init__(master) self.button1 = customtkinter.CTkButton(self, text="إختيار ملف", font=customtkinter.CTkFont(family="Calibri", size=12, weight="bold")) self.button1.grid(row=0, column=1, padx=3, pady=(3, 0), sticky="w") class Frame2(customtkinter.CTkFrame): def __init__(self, master): super().__init__(master) self.checkbox_1 = customtkinter.CTkCheckBox(self, text="checkbox 1") self.checkbox_1.grid(row=0, column=0, padx=3, pady=(3, 0), sticky="w") class Frame3(customtkinter.CTkFrame): def __init__(self, master): super().__init__(master) self.button2 = customtkinter.CTkButton(self, text="خروج", state="disabled", font=customtkinter.CTkFont(family="Calibri", size=12, weight="bold")) self.button2.grid(row=0, column=0, padx=3, pady=(3, 0), sticky="w") class App(customtkinter.CTk): def __init__(self): super().__init__() self.title("my app") self.geometry("400x180") self.grid_columnconfigure(0, weight=1) self.grid_rowconfigure(0, weight=1) self.Frame_A = Frame1(self,"red",10,"red") self.Frame_A.grid(row=0, column=0, padx=1, pady=(1, 0), sticky="nswe") self.Frame_B = Frame2(self) self.Frame_B.grid(row=0, column=1, padx=1, pady=(1, 0), sticky="nswe") self.Frame_C = Frame3(self) self.Frame_C.grid(row=1, column=0, padx=1, pady=(1, 10), sticky="nswe") app = App() app.mainloop()
  20. السلام عليكم معذرة أحتاج تصحيح في هذا الكود حيث أنه لدي أداة القائمة من المفترض عند اختيار الملف تمتلئ هذه القائمة الرجاء الاطلاع وتشغيل الكود وتصحيح الخطأ الذي به import customtkinter from tkinter import filedialog from pathlib import Path import pandas as pd class Frame1(customtkinter.CTkFrame): def __init__(self, master): super().__init__(master) self.AS = None def LoadFile(): filepath = filedialog.askopenfilename(initialdir="C:\\Users\\Cakow\\PycharmProjects\\Main", title="Open file okay?", filetypes=(("text files", "*.xlsx"), ("all files", "*.*"))) filepathA = Path(filepath) self.AS = pd.ExcelFile(filepathA) AD = self.sht() self.optionmenu1.values = AD self.button1 = customtkinter.CTkButton(self, text="إختيار ملف", font=customtkinter.CTkFont(family="Calibri", size=12, weight="bold"), command=LoadFile) self.button1.grid(row=0, column=1, padx=3, pady=(3, 0), sticky="we") self.optionmenu1 = customtkinter.CTkOptionMenu(self) self.optionmenu1.grid(row=0, column=0, padx=3, pady=(3, 0), sticky="we") def sht(self): if self.AS: AD = self.AS.sheet_names return AD else: return [] class Frame2(customtkinter.CTkFrame): def __init__(self, master): super().__init__(master) self.checkbox_1 = customtkinter.CTkCheckBox(self, text="checkbox 1") self.checkbox_1.grid(row=0, column=0, padx=3, pady=(3, 0), sticky="w") class Frame3(customtkinter.CTkFrame): def __init__(self, master): super().__init__(master) def button_event(): print("خروج") self.button2 = customtkinter.CTkButton(self, text="خروج", state="disabled", font=customtkinter.CTkFont(family="Calibri", size=12, weight="bold"), command=button_event) self.button2.grid(row=0, column=0, padx=3, pady=(3, 0), sticky="w") class App(customtkinter.CTk): def __init__(self): super().__init__() self.title("my app") self.geometry("400x180") self.grid_columnconfigure(0, weight=1) self.grid_rowconfigure(0, weight=1) customtkinter.set_appearance_mode("dark") customtkinter.set_default_color_theme("dark-blue") self.Frame_A = Frame1(self) self.Frame_A.grid(row=0, column=0, padx=1, pady=(1, 0), sticky="nswe") self.Frame_B = Frame2(self) self.Frame_B.grid(row=0, column=1, padx=1, pady=(1, 0), sticky="nswe") self.Frame_C = Frame3(self) self.Frame_C.grid(row=1, column=0, padx=1, pady=(1, 10), sticky="nswe") app = App() app.mainloop()
  21. صحيح أخي لقد قمت بإزالة الخطأ لاكن السؤال الأن لماذا هذا الكود لم ينفذ self.optionmenu1.values = AD حيث تبقى القائمة فارغة
  22. السلام عليكم الرجاء التتبع وتصحيح هذا الخطأ AttributeError: 'Frame1' object has no attribute 'sht' import customtkinter from tkinter import filedialog from pathlib import Path import pandas as pd class Frame1(customtkinter.CTkFrame): def __init__(self, master): super().__init__(master) self.AS = None def LoadFile(): filepath = filedialog.askopenfilename(initialdir="C:\\Users\\Cakow\\PycharmProjects\\Main", title="Open file okay?", filetypes=(("text files", "*.xlsx"), ("all files", "*.*"))) filepathA = Path(filepath) self.AS = pd.ExcelFile(filepathA) AD = self.sht() self.optionmenu1.values = AD def sht(): if self.AS: AD = self.AS.sheet_names return AD else: return [] self.button1 = customtkinter.CTkButton(self, text="إختيار ملف", font=customtkinter.CTkFont(family="Calibri", size=12, weight="bold"), command=LoadFile) self.button1.grid(row=0, column=1, padx=3, pady=(3, 0), sticky="we") self.optionmenu1 = customtkinter.CTkOptionMenu(self) self.optionmenu1.grid(row=0, column=0, padx=3, pady=(3, 0), sticky="we") class Frame2(customtkinter.CTkFrame): def __init__(self, master): super().__init__(master) self.checkbox_1 = customtkinter.CTkCheckBox(self, text="checkbox 1") self.checkbox_1.grid(row=0, column=0, padx=3, pady=(3, 0), sticky="w") class Frame3(customtkinter.CTkFrame): def __init__(self, master): super().__init__(master) def button_event(): print("خروج") self.button2 = customtkinter.CTkButton(self, text="خروج", state="disabled", font=customtkinter.CTkFont(family="Calibri", size=12, weight="bold"), command=button_event) self.button2.grid(row=0, column=0, padx=3, pady=(3, 0), sticky="w") class App(customtkinter.CTk): def __init__(self): super().__init__() self.title("my app") self.geometry("400x180") self.grid_columnconfigure(0, weight=1) self.grid_rowconfigure(0, weight=1) customtkinter.set_appearance_mode("dark") customtkinter.set_default_color_theme("dark-blue") self.Frame_A = Frame1(self) self.Frame_A.grid(row=0, column=0, padx=1, pady=(1, 0), sticky="nswe") self.Frame_B = Frame2(self) self.Frame_B.grid(row=0, column=1, padx=1, pady=(1, 0), sticky="nswe") self.Frame_C = Frame3(self) self.Frame_C.grid(row=1, column=0, padx=1, pady=(1, 10), sticky="nswe") app = App() app.mainloop()
  23. أخي قمت بتجرب الكود الذي قمت حضرتك بتعديله ولاكن لم يعمل لم تدرج الأسماء بالقائمة فأين الخطأ الرجاء أخي التحقق من الكود حيث أن الخطأ يظهر هكذا AttributeError: 'Frame1' object has no attribute 'sht'
×
×
  • أضف...