'How to set a cursor at a MDtextfield and move cursor by pressing Tab key

Python 3.9 and KivyMD

I have a popup window class and there are 3 MDtextfields to get input data and 2 buttons to calculate the input data.

  1. I want to set a cursor at one of MDtextfield when program runs and then move the cursor by pressing tab key.

  2. When completing all the MDtextfields, when you press tab key, the cursor moves to the next available button.

at ttk, i used icursor() but in MDtextfields, i can't find any information, equivalent with icursor().

Example of TTK,

self.e_ptName = ttk.Entry(self, font= LARGE_FONT)

self.e_ptName.icursor(0)

But i want to do the same thing in KivyMD.

I have a py file and a kv file.

I appreciate your help in advance.

Thanks.

for example, main.py ''' class Dexmedetomidine(Popup):

ptName = ObjectProperty(None)
ptAdminWeight = ObjectProperty(None)
ptIdealWeight = ObjectProperty(None)


def on_open(self):
    selsf.ptName.icursor(0)    # this does not work
    self.ptAdminWeight.icursor(1)  # this does not work

'''

kv file ''' MDTextField: id: ptName hint_text: "Patient Name" line_color_focus: 0,0,0,1 font_size: '30sp'

MDTextField: id:ptAdminWeight input_filter: "float" hint_text: "Admission Weight" required: True font_size: '30sp' line_color_focus: 0.9,0.75,0,1 '''



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source