Search code examples
pythonkivykivy-languagekivymd

ImportError: cannot import name 'MDFlatButton' from 'kivymd.uix.button'


This is the code I was working in:

from kivy.lang import Builder
from kivymd.app import MDApp
from kivymd.uix.dialog import MDDialog
from kivymd.uix.button import MDFlatButton
from kivy.core.window import Window

Window.size = (300, 450)

KV = '''
Screen:
    # More styling here
        MDFillFlatButton:
            text : "LOG IN"
            font_size: 15
            pos_hint: {"center_x" : 0.5}
            on_press: app.login() 
'''

ImportError: cannot import name 'MDFlatButton' from 'kivymd.uix.button' I was looking for something that could solve it; I re installed kivymd and updated Kivy to the lalest version but the mistake stills there :c


Solution

  • MDFlatButton is from kivymd 1.2.0 version.

    If you have installed the lattest version of kivymd, 2.0.1.dev() you have to use this buttons:

    from kivymd.uix.button import MDButton, MDButtonText
    

    You have some examples on the doc:
    https://kivymd.readthedocs.io/en/latest/getting-started/