Traceback (most recent call last):
File "/home/lmx/PycharmProjects/login/main.py", line 79, in <module>
Login().run()
File "/home/lmx/PycharmProjects/login/lib/python3.8/site-packages/kivy/app.py", line 950, in run
runTouchApp()
File "/home/lmx/PycharmProjects/login/lib/python3.8/site-packages/kivy/base.py", line 582, in runTouchApp
EventLoop.mainloop()
File "/home/lmx/PycharmProjects/login/lib/python3.8/site-packages/kivy/base.py", line 347, in mainloop
self.idle()
File "/home/lmx/PycharmProjects/login/lib/python3.8/site-packages/kivy/base.py", line 391, in idle
self.dispatch_input()
File "/home/lmx/PycharmProjects/login/lib/python3.8/site-packages/kivy/base.py", line 342, in dispatch_input
post_dispatch_input(*pop(0))
File "/home/lmx/PycharmProjects/login/lib/python3.8/site-packages/kivy/base.py", line 248, in post_dispatch_input
listener.dispatch('on_motion', etype, me)
File "kivy/_event.pyx", line 709, in kivy._event.EventDispatcher.dispatch
File "/home/lmx/PycharmProjects/login/lib/python3.8/site-packages/kivy/core/window/__init__.py", line 1412, in on_motion
self.dispatch('on_touch_down', me)
File "kivy/_event.pyx", line 709, in kivy._event.EventDispatcher.dispatch
File "/home/lmx/PycharmProjects/login/lib/python3.8/site-packages/kivy/core/window/__init__.py", line 1428, in on_touch_down
if w.dispatch('on_touch_down', touch):
File "kivy/_event.pyx", line 709, in kivy._event.EventDispatcher.dispatch
File "/home/lmx/PycharmProjects/login/lib/python3.8/site-packages/kivy/uix/screenmanager.py", line 1198, in on_touch_down
return super(ScreenManager, self).on_touch_down(touch)
File "/home/lmx/PycharmProjects/login/lib/python3.8/site-packages/kivy/uix/widget.py", line 545, in on_touch_down
if child.dispatch('on_touch_down', touch):
File "kivy/_event.pyx", line 709, in kivy._event.EventDispatcher.dispatch
File "/home/lmx/PycharmProjects/login/lib/python3.8/site-packages/kivy/uix/relativelayout.py", line 297, in on_touch_down
ret = super(RelativeLayout, self).on_touch_down(touch)
File "/home/lmx/PycharmProjects/login/lib/python3.8/site-packages/kivy/uix/widget.py", line 545, in on_touch_down
if child.dispatch('on_touch_down', touch):
File "kivy/_event.pyx", line 709, in kivy._event.EventDispatcher.dispatch
File "/home/lmx/PycharmProjects/login/lib/python3.8/site-packages/kivymd/uix/behaviors/ripple_behavior.py", line 255, in on_touch_down
super().on_touch_down(touch)
File "/home/lmx/PycharmProjects/login/lib/python3.8/site-packages/kivy/uix/behaviors/button.py", line 138, in on_touch_down
if super(ButtonBehavior, self).on_touch_down(touch):
File "/home/lmx/PycharmProjects/login/lib/python3.8/site-packages/kivy/uix/widget.py", line 545, in on_touch_down
if child.dispatch('on_touch_down', touch):
File "kivy/_event.pyx", line 709, in kivy._event.EventDispatcher.dispatch
File "/home/lmx/PycharmProjects/login/lib/python3.8/site-packages/kivy/uix/behaviors/button.py", line 151, in on_touch_down
self.dispatch('on_press')
File "kivy/_event.pyx", line 705, in kivy._event.EventDispatcher.dispatch
File "kivy/_event.pyx", line 1248, in kivy._event.EventObservers.dispatch
File "kivy/_event.pyx", line 1132, in kivy._event.EventObservers._dispatch
File "/home/lmx/PycharmProjects/login/lib/python3.8/site-packages/kivy/lang/builder.py", line 57, in custom_callback
exec(__kvlang__.co_value, idmap)
File "/home/lmx/PycharmProjects/login/login.kv", line 128, in <module>
on_press: app.on_save()
File "/home/lmx/PycharmProjects/login/main.py", line 54, in on_save
if self.root.ids.nome.text != "":
File "kivy/properties.pyx", line 864, in kivy.properties.ObservableDict.__getattr__
AttributeError: 'super' object has no attribute '__getattr__'
Process finished with exit code 1
----------The error------------------------------------
-----------The py file----------------------------------
import json
import requests
from kivy.lang import Builder
from
kivymd.app import MDApp
from kivy.uix.screenmanager import ScreenManager, Screen
from kivy.core.window import Window
Window.size = (800, 600)
class PrimeiraJanela(Screen):
pass
class SegundaJanela(Screen):
pass
class WindowManager(ScreenManager):
pass
class Login(MDApp):
firebase_url = '
https://logintest-a0b05-default-rtdb.firebaseio.com/'
def build(self):
self.theme_cls.theme_style = "Dark"
# self.theme_cls.primary_palette = "Orange"
kv = Builder.load_file('login.kv')
return kv
def search_key(self, **kwargs):
# recover record
# -MejGIx9r-oF0RskYMle
if self.root.ids.ausweis.text != "":
firebase_path = self.firebase_url + self.root.ids.ausweis.text + ".json"
res = requests.get(url=firebase_path)
self.load_fields(**res.json())
self.root.ids.status_label.text = "Localizado!"
else:
self.root.ids.status_label.text = "Insira o Id"
return
def load_fields(self, idade, nome):
self.root.ids.idade.text = idade
self.root.ids.nome.text = nome
# change button salvar to "atualizar"
self.root.ids.bt_save.text = "Atualizar"
return
def on_save(self):
if self.root.ids.nome.text != "":
# preparing data
json_data = '{"nome" :"' + self.root.ids.nome.text + '" , "idade" :"' + self.root.ids.idade.text + '"}'
# checking if create = post or update = put
if self.root.ids.ausweis.text == "":
# creating data
firebase_path = self.firebase_url + '.json'
res =
requests.post(url=firebase_path, json=json.loads(json_data))
else:
# updating data
firebase_path = self.firebase_url + '/' + self.root.ids.ausweis.text + '.json'
res = requests.put(url=firebase_path, json=json.loads(json_data))
# cleaning fields
self.root.ids.idade.text = ""
self.root.ids.nome.text = ""
self.root.ids.ausweis.text = ""
# messaging
self.root.ids.bt_save.text = "Salvar"
self.root.ids.status_label.text = "Salvo!"
else:
# alert message
self.root.ids.status_label.text = "O campo NOME é obrigatório!"
return
Login().run()
-----------The py file-------------------------------
-----------The kv file-------------------------------
WindowManager:
PrimeiraJanela:
SegundaJanela:
<PrimeiraJanela>:
name: "Welcome"
MDFloatLayout:
md_bg_color: 1, 1, 1, 0
line_color: rgba(228, 0, 35, 255)
Image:
source: "thelyon.png"
size_hint: .8, .8
pos_hint: {"center_x": .5, "center_y": .65}
Button:
text: "Entrar"
size_hint: .8, .075
pos_hint: {"center_x": .5, "center_y": .29}
background_color: 1, 1, 1, 0
canvas.before:
Color:
rgb: rgba(228, 0, 35, 255)
RoundedRectangle:
size: self.size
pos: self.pos
radius: [23]
on_press:
app.root.current ="Login"
root.manager.transition.direction = "left"
Button:
text: "Sair"
size_hint: .8, .075
pos_hint: {"center_x": .5, "center_y": .195}
background_color: 1, 1, 1, 0
color: rgba(228, 0, 35, 255)
canvas.before:
Color:
rgb: rgba(228, 0, 35, 255)
Line:
width: 1
rounded_rectangle: self.x, self.y, self.width, self.height, 23, 23, 23, 23, 100
<SegundaJanela>:
name: "Login"
MDCard:
size_hint: None, None
size: 800,600
pos_hint: {"center_x": 0.5, "center_y": 0.5}
elevation: 10
padding: 25
spacing: 25
orientation: 'vertical'
MDLabel:
id: status_label
text: "Aguardando ..."
font_size: 10
halign: 'center'
size_hint_y: None
height: self.texture_size[1]
padding_y: 15
MDTextField:
id: ausweis
mode: "rectangle"
hint_text: "Id"
size_hint_x: None
width: 300
font_size: 12
pos_hint: {"center_x": 0.5}
MDTextField:
id: nome
mode: "rectangle"
hint_text: "Nome"
size_hint_x: None
width: 300
font_size: 12
required: True
helper_text: "Campo obrigatório!"
pos_hint: {"center_x": 0.5}
MDTextField:
id: idade
mode: "rectangle"
hint_text: "Idade"
size_hint_x: None
width: 300
font_size: 12
pos_hint: {"center_x": 0.5}
Button:
id: bt_search
text: "Localizar"
font_size: 12
size_hint: .8, .075
pos_hint: {"center_x": 0.5}
background_color: 1, 1, 1, 0
color: rgba(228, 0, 35, 255)
canvas.before:
Color:
rgb: rgba(228, 0, 35, 255)
Line:
width: 1
rounded_rectangle: self.x, self.y, self.width, self.height, 23, 23, 23, 23, 100
on_press: app.search_key()
Button:
id: bt_save
text: "Salvar"
font_size: 12
size_hint: .8, .075
pos_hint: {"center_x": 0.5}
background_color: 1, 1, 1, 0
color: rgba(228, 0, 35, 255)
canvas.before:
Color:
rgb: rgba(228, 0, 35, 255)
Line:
width: 1
rounded_rectangle: self.x, self.y, self.width, self.height, 23, 23, 23, 23, 100
on_press: app.on_save()
Button:
text: "Sair"
size_hint: .8, .075
pos_hint: {"center_x": .5, "center_y": .195}
background_color: 1, 1, 1, 0
color: rgba(228, 0, 35, 255)
canvas.before:
Color:
rgb: rgba(228, 0, 35, 255)
Line:
width: 1
rounded_rectangle: self.x, self.y, self.width, self.height, 23, 23, 23, 23, 100
on_press:
app.root.current ="Welcome"
root.manager.transition.direction = "right"
Widget:
size_hint_y: None
height: 10
-----------The kv file-------------------------------