In this tutorial, we will be creating a login screen using KivyMD, which is an extension of the Kivy framework that provides Material Design components for creating beautiful and intuitive user interfaces. The login screen will have two input fields for the username and password, as well as buttons for logging in and creating a new account.
To get started, make sure you have Kivy and KivyMD installed. You can install them using pip:
pip install kivy
pip install kivymd
Now, create a new Python file and import the necessary modules:
from kivymd.app import MDApp
from kivymd.uix.screen import MDScreen
from kivymd.uix.textfield import MDTextField
from kivymd.uix.button import MDFlatButton
from kivymd.uix.label import MDLabel
Next, create a class for the login screen:
class LoginScreen(MDScreen):
def __init__(self, **kwargs):
super().__init__(**kwargs)
self.username = MDTextField(hint_text='Username', pos_hint={'center_x': 0.5, 'center_y': 0.6})
self.add_widget(self.username)
self.password = MDTextField(hint_text='Password', password=True, pos_hint={'center_x': 0.5, 'center_y': 0.5})
self.add_widget(self.password)
self.login_button = MDFlatButton(text='Login', pos_hint={'center_x': 0.5, 'center_y': 0.4}, on_release=self.login)
self.add_widget(self.login_button)
self.new_account_button = MDFlatButton(text='Create New Account', pos_hint={'center_x': 0.5, 'center_y': 0.3}, on_release=self.create_account)
self.add_widget(self.new_account_button)
def login(self, *args):
username = self.username.text
password = self.password.text
# Add code to verify login credentials here
def create_account(self, *args):
# Add code to create a new account here
Now, create a class for the main app:
class LoginApp(MDApp):
def build(self):
self.theme_cls.primary_palette = 'Blue'
return LoginScreen()
Finally, run the app:
if __name__ == '__main__':
LoginApp().run()
This will create a basic login screen with two input fields for the username and password, as well as buttons for logging in and creating a new account. You can customize the appearance and functionality of the login screen by adding more components and implementing the necessary logic for verifying login credentials and creating new accounts.
hi. Where i can get the code? in the video you talk about a pin comment but i dont see it anymore? Thanks!
Some Annoying girl: Hey who's your favorite youtuber?
Me: John Elder
Annoying Girl: Who's that?
Me: "You are accused of treason and anti-soviet behavior. The court finds you guilty and sentences you to be shot"
Seem like MDTextFieldRound is removed from KivyMD
Alternative:
MDTextField:
mode: "round"
id: user
hint_text: "Username"
How to toggle password visibility,
for some reason the line – self.root.ids.welcome_label.text = f'Sup {self.root.ids.user.text}!' – doesn't work, and it says raise BuilderException(rule.ctx, rule.line. do any of you have any idea why? thanks!
Hi John! Getting an error about ids and that it defaults to an empty dict? Any help, please? 🙂
Thank you sir
you know that you are saving me, aren't ya ?
got an error when writing MDTextFieldRound saying this raise FactoryException('Unknown class <%s>' % name)
kivy.factory.FactoryException: Unknown class <MDTextFieldRound> please help me how to fix this
I copied all your code but it has error " kivy.factory.FactoryException: Unknown class <MDCard>". How can i fix it?
hey men, i really like your videos, but i have a quiestion: What if i want to call a function () in de kivy file……but not with a button just call the function from la LABEL or a Widget , that function is in my PY File. Best regards
Hello Sir, I write exactly the same code which you have written, but in my .kv file while using "MDTextFieldRound", giving this error – kivy.factory.FactoryException: Unknown class <MDTextFieldRound>. I am new to kivy programming so not able to figure it out. if I use "MDTextFieldRect" it works fine. Is this the Python version Issue ? Or I have not included any class ?
Please HELP. Thanks
It showing me an error
Is says kivy.factory. factoryExpection: unknown class
Hi, I just want to know if you have a video where you are on the login page in python kivy and if you click sign up then the sign up page will appear on the screen made in python kivy. Please help cant find any resource to do that or any other video. Other videos are telling me how to gather data from text boxs when user clicks the submit button but what I need is if I click signup on the login page it should take me to an exsisting sign up page I have created using python kivy. Thanks
very nice, thanks , like so much …
how to lock potrait screen for android in kivy?
Thank you so much!!!!!!!!
How you add multiple teminal
Bro kivy md is additional module
Bro please how we make login page in pycharm