-
wenchoheelio
super().init(*args, **kwargs)
I don't fully understand the super() part here. Not sure I really need to understand or use it early on? Also, I understand arguments/parameters - but what's *args, **kwargs ?Does that mean something? Arguments and KW arguments?!
(frame=f)
What is this code for? It doesn't look like the function requires a parameter? (obviously it does.. I just don't understand it)
Thanks.
-
wenchoheelio
@Phuket2 Thanks a million for this! Since your last response, this is something I'm really looking into. I guess it's the next step for me. I actually have a tab on my computer open with the pythonista documentation for 'action and delegates' right now. You couldn't have timed a better response.
I guess another advantage to this, aside from it being customisable, teaching me about classes, actions, delegates, etc - it'll allow me to send code to other people and have it run without a pyui file.A couple more questions if you don't mind:
- I've seen a lot of people refer to 'superview' - what is a superview? Is that just a variable that people use often for the main view?
- Is a delegate the same as a sub class or a custom class?
-
-
wenchoheelio
@Phuket2 Thanks, I really appreciate the time you've taken to write this.
-
wenchoheelio
Hi, I've got the code below to change a tableview's data to what's in the ui's textfield when the button is pushed. Can anyone explain to me please why it's not working?
I will type something into the text field and then press the button and the data in the tableview doesn't change as it is.
import ui import console def button_pushed(sender): textfield1 = v['textfield1'].text textfield2 = v['textfield2'].text textfield3 = v['textfield1'].text data = [textfield1, textfield2, textfield3] datasource = ui.ListDataSource(data) v['tableview1'].data_source=datasource v=ui.load_view() v.present('fullscreen')
Thanks in advance.
-
wenchoheelio
Thanks so much for your help here. It seems that it's a problem with the variable - textfield1
Doing what you said - textfield1 prints nothing to the console and v['textfield1'].text prints whatever was typed into the textfield
Do you happen to know anyway in which I can use a variable to print to the console using the button?
I think I understand the issue from how you've explained it - the variable textfield1 starts of as "" and so even when it changes it's always going to remain as "", in order for me to put it into a variable - I'd have to put it into a variable within the function, when it's already set as whatever the user has set it as.
I think I may have answered my own question there?
-
wenchoheelio
I'm trying to check if a textfield in my ui has any numbers in it when I press on a button. When I use the same code on a string it works. When I use the code for textfield within a button's action it doesn't work. Please help? Here's what my code is like:
import ui import console def contains_digits(d): for char in d: if char.isdigit(): return True return False test='test3' print(contains_digits(test)) #this works - it prints TRUE! #below always prints failed even though it should print whatever is in the textfield?! def button_pushed(sender): if contains_digits(textfield1): print(textfield1) print('failed') v=ui.load_view() textfield1 = str(v['textfield1'].text) v.present('fullscreen')