I am creating a program for my Electronic health records (EHR) where the user, after logging in can create multiple doctors under the same account.
I want to create a screen 'SignIn_MD' where the there is one button for every doctor under the user's list.
assume that kivyfxns work correctly.
I wish to show in the sample dictionary that there would be 2 buttons ('a' and 'b')
I think kivy is not showing the updated DoctorsList layout. I tried hardcoding a list and it works.. but if I dynamically update with a function, it does not show the buttons
`users= {'doctors': ['name':'a', 'name':'b']}`
GUI.py
`class UserSignIn(Screen):
username_input = StringProperty('username')
password_input = StringProperty('password')
user_error = StringProperty('')
pass_error = StringProperty('')
doctor_list = None
def update_user(self, txt_input):
self.username_input = txt_input.text
print(self.username_input)
def update_pw(self, txt_input):
self.password_input = txt_input.text
print(self.password_input)
def submit(self):
print('submitted')
print(self.username_input)
print(self.password_input)
check = kivy_fxns.kivy_signin(self.username_input,self.password_input)
if check == True:
self.doctor_list = DoctorList()
self.doctor_list.create_doctor_buttons()
App.get_running_app().root.current ='SignIn_MD'
else:
self.user_error = 'invalid username and password'
class DoctorList(GridLayout):
def __init__(self, \*args, \*\*kwargs):
super().__init__(\*\*kwargs)
self.cols = 1
def create_doctor_buttons(self):
doctors = kivy_fxns.get_doctors()
for doctor in doctors:
btn = Button(text= doctor.get('lastname'), on_release= lambda instance, doctor : self.on_button_click(instance,doctor))
self.add_widget(btn)`
GUI.kv
`<SignIn_MD>:
name: 'SignIn_MD'
BoxLayout:
orientation: 'vertical'
Label:
text: 'Sign In'
Label:
text: 'the following are the list of doctors of user'
BoxLayout:
orientation: 'vertical'
Label:
size_hint: 0.25,1
DoctorList: #does not show any button
Button: # this button is a sample that works fine
text: 'sample'
Label:
size_hint: 0.25,1
Label:`
self.doctor_list = DoctorList()
and thekv
line:DoctorList:
are both creating instances ofDoctorList
. But those instances are not related,and the one created in the python code is not part of your GUI.