Ok guys i have a problem i want to click a button on the popup and then after i clicked the popup it must transistion to another screen....here is my code
just want to get a new fresh screen after i clicked the popup button
from kivy.uix.popup import Popup
from kivy.app import App
from kivy.uix.gridlayout import GridLayout
from kivy.uix.label import Label
from kivy.uix.textinput import TextInput
from kivy.uix.button import Button
# from kivy.uix.boxlayout import BoxLayout
# from kivy.uix.stacklayout import StackLayout
from kivy.uix.screenmanager import ScreenManager, Screen
class LoginScreen(GridLayout, Screen):
def __init__(self, sm, **kwargs):
super(LoginScreen, self).__init__(**kwargs)
self.sm = sm
self.cols = 2
self.row = 2
self.add_widget(Label(text='User Name', font_size='20sp'))
self.username = TextInput(multiline=False)
self.add_widget(self.username)
self.add_widget(Label(text='password'))
self.password = TextInput(password=True, multiline=False)
self.add_widget(self.password)
self.hello = Button(text="hello", on_press=lambda a: self.save(), size=(100, 100),
size_hint=(0.3, 0.3))
self.add_widget(self.hello)
def save(self):
print("s")
id_name = self.username._get_text()
id_num = self.password._get_text()
if id_name == "Hendricko" and id_num == "stokkies123":
content = Button(text="Press Here", size=(100, 100), size_hint=(0.3, 0.3))
popup = Popup(title="You May Proceed ",
content=content,
size=(50, 50),
size_hint=(0.3, 0.3),
auto_dismiss=False)
content.bind(on_press=lambda b: self.check_menu_press)
popup.open()
def check_menu_press(self, button, *args):
if button.state == 'normal':
self.sm.current = "SecondScreen"
class SecondScreen(GridLayout,Screen):
def __init__(self, sm, **kwargs):
super(SecondScreen, self).__init__(**kwargs)
self.row = 2
self.cols = 2
self.add_widget(Label(text="hello", font_size="20sp"))
self.sm = sm
def on_touch_down(self, touch):
self.sm.current = "LoginScreen"
class MyApp(App):
def build(self):
sm = ScreenManager()
sm.add_widget(LoginScreen(sm, name="SecondScreen"))
sm.add_widget(SecondScreen(sm, name="LoginScreen"))
return sm
if __name__ == '__main__':
MyApp().run()