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

عدم عرض البيانات في المتصفح

عبده عبدالسلام

السؤال

السلام عليكم  

اشكركم على قبول التسجيل في منصتكم 

اريد مساعدتكم في لغة البايتون ,في مرحلة جلب البانات من قاعدة البانات لم تظهر واعطتني اخطاء حاولت حلها لكنها استعصت علي لاني انا متوسط المعرفة بالبرمجة في الملف تجد صورة للمشكل  وشكرا

mistakes1.png

mistakes2.png

رابط هذا التعليق
شارك على الشبكات الإجتماعية

Recommended Posts

  • 0

من خلال الخطأ الذي ظهر لك في الصورة، لاحظت أن الكائن "Student" الذي تم إنشاؤه لا يحتوي على الخاصية "search" التي يتم الإشارة إليها في سطر الخطأ، وبالتالي يجب التحقق من وجود هذه الخاصية في الصفحة التي تحتوي على الصفة __init__ من الكلاس Student.

علاوة على ذلك، قد يكون هناك خطأ إملائي أو نحوي في الأمر الذي يحدد كيفية عرض البيانات في المتصفح، وهو الذي يتضمن الخاصية "search".

وتستطيع تصحيح هذا الخطأ عن طريق تحديد الخاصية الصحيحة في الصفحة التي تحتوي على الصفة __init__ من الكلاس "Student"، أو عن طريق إضافة الخاصية "search" للكائن "Student".

أيضًا تستطيع التحقق من وجود أي أخطاء إملائية أو نحوية في الأمر الذي يحدد كيفية عرض البيانات في المتصفح.

وفي حال لم تتمكن من تحديد سبب الخطأ، يمكنك مشاركة الكود الذي يحتوي على صفحة __init__ من الكلاس "Student" والكود الذي يحدد كيفية عرض البيانات في المتصفح، وذلك لمساعدتك في حل المشكلة بشكل أفضل.

رابط هذا التعليق
شارك على الشبكات الإجتماعية

  • 0

العفو أخي عبده، لكن أرجو منك وضع الكود بشكل نصي من خلال علامة <> عند إضافة السؤال لأتمكن من مساعدتك، وإخباري ما المشكلة التي تواجهك بالضبط وماذا تتوقع من الكود.

رابط هذا التعليق
شارك على الشبكات الإجتماعية

  • 0

شكرا جزيلا  سيدي سليمان 

هاهو النص.اريد تنفيذ البرنامج 

 

from tkinter import*
from tkinter import ttk
from tkinter import messagebox
from typing import Self
from webbrowser import BackgroundBrowser
import pymysql

