Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
Always checking text field
-
Is there any way to make a function or something that will be running all the time? I want to always be checking if a text field is empty.
-
Check out the TextField.delegate documentation. This might be what you are looking for.
-
While you coulda use a threading.Thread or a Timer for example to continually do something in the background, there is not need to do so for your example.
textfield_did_change
gets called whenever you type a key for example, or, well, whenever the textfield changes. So, for example you could ls check whether the textfield is empty within that delegate function, and take whatever action you see fit (enabling another button, etc) -
Exactly. See the code at line 34 of https://github.com/humberry/ui-tutorial/blob/master/AreYouEnabledView.py to see how to enable/disable ui.Buttons based on the presence/absence of text in a ui.TextField.
-
I'm looking to have a table update for every letter typed in the textfield.
@ccc How would I implement this? Would it be using
def set_actions(self): # method 2: traversing all subviews for subview in self.subviews: if isinstance(subview, ui.TextField): subview.delegate = self elif isinstance(subview, ui.Button): if subview.name == 'say hi': # method 3: button-specific action methods subview.action = self.say_hi else: subview.action = self.button_pressed
-
@techteej Put some sample code in a GitHub repo and we can edit it together.
-
-
I created a separate NotepadView.py so I did not clobber your original code. it is somewhat workable in its current form.
-
Thanks for doing that. Will try to make some improvements then merge with original code.