#python-kivy

28 messages · Page 1 of 1 (latest)

rustic kettle
#

at this video https://youtu.be/H8aWfu9aICc?list=PLzMcBGfZo4-kSJVMyYeOQ8CXJ3z1k7gHn i made everything like he was telling but when i run it it is saying AttributeError: 'MyApp' object has no attribute 'btn'and i dont know what to do

the codes are this
main.py:
import kivy
from kivy.app import App
from kivy.uix.label import Label
from kivy.uix.gridlayout import GridLayout
from kivy.uix.textinput import TextInput
from kivy.uix.button import Button
from kivy.uix.widget import Widget
from kivy.properties import ObjectProperty

class MyGrid(Widget):
name = ObjectProperty(None)
email = ObjectProperty(None)

def btn(self):
    print("Name:", self.name.text, "email:", self.email.text)
    self.name.text = ""
    self.email.text = ""

class MyApp(App):
def build(self):
return MyGrid()

if name == "main":
MyApp().run()

my.kv:
<MyGrid>:

name: name
email: email

GridLayout:
    cols:1
    size: root.width - 200, root.height -200
    pos: 100, 100

    GridLayout:
        cols:2

        Label:
            text: "Name: "

        TextInput:
            id: name
            multiline:False

        Label:
            text: "Email: "

        TextInput:
            id: email
            multiline:False

    Button:
        text:"Submit"
        on_press: root.btn()
rustic kettle
#

python-kivy

tough hull
#

wait but it should work still

#

can you send full code in proper code formatting?

#

t.tag discord code

echo sequoiaBOT
#

To send code in discord use three of these ` before and after. for example:
```python
code here
```
for long code please use a code sharing service (for a list type "t.tag paste" without the quotes)

rustic kettle
#

it shouldnt work right

#

myapp doesnt have btn

tough hull
#

not MyApp

rustic kettle
#

AttributeError: 'MyApp' object has no attribute 'btn'

tough hull
#

which line

rustic kettle
#

idk

#

he didnt paste all the code

tough hull
#

post full code and exception

rustic kettle
#

its not my fucking question

#

smh

tough hull
#

then why're you asking?

#

tell them to ask

#

don't type in lines

rustic kettle
#

he calls myapp.btn later on in the code

#

im assuming

tough hull
#

yeah makes sense

rustic kettle
#

bruh i got muted 🤡

tough hull
#

should do myapp.root.btn