class Student:
    #-------انشاء نافذة-----------------
    def __init__(self, root):
        self.root =root
        self.root.geometry('1350x690+1+1')
        self.root.title('Gestion Pédagogique')
        self.root.configure(background="silver")
        self.root.resizable(False,False)
        title=Label(self.root ,
          text='Inscription des etudiants',
          background='yellow',
          font=('monospace',16),
          fg='red'          
                    )
        title.pack(fill=X)
        #------------  variable  -------------
        self.id_var=StringVar()
        self.name_var=StringVar()
        self.email_var=StringVar()
        self.numero_var=StringVar()
        self.se_var=StringVar()
        self.dell_var=StringVar()
    #--------------------ادوات التحكم في البرنامج--------------------    
        Manage_Frame=Frame(self.root,bg='white')
        Manage_Frame.place(x=1139,y=30,width=210,height=400)
        label_ID=Label(Manage_Frame,text='serial number',background='white')
        label_ID.pack()
        ID_Entry=Entry(Manage_Frame,textvariable=self.id_var,border='2',justify='center')
        ID_Entry.pack()
        
        label_name=Label(Manage_Frame,background='white',text='Name')
        label_name.pack()
        name_Entry=Entry(Manage_Frame,textvariable=self.name_var,border='2',justify='center')
        name_Entry.pack()
        label_email=Label(Manage_Frame,background='white',text='email')
        label_email.pack()
        email_Entry=Entry(Manage_Frame,textvariable=self.email_var,border='2',justify='center')
        email_Entry.pack()
        label_numero =Label(Manage_Frame,background='white',text='numero d inscription')
        label_numero.pack()
        numero_Entry=Entry(Manage_Frame,textvariable=self.numero_var,border='2',justify='center')
        numero_Entry.pack()
        label_delete=Label(Manage_Frame,fg='red',background='white',text='efface par name')
        label_delete.pack()
        delete_Entry=Entry(Manage_Frame,textvariable=self.dell_var,border='2',justify='center')
        delete_Entry.pack()
        #-----------butons-----------
        butons_Frame=Frame(self.root, background='white')
        butons_Frame.place(x=1139,y =436,width=210,height=253)
        title1=Label(butons_Frame,text='لوحة التحكم',font=('Deco,16'),fg='white',bg='#7D3C98')
        title1.pack(fill=X)

        add_btn=Button(butons_Frame,text='اصافة طالب',bg='green',command=self.add_student)
        add_btn.place(x=33,y=33,width=150,height=30)
        del_butons=Button(butons_Frame,text='حذف طالب',bg='red',command=self.delet)
        del_butons.place(x=33,y=63,width=150,height=30)
        update_butons=Button(butons_Frame,text='تعديل بيانات',bg='orange',command=self.update)
        update_butons.place(x=33,y=93,width=150,height=30)
        clear_butons=Button(butons_Frame,text='افراغ الحقول',bg='blue',command=self.clear)
        clear_butons.place(x=33,y=123,width=150,height=30)
        about_butons=Button(butons_Frame,text='من نحن',bg='white',command=self.about)
        about_butons.place(x=33,y=153,width=150,height=30)
        exit_butons=Button(butons_Frame,text='اغلاق البرنامج',bg='yellow',command=root.quit)
        exit_butons.place(x=33,y=183,width=150,height=30)

        #---------------search manage البحث---------------
        

        

        search_Frame=Frame(self.root,bg='white')
        search_Frame.place(x=1,y=30,width=1135,height=50)

        label_search=Label(search_Frame,text='البحث عن طالب',bg='white')
        label_search.place(x=1034,y=12)


        combo_search= ttk.Combobox(search_Frame,justify='right')
        combo_search['value']=('name','email','id')
        combo_search.place(x=890,y=12)

        search_Entry=Entry(search_Frame,textvariable=self.se_var,justify='right',bd='2')
        search_Entry.place(x=750,y=12)

        search_btn=Button(search_Frame,text='بحث',bg='blue',command=self.search)
        search_btn.place(x=630,y=12,width=100,height=25)

        #-----------dietals عرض البيانات------------
        Dietals_Frame=Frame(self.root)
        Dietals_Frame.place(x=1,y=82,width=1134,height=600)
             #-----scroll-------
        scroll_x=Scrollbar(Dietals_Frame,orient=HORIZONTAL)
        scroll_y=Scrollbar(Dietals_Frame,orient=VERTICAL)
             #---------Treeview------------
        self.student_table=ttk.Treeview(Dietals_Frame,
        columns=('numero','email','name','id') ,
        xscrollcommand=scroll_x.set,
        yscrollcommand=scroll_y.set )
        self.student_table.place(x=18,y=1,width=1130,height=587)
        scroll_x.pack(side=BOTTOM,fill=X)
        scroll_y.pack(side=LEFT,fill=Y)
        scroll_x.config(command=self.student_table.xview)
        scroll_y.config(command=self.student_table.yview)
        self.student_table['show']='headings'
        self.student_table.heading('numero',text='رقم التسجيل')
        self.student_table.heading('email',text='العنوان الالكتروني')
        self.student_table.heading('name',text='اسم الطالب')
        self.student_table.heading('id',text='الرقم التسلسلي')

        self.student_table.column('numero',width=130)
        self.student_table.column('email',width=70)
        self.student_table.column('name',width=80)
        self.student_table.column('id',width=30)
        self.student_table.bind("<ButtonRelease-1>",self.get_cursor)

        #------con + add------------
        self.fetch_all()
    def add_student(self):
            con = pymysql.connect(host='localhost',user='root',password='', database='stud')
            cur = con.cursor()
            cur.execute("insert into student values(%s,%s,%s,%s)",(        
                                                        self.id_var.get(),
                                                        self.name_var.get(),
                                                        self.email_var.get(),
                                                        self.numero_var.get()
                                                        ))
            con.commit()
            self.clear()
            con.close()


    def fetch_all(self):
            con=pymysql.connect(host='localhost',user='root',password='',database='student')
            cur=con.cursor()
            cur.execute('select * from student')
            rows=cur.fetchall()
            if len (rows) !=0:
                self.student_table.delete(*self.student_table.get_children())
                for row in rows:
                    self.student_table.insert("",END,value=row)
                con.commit()
            con.close()
    def delet(self):
         con=pymysql.connect(host='localhost',user='root',password='',database='student')
         cur=con.cursor()
         cur.execute('delete from student where name=%s',self.dell_var.get())
         con.commit()
         self.fetch_all()
         con.close()

    def clear(self):
         self.id_var.set('')
         self.name_var.set('')
         self.email_var.set('')
         self.numero_var.set('')
    def get_cursor(self,ev):
         cursor_row=self.student_table.focus()
         contents =self.student_table.item(cursor_row)
         row=contents['values']
         self.id_var.set(row[0])
         self.name_var.set(row[1])
         self.email_var.set(row[2])
         self.numero_var.set(row[3])

    def update(self):
            con = pymysql.connect(host='localhost',user='root',password='', database='stud')
            cur = con.cursor()
            cur.execute("update student set where id=%s,name=%s,email=%s,numero=%s",(        
                                                        self.id_var.get(),
                                                        self.name_var.get(),
                                                        self.email_var.get(),
                                                        self.numero_var.get()
                                                        ))
            con.commit()
            self.clear()
            con.close()

    def search_all(self):
            con=pymysql.connect(host='localhost',user='root',password='',database='student')
            cur=con.cursor()
            cur.execute('select * from student where ' +
            str(self.se_by.get())+"LIKE '%"+str(self.se_var.get())+"%'")
            
            rows=cur.fetchall()
            if len (rows) !=0:
                self.student_table.delete(*self.student_table.get_children())
                for row in rows:
                    self.student_table.insert("",END,values=row)
                con.commit()
            con.close()
    def about(self):
         messagebox.showinginfo("itcmd developer","welcome to")
         


root=Tk()
ob=Student(root)
root.mainloop()

 

رابط هذا التعليق
شارك على الشبكات الإجتماعية

انضم إلى النقاش

يمكنك أن تنشر الآن وتسجل لاحقًا. إذا كان لديك حساب، فسجل الدخول الآن لتنشر باسم حسابك.

زائر
أجب على هذا السؤال...

×   لقد أضفت محتوى بخط أو تنسيق مختلف.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   جرى استعادة المحتوى السابق..   امسح المحرر

×   You cannot paste images directly. Upload or insert images from URL.

  • إعلانات

  • تابعنا على



×
×
  • أضف...