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.
code not reading a scrollview
-
Hello All
I have a calculation thing that I did with the UI designer. It has four textfields and one button. It worked great, but one thing I did not like. When the keypad is up (the one cvp did, which is awesome) it blocked part of the form. I redid it with a scrollview to try to get it to scroll. I put the lables and the textfields and the button on the scrollview. Now it looks good and scrolls but now my code doesn’t connect to the UI interface. It does not read the button action or the text fields. I think I need to add a sub_view to the scrollview. I do not know for sure.
Any help would be very much appreciated
-
@DaveClark did you try with the standard keypad, just to be sure that "my" keypad does not destroy something?
-
the standard keyboard does come up and works. I am using the stock one for now.. Your keyboard has worked great on my other stuff that does not use a scrollview. I could put my code, but its the pyui file that I think needs work. or acutally, I need to code the scollview in the UI designed GUI, maybe. I dont know how to post the pyui file along with the py file
-
@DaveClark sorry, but it is difficult to help without the code and the pyui file
-
@DaveClark you can use this to copy the pyui to the clipboard and then you paste it here
import clipboard with open("your file.pyui") as f: clipboard.set(f.read())
-
Thanks for your help. Here is the code
import ui from SetTextFieldPad import SetTextFieldPad def getInput(view): textfield = v[view] input = textfield.text return input def calculate(motion, height, spacing, speed): result = repr(round(motion * (height/(spacing*12/3/speed) / .0568))) + ' inches per second' return result def button_tapped(sender): motion = float(getInput('textfield1')) height = float(getInput('textfield2')) spacing = float(getInput('textfield3')) speed = float(getInput('textfield4')) v['label6'].text = calculate(motion, height, spacing, speed) #SetTextFieldPad(v['textfield1']) #SetTextFieldPad(v['textfield2']) #SetTextFieldPad(v['textfield3']) #SetTextFieldPad(v['textfield4']) v = ui.load_view('whoops5test') #button1.action = button_tapped button1 = v['button1'] v.present('sheet')``` Next I’ll send the Pruitt file
-
Here is the Pyui file
Whoops5test.pyui
[ { "nodes" : [ { "nodes" : [ { "nodes" : [ ], "frame" : "{{0, 0}, {540, 133}}", "class" : "Label", "attributes" : { "name" : "label1", "flex" : "WH", "frame" : "{{195, 254}, {150, 32}}", "uuid" : "F7EB115D-61EC-419E-BB26-7CEDC7ADEBC8", "class" : "Label", "alignment" : "center", "text" : "Shock Shaft Speed", "number_of_lines" : 0, "font_size" : 26, "font_name" : "<System>" }, "selected" : false }, { "nodes" : [ ], "frame" : "{{0, 459}, {540, 92}}", "class" : "Label", "attributes" : { "name" : "label6", "flex" : "WH", "frame" : "{{195, 254}, {150, 32}}", "uuid" : "536B313D-8792-4912-A7F0-9ED17CEF3818", "class" : "Label", "alignment" : "center", "text" : "answer", "font_size" : 24, "font_name" : "<System>" }, "selected" : false }, { "nodes" : [ ], "frame" : "{{0, 141}, {274, 60}}", "class" : "Label", "attributes" : { "name" : "label2", "flex" : "WH", "frame" : "{{195, 334}, {150, 32}}", "uuid" : "ABB867F3-B6CB-41BF-B344-621A60512C75", "class" : "Label", "alignment" : "left", "text" : "Motion Ratio?", "font_size" : 22, "font_name" : "<System>" }, "selected" : false }, { "nodes" : [ ], "frame" : "{{366, 141}, {174, 60}}", "class" : "TextField", "attributes" : { "uuid" : "2AFA90FE-B716-4A95-82A4-3F522A466FC2", "font_size" : 17, "frame" : "{{170, 334}, {200, 32}}", "action" : "", "alignment" : "center", "autocorrection_type" : "default", "text" : "1", "font_name" : "<System>", "spellchecking_type" : "default", "class" : "TextField", "name" : "textfield1", "flex" : "WH" }, "selected" : false }, { "nodes" : [ ], "frame" : "{{0, 209}, {274, 60}}", "class" : "Label", "attributes" : { "name" : "label3", "frame" : "{{195, 334}, {150, 32}}", "uuid" : "2EE9FFC0-FCF1-4996-8449-2A8C8DA8934C", "class" : "Label", "alignment" : "left", "text" : "Whoop Height in inches?", "font_size" : 22, "font_name" : "<System>" }, "selected" : false }, { "nodes" : [ ], "frame" : "{{0, 278}, {274, 60}}", "class" : "Label", "attributes" : { "name" : "label4", "frame" : "{{195, 334}, {150, 32}}", "uuid" : "DFF299B2-0881-46DC-AEF9-7EB993E46A2B", "class" : "Label", "alignment" : "left", "text" : "Whoop Spacing in inches?", "font_size" : 22, "font_name" : "<System>" }, "selected" : false }, { "nodes" : [ ], "frame" : "{{0, 346}, {274, 60}}", "class" : "Label", "attributes" : { "name" : "label5", "frame" : "{{195, 334}, {150, 32}}", "uuid" : "599966B1-4F08-45EE-ABD8-B8D9A75AA37E", "class" : "Label", "alignment" : "left", "text" : "Vehicle Speed in mph?", "font_size" : 22, "font_name" : "<System>" }, "selected" : false }, { "nodes" : [ ], "frame" : "{{366, 208}, {174, 62}}", "class" : "TextField", "attributes" : { "flex" : "WH", "font_name" : "<System>", "frame" : "{{170, 334}, {200, 32}}", "spellchecking_type" : "default", "class" : "TextField", "uuid" : "2AFA90FE-B716-4A95-82A4-3F522A466FC2", "alignment" : "center", "text" : "15", "autocorrection_type" : "default", "name" : "textfield2", "font_size" : 17 }, "selected" : false }, { "nodes" : [ ], "frame" : "{{366, 278}, {174, 60}}", "class" : "TextField", "attributes" : { "flex" : "WH", "font_name" : "<System>", "frame" : "{{170, 334}, {200, 32}}", "spellchecking_type" : "default", "class" : "TextField", "uuid" : "2AFA90FE-B716-4A95-82A4-3F522A466FC2", "alignment" : "center", "text" : "15", "autocorrection_type" : "default", "name" : "textfield3", "font_size" : 17 }, "selected" : false }, { "nodes" : [ ], "frame" : "{{366, 346}, {174, 60}}", "class" : "TextField", "attributes" : { "flex" : "WH", "font_size" : 17, "frame" : "{{170, 334}, {200, 32}}", "spellchecking_type" : "default", "class" : "TextField", "uuid" : "2AFA90FE-B716-4A95-82A4-3F522A466FC2", "alignment" : "center", "text" : "40", "autocorrection_type" : "default", "name" : "textfield4", "font_name" : "<System>" }, "selected" : false }, { "nodes" : [ ], "frame" : "{{195, 586}, {168, 55}}", "class" : "Button", "attributes" : { "flex" : "WH", "action" : "", "frame" : "{{230, 334}, {80, 32}}", "title" : "Calculate", "uuid" : "EA291EB5-371B-4AAE-A3D4-31BE3D10ACC5", "class" : "Button", "name" : "button1", "font_size" : 22 }, "selected" : true } ], "frame" : "{{0, 0}, {540, 500}}", "class" : "ScrollView", "attributes" : { "flex" : "HRTB", "frame" : "{{110, 110}, {320, 320}}", "uuid" : "E616DE17-915E-41B3-BA80-AB2043AC2DDB", "content_height" : 720, "class" : "ScrollView", "content_width" : 540, "name" : "scrollview1" }, "selected" : true } ], "frame" : "{{0, 0}, {540, 540}}", "class" : "View", "attributes" : { "enabled" : true, "background_color" : "RGBA(1.000000,1.000000,1.000000,1.000000)", "tint_color" : "RGBA(0.000000,0.478000,1.000000,1.000000)", "border_color" : "RGBA(0.000000,0.000000,0.000000,1.000000)", "flex" : "" }, "selected" : false } ]
-
if your labels, etc are all subviews of your scrollview, you need to referent the scrollview.
the simplest change, might be to change v to point to your scrollview. obviously, you still have to present the root, so you would do:
root=ui.load_view(...) v=root['scrollview1'] root.present()
alternatively,
v['scrollview1']['label1']
would be the other way to reference, using your original code. -
@DaveClark as explained by @JonB
v = ui.load_view('whoops5test') SetTextFieldPad(v['scrollview1']['textfield1'])
Reference to v in SetTextFieldPad needs to move line v = … before