'trying to set the same task but with different data each one in kivy
how i can run the same task with different data? i tried everything but is always the same. for example i put "yes" in one textinput and "no" in another and start printing it in one thread, but if i try to erase the data of the input for start a new one with other data it will also erase it from the thread that is already running, for example again "yes" and "no" if i delete "yes" the thread will also delete it and continue printing only "no". how can i resolve this? Code is down below
.kv file
<Request>:
name: 'request'
MDTextField:
id: emailrequest
hint_text: "E-mail"
pos_hint: {"center_x": 0.5, "center_y": 0.70}
size_hint_x: None
width: 300
on_text_validate: root.calling()
MDTextField:
id: seguridad
hint_text: "At what age did you give your first kiss?"
pos_hint: {"center_x": 0.5, "center_y": 0.60}
size_hint_x: None
width: 300
on_text_validate: root.calling()
MDLabel:
text: "Password request"
pos_hint: {"center_x": 0.7, "center_y": 0.80}
size_hint_x: None
width: 500
MDRaisedButton:
text: "Request"
pos_hint: {"center_x": 0.5, "center_y": 0.45}
on_press: root.imprimir()
MDRectangleFlatButton:
text: "Go back"
pos_hint: {"center_x": 0.3, "center_y": 0.85}
on_press: root.manager.current = 'login'
.py file
class Request(Screen):
def __init__(self, **kw):
super().__init__(**kw)
def calling(self):
_thread.start_new_thread(self.imp2, ("thread", 4))
def imp2(self, *args):
Clock.schedule_interval(self.pal, 1/1)
def pal(self, *args):
palabra = self.ids.emailrequest.text
palabra2 = self.ids.seguridad.text
print(palabra, palabra2)
pass
sm = ScreenManager()
sm.add_widget(Request(name='request'))
class work(MDApp):
def build(self):
self.theme_cls.primary_palette = "Yellow"
screen = Builder.load_string(screen_helper)
return screen
work().run()
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
