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.
Two Very Needed Questions!
-
1: Putting a sheet UI view on top of a fullscreen UI view on iPad.
• For some reason, I can't figure out a way to load to different UI's at the same time. I am trying to execute the sheet .py file, from the fullscreen .py file. It executes the sheet .py file, but it has an error trying to load the second .pyui file on top of the firstly loaded fullscreen .pyui file.
• If this is confusing, I will post code, but right now I am on time constraints.2: Getting to manipulate attributes to a UI view like textview, without using superview[(view to manipulate here)]. That way I don't have to have a button or a switch run a function in order to manipulate another view's attributes under the same parent view.
def btntapped(sender): sender.superview["textview1"].text
If you could post straight up coded answers, and a little bit of explanation of what it is doing, that would be helpful. Thank you for the help!
-
OK, I answered question one myself. It was a simple work around. But I still need an answer to two. The!
-
A common way to handle question 2 is to store "shortcuts" in the top level class to whatever ui elements you want to easily access.
import ui,console class MyView(ui.View): def __init__(self,*args,**kwargs): ui.View.__init__(self,*args,**kwargs) self.tv = ui.TextField(frame=(20,20,200,50)) self.b = ui.Button(frame=(100,100,100,100),bg_color='red',title='push') self.b.action=self.btn_action self.add_subview(self.b) self.add_subview(self.tv) def btn_action(self,sender): console.hud_alert(self.tv.text) v=MyView() v.present()
-
@JonB How do I access ui elements created in the editor, not through the script? That's what I'm attempting to do. Thanks for your help Jon. You're the only one who actually answers and helps me out.
-
The same basic approach applies, just after you load the view, make convenience variables that point to subviews you plan on referencing a lot. For instance, see polymerchm's chordcalc: after loading, he creates globals for easy referencing.
https://github.com/polymerchm/chordcalc/blob/master/chordCalc/chordcalc.py#L1766