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 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