Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I am trying to save/print my input data in pycharm by means of dialog box. So if I press the "okay" button in my dialog box, it will submit my data on my database. Here's my code and some preview of what I'm developing.

The dialogbox:

The dialogbox

The textfield and confirm button:

The textfield and confirm button

.kv file:

<InputScreen>
id:information
BoxLayout:
    orientation: 'vertical'
    MDToolbar:
        title:'Input Details'
        elevation:10
        left_action_items:[["backspace",lambda x:app.back_screen("menu")]]

    Widget:
    MDTextField:
        id:fname
        hint_text: "Full name"
        pos_hint: {'center_x': 0.5}
        size_hint_x: None
        width: '250dp'
        helper_text:"Please enter your Registered Name"
        helper_text_mode:"on_focus"
    Widget:
        height: 35
    MDTextField:
        id:height
        hint_text: "Height"
        pos_hint: {'center_x': 0.5}
        size_hint_x: None
        width: '250dp'
        helper_text:"Must be in centimeters"
        helper_text_mode:"on_focus"
    Widget:
        height:35
    MDTextField:
        id:weight
        hint_text: "Weight"
        pos_hint: {'center_x': 0.5}
        size_hint_x: None
        width: '250dp'
        helper_text:"Must be in Kilogram"
        helper_text_mode:"on_focus"
    Widget:
        height:35
    MDTextField:
        id:age
        hint_text: "Age"
        pos_hint: {'center_x': 0.5}
        size_hint_x: None
        width: '250dp'
        helper_text:"please enter your age"
        helper_text_mode:"on_focus"
    Widget:
        size_hint_y: None
    MDScreen:
        MDRectangleFlatButton:
            mode: "rectangle"
            text: 'Confirm'
            pos_hint: {'center_x':0.5, 'center_y':0.8}
            on_press :
                app.show_alert_dialog()
    Widget:
        size_hint_x: None

python file

    def show_alert_dialog(self):
    close_button = MDFlatButton(text="Okay",
                                on_press=self.heartrate)
    more_button = MDFlatButton(text="Cancel", on_press=self.close_dialog)

    self.dialog = MDDialog(title="Confirmation", text="Confirm Details?",
                           size_hint=(0.7, 1),
                           buttons=[close_button, more_button])
    self.dialog.open()

    def heartrate(self, obj):
    self.root.ids.scr_mngr.current = 'heartrate'
    self.dialog.dismiss()
question from:https://stackoverflow.com/questions/66066433/input-print-data-in-database-kivymd

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
303 views
Welcome To Ask or Share your Answers For Others

1 Answer

Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...