-
-
Save Cheaterman/812203a74f8c552a4918 to your computer and use it in GitHub Desktop.
*.pyc |
<Connected>: | |
BoxLayout: | |
orientation: 'vertical' | |
Label: | |
text: "You are now connected" | |
font_size: 32 | |
Button: | |
text: "Disconnect" | |
font_size: 24 | |
on_press: root.disconnect() |
from kivy.app import App | |
from kivy.uix.screenmanager import Screen, SlideTransition | |
class Connected(Screen): | |
def disconnect(self): | |
self.manager.transition = SlideTransition(direction="right") | |
self.manager.current = 'login' | |
self.manager.get_screen('login').resetForm() |
#:include connected.kv | |
<Login>: | |
BoxLayout | |
id: login_layout | |
orientation: 'vertical' | |
padding: [10,50,10,50] | |
spacing: 50 | |
Label: | |
text: 'Welcome' | |
font_size: 32 | |
BoxLayout: | |
orientation: 'vertical' | |
Label: | |
text: 'Login' | |
font_size: 18 | |
halign: 'left' | |
text_size: root.width-20, 20 | |
TextInput: | |
id: login | |
multiline:False | |
font_size: 28 | |
BoxLayout: | |
orientation: 'vertical' | |
Label: | |
text: 'Password' | |
halign: 'left' | |
font_size: 18 | |
text_size: root.width-20, 20 | |
TextInput: | |
id: password | |
multiline:False | |
password:True | |
font_size: 28 | |
Button: | |
text: 'Connexion' | |
font_size: 24 | |
on_press: root.do_login(login.text, password.text) |
from kivy.app import App | |
from kivy.properties import StringProperty | |
from kivy.uix.screenmanager import ScreenManager, Screen, SlideTransition | |
import os | |
from connected import Connected | |
class Login(Screen): | |
def do_login(self, loginText, passwordText): | |
app = App.get_running_app() | |
app.username = loginText | |
app.password = passwordText | |
self.manager.transition = SlideTransition(direction="left") | |
self.manager.current = 'connected' | |
app.config.read(app.get_application_config()) | |
app.config.write() | |
def resetForm(self): | |
self.ids['login'].text = "" | |
self.ids['password'].text = "" | |
class LoginApp(App): | |
username = StringProperty(None) | |
password = StringProperty(None) | |
def build(self): | |
manager = ScreenManager() | |
manager.add_widget(Login(name='login')) | |
manager.add_widget(Connected(name='connected')) | |
return manager | |
def get_application_config(self): | |
if(not self.username): | |
return super(LoginApp, self).get_application_config() | |
conf_directory = self.user_data_dir + '/' + self.username | |
if(not os.path.exists(conf_directory)): | |
os.makedirs(conf_directory) | |
return super(LoginApp, self).get_application_config( | |
'%s/config.cfg' % (conf_directory) | |
) | |
if __name__ == '__main__': | |
LoginApp().run() |
please share what will be the output of dis pgm.
gracias funciona muy bien (thanks, work very well!)
Hey, very new in python and kivy. Could you tell me how to add actionbar after user log in? Like if user log in it will directed to connected.py, is it possible for actionbar to be inside connected.py? If so, how? Thank you.
Thanks a lot fairly new to kivy and python and the logic to this has been a killer to get. By going through your code i get why?
Thanks
Hi,
I also had the same error as nixem420.
But I arranged by removing the “:” of the line “#i: nclude connected.kv” of the login.kv file
hi,
how to run this code i couldnt understand
Can you explain how the screen management work and transition?
I am getting a complete black screen after running this.
Even I am getting a black screen. Can you let us know how to resolve it?
On windows use python -m conda -c conda-forge kivy wheel pygame cython
Great ... Thanks a lot
Great, super contribution, a question many as I do to take the data of the variable for example, idUser, to the connected file and put print it in that file.
Priyanshthehacker you didnt create that connected.py file wich imports this
awsome dude thnks a lot
how to run it ...m stuk....i have installed kivy ,wheel,pygame,cython but unable to run it...getting error lyk dis:
