Why is my run() missing a "self" argument in kivymd?

When I run the following code, I get an error message that says run() has a missing argument "self". Can anyone teach me what the problem is?


Main Code:

from kivymd.app import MDApp
from kivymd.uix.screen import Screen
from kivy.lang import Builder
from AppAssetlib import username_helper
from kivymd.uix.button import MDRectangleFlatButton


def rgba(r,g,b,a):
    new_col = (r/255.0,g/255.0,b/255.0,a)
    return new_col

class demoApp(MDApp):

    def build(self):
        first_screen = Screen()
        self.theme_cls.primary_palette = "Green"
        #username = MDTextField(text = 'Enter Username',
        #pos_hint = {'center_x' : 0.5, 'center_y' : 0.5},
        #size_hint_x = None, width = 300)
        #first_screen.add_widget(username)
        self.btn = MDRectangleFlatButton(text='Show', pos_hint =
        {'center_x' : 0.5, 'center_y' : 0.3},
        on_release = self.show_data)
        self.username = Builder.load_string(username_helper)
        first_screen.add_widget(self.username)
        first_screen.add_widget(self.btn)
        return first_screen



    def show_data(self, obj):
        print(self.username.text)




demoApp.run()

The code for AppAssetlib.py:

username_helper = """
MDTextField:
    text: "Enter a Username"
    icon_right:"android"
    icon_right_color: app.theme_cls.primary_color
    hint_text: 'Enter Username'
    helper_text: 'Ceate a username'
    helper_text_mode: "on_focus"
    pos_hint : {'center_x' : 0.5, 'center_y' : 0.5}
    size_hint_x : None
    width : 300
"""

0 ответов

Другие вопросы по тегам