Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nenhum #13

Open
Danielbanana21 opened this issue Apr 1, 2024 · 0 comments
Open

Nenhum #13

Danielbanana21 opened this issue Apr 1, 2024 · 0 comments

Comments

@Danielbanana21
Copy link

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

KV = '''
BoxLayout:
orientation: 'vertical'

MDLabel:
    text: 'Quer namorar comigo?'
    halign: 'center'
    font_style: 'H4'
    size_hint_y: None
    height: self.texture_size[1]

MDRaisedButton:
    text: 'Sim'
    size_hint: None, None
    width: 150
    pos_hint: {'center_x': 0.5}
    on_release: app.dialog.open()

'''

class MyApp(MDApp):
def build(self):
self.dialog = MDDialog(
title="Pedido de Namoro",
text="Você aceita namorar comigo?",
buttons=[
MDFlatButton(
text="Sim", on_release=self.accept
),
MDFlatButton(
text="Não", on_release=self.dismiss
),
],
)
return Builder.load_string(KV)

def accept(self, *args):
    self.dialog.dismiss()
    self.root.clear_widgets()
    self.root.add_widget(
        Builder.load_string(
            '''
            MDLabel:
                text: 'Parabéns, agora somos namorados!'
                halign: 'center'
                font_style: 'H4'
                size_hint_y: None
                height: self.texture_size[1]
            '''
        )
    )

def dismiss(self, *args):
    self.dialog.dismiss()
    self.root.clear_widgets()
    self.root.add_widget(
        Builder.load_string(
            '''
            MDLabel:
                text: 'Tudo bem, talvez da próxima vez.'
                halign: 'center'
                font_style: 'H4'
                size_hint_y: None
                height: self.texture_size[1]
            '''
        )
    )

if name == 'main':
MyApp().run()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant