Hello I am try to make a type of dropdown selection for my text input using a popup window but it doesn't work .
Python code:
class SecondWindow(Screen):
def __init__(self,**kwargs):
super(SecondWindow, self).__init__()
txt_inpt = ObjectProperty()
add =ObjectProperty()
finish = ObjectProperty()
numar_bucati = ObjectProperty()
tip_schela = ObjectProperty()
metri_schela = ObjectProperty()
tip_motor = ObjectProperty()
numar_motoare = ObjectProperty()
def re_enter(self):
with open("popupid/light_selected","r") as popi:
popir= popi.read()
if popir != "" :
self.ids.txt_inpt.text = popir
else:
pass
def lights_drop(self,instance):
if instance in self.ids.values():
popup_id=list(self.ids.keys())[list(self.ids.values()).index(instance)]
with open("popupid/popup_id.txt","w") as poptxt:
poptxt.write(popup_id)
poptxt.close()
LightsPop().open()
def selected_item(self,instance):
if instance.text in aparate.keys():
with open("popupid/light_selected", "w") as lighsel:
lighsel.write(instance.text)
self.re_enter()
else:
pass
def on_open(self):
with open('popupid/popup_id.txt','r') as popread:
mdx = popread.read()
if mdx == "droplightbutton" :
for x in fixture_list.split("\n"):
b= Button(text=x,font_size=14,size_hint=(1,0.8))
b.bind(on_press=SecondWindow().selected_item)
self.ids.drop2.add_widget(b)
Kivy:
TextInput:
id: txt_inpt
text: ""
font_size:14
multiline:False
size_hint:(0.7,1)
hint_text:"type your fixture here"
Button:
id:droplightbutton
y: self.parent.y
x: self.parent.x
text: ""
markup: True
size_hint:(0.2,1)
background_normal: ''
background_color: (0,0,0,0)
on_press: root.lights_drop(self)
Image:
source: 'images/drop_down2.png'
y: self.parent.y
x: self.parent.x
size_hint:(None,None)
size: (40,40)