from distutils.command.build import build
from tkinter import INSERT
from kivy.lang import Builder
from kivy.uix.screenmanager import ScreenManager, Screen
from kivymd.app import MDApp
from kivy.core.window import Window
from kivymd.uix.textfield import TextInput
from kivymd.uix.button import MDFillRoundFlatButton
import sqlite3
from kivy.clock import Clock
from kivymd.uix.list import OneLineListItem
con = sqlite3.connect('my.db')
c = con.cursor()
c.execute("""CREATE TABLE IF NOT EXISTS post(
title TEXT NOT NULL,
main_text TEXT NOT NULL)""")
con.commit()
con.close()
sm = ScreenManager()
sm.add_widget(AddPost(name="add"))
sm.add_widget(ReadPost(name="read"))
sm.add_widget(MenuScreen(name="menu"))
return sm
def on_start(self):
con = sqlite3.connect("my.db")
c = con.cursor()
data = """SELECT * FROM post"""
c.execute(data)
data = c.fetchall()
for i in data:
self.ids.container.add_widget(
OneLineListItem(text=f"{i}")
)
con.close()
print("das")
def submit(self, title, main_text):
if title == '' or main_text == '':
print('eror')
else:
con = sqlite3.connect("my.db")
c = con.cursor()
c.execute("""INSERT INTO post(
title, main_text)
VALUES (?,?);""",
(title, main_text))
con.commit()
con.close()
print("Э")
def listText(self):
con = sqlite3.connect("my.db")
c = con.cursor()
data = """SELECT * FROM post"""
c.execute(data)
data = c.fetchall()
for i in data:
self.root.ids.container.add_widget(
OneLineListItem(text=f"{i}")
)
con.close()
MainApp().run()
Ошибка
Traceback (most recent call last):
File "kivy/properties.pyx", line 961, in kivy.properties.ObservableDict.__getattr__
KeyError: 'container'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/diarsavkatov/Documents/projects/read/main.py", line 215, in
MainApp().run()
File "/Users/diarsavkatov/Documents/projects/read/env/lib/python3.10/site-packages/kivy/app.py", line 954, in run
self._run_prepare()
File "/Users/diarsavkatov/Documents/projects/read/env/lib/python3.10/site-packages/kivy/app.py", line 949, in _run_prepare
self.dispatch('on_start')
File "kivy/_event.pyx", line 731, in kivy._event.EventDispatcher.dispatch
File "/Users/diarsavkatov/Documents/projects/read/main.py", line 178, in on_start
self.root.ids.container.add_widget(
File "kivy/properties.pyx", line 964, in kivy.properties.ObservableDict.__getattr__
AttributeError: 'super' object has no attribute '__getattr__'