поэтому все работает, и значения добавляются в базу данных, но по какой-то причине он просто не работает сразу после выдачи следующей ошибки:
TypeError: 'NoneType' object is not subscriptable
Я думал, что это может быть то, как я отображаю его на экране, поэтому я удалил последний бит, чтобы посмотреть, пройдет ли он без ошибок, но он все равно выдает ту же ошибку, попробовал все, что мог, но мой разум пустой, и мне нужно лечь спать , любая помощь приветствуется, Поздравляем всех и всех с запоздалой Пасхой !!!
Код Python -
def add_student_now(self):
spec_email = self.manager_screen.home.nav_drawer.grid_drawer.drawer_email.text
student_first_name = self.manager_screen.add_student.firstname.text
student_last_name = self.manager_screen.add_student.lastname.text
student_notes = self.manager_screen.add_student.notes.text
con = sql.connect(host = "localhost", user = "root", password = "hipeople11", database = "people")
cur = con.cursor(buffered=True)
query = "SELECT email, first_name, surname FROM teachers"
cur.execute(query)
for (email, first_name, surname) in cur:
if email == spec_email:
full_name = first_name.lower() + surname.lower()
print(full_name)
print(spec_email)
print("{}students".format(full_name))
cur.execute("INSERT INTO {}students (studentfirstname, studentlastname, studentnotes) VALUES (%s,%s,%s)".format(full_name), (student_first_name, student_last_name, student_notes))
con.commit()
con.close()
self.manager_screen.current = "home"
student = student_first_name + " " + student_last_name
#create label
self.manager_screen.home.grid_home.s_home.h_student_list.add_widget(OneLineListItem(text=student)) ```
Kivy code-
MDScreen:
id: home
name: "home"
radius: [25, 0, 0, 0]
grid_home: grid_home
nav_drawer: nav_drawer
MDGridLayout:
id: grid_home
h_toolbar : h_toolbar
s_home: s_home
ab_home: ab_home
del_home: del_home
cols: 1
rows: 2
MDToolbar:
id: h_toolbar
title: "NewArk Grading Systems"
pos_hint: {'top':1.0}
md_bg_color: 0,0,0,1
elevation: 10
left_action_items: [["menu", lambda x: nav_drawer.set_state("open")]]
ScrollView:
id: s_home
name: "s_home"
h_student_list: h_student_list
do_scroll_x: False
MDList:
id: h_student_list
MDScreen:
id: add_student
name: "add_student"
firstname: firstname
lastname: lastname
notes: notes
radius: [25, 0, 0, 0]
MDFloatLayout:
MDLabel:
text:'Enter Details'
pos_hint: {'center_x': 0.965, 'center_y':0.6}
bold: True
MDRectangleFlatButton:
text: 'Add Student'
pos_hint: {'center_x':0.5, 'center_y': 0.2}
line_color: 0,0,0,1
text_color: 0,0,0,1
on_release: root.add_student_now()
MDTextField:
id: firstname
hint_text: 'First Name'
pos_hint: {'center_x':0.5, 'center_y': 0.5}
icon_right: 'smile'
color_mode: 'custom'
helper_text_mode: "on_focus"
line_color_focus: 0, 0, 0, 1
size_hint_x:None
MDTextField:
id: lastname
hint_text: 'Last Name'
pos_hint: {'center_x':0.5, 'center_y': 0.4}
icon_right: 'smile'
color_mode: 'custom'
helper_text_mode: "on_focus"
line_color_focus: 0, 0, 0, 1
size_hint_x:None
MDTextField:
id: notes
hint_text: 'Notes'
pos_hint: {'center_x':0.5, 'center_y': 0.3}
icon_right: 'smile'
color_mode: 'custom'
helper_text_mode: "on_focus"
line_color_focus: 0, 0, 0, 1
size_hint_x:None
multiline : True
для всех, кто это читает, неважно, я решил это, все, что мне нужно было сделать, это выйти из цикла сразу после того, как значения были вставлены и отображены в операторе if