Q:

I'm trying to code a kivy gui that prints certain words, but it is NOT WORKING and I have no idea why

python code
this is the code

I am trying to get the code to print words that are only in the words.txt 
but the script keeps crashing saying that I didn't define "words"
Can anyone tell me what the problem is?

import kivy
from kivy.app import App
from kivy.uix.label import Label
from kivy.uix.gridlayout import GridLayout
from kivy.uix.floatlayout import FloatLayout
from kivy.uix.textinput import TextInput
from kivy.uix.button import Button
from kivy.uix.widget import Widget
from kivy.properties import ObjectProperty
from kivy.core.window import Window
Window.clearcolor = (1, 1, 1, 1)

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

    def btn(self):

        self.name.text = txt

    def find_words(self):

        self.words.text = word
        list_words=open("word.txt").read().split()
        for x in word:
            for y in list_words:
                if x==y:
                    print(x)

Kivy code
this is the kivy code. I made two more classes, roundbutton and mytextinput, which are just design changes

<RoundButton@Button>:
    background_color: 0,0,0,0
    canvas.before:
        Color:
            rgba: (.7,.7,.7,0.7) if self.state=='normal' else (0.5,1,1,1)
        RoundedRectangle:
            pos: self.pos
            size: self.size
            radius: [10,]

<MyTextInput@TextInput>:
    background_normal: "textinput.png"
    background_color: (0.82,0.96,0.92,1) if self.focus else (1,1,1,0.5)

<MyGrid>:

    txt:txt
    words:words

    FloatLayout:

        size: root.width, root.height

        MyTextInput:
            id: txt
            pos_hint: {"x":0.05, "top":0.8}
            size_hint: 0.63,0.75
        MyTextInput:
            id: words
            on_text: root.find_words()
            pos_hint: {"x": 0.7, "top":0.8}
            size_hint: 0.25,0.75
            text:"hello"

        RoundButton:
            text:"Submit"
            on_press: root.btn()
            pos_hint: {"x":0.05, "top":0.95}
            size_hint: 0.2,0.1

A:

self.words.text = word
list_words=open("word.txt").read().split()
for x in word:
    for y in list_words:
        if x==y:
            print(x)

In the code above, where is word? You didnt declare it. Thats why you have that error.
That might should be: word = self.words.text instead of self.words.text = word?

