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.
Help with JSON external ui
-
Hi guys
I'm very new to this so please forgive.
Can someone tell me please assist me.
I need to save switch positions and label texts to json. In a UI designed in pythonista ui-builder (not code built)
Also need to update a label text based on a incremental switch created from a segment control. Ie -/+ updates label text.
Label text becoming a value to feed another label. -
I think I responded to one of your previous posts with a settings storage function to allow you to save and restore switch /slider/textfield/ etc settings as yaml.
https://github.com/jsbain/uicomponents/blob/master/ui_settings_storage.py
Did this work for you?You posted here asking for help with swithces linking with textfields. Did the suggestions work? Maybe continue that thread by asking for more clarification. (see my specific reponse ...you have to update textfields from the switch actions if you want them to update as soon as you switch the switch)
-
edit:
# coding: utf-8 import os, json def loadsettings(file): if os.path.exists(file): with open(file, "r") as f: return json.load(f) file = "test.pyui" settings = loadsettings(file) i = 0 for s in settings[0]: #show me dicts in list if s == 'nodes': print s + ' = ', for d in settings[0].values()[i]: print d print else: print s + ' = ' + str(settings[0].values()[i]) print i += 1 print 'get attributes of the first node:' print "settings[0].get('nodes')[0].values()[0] = " + str(settings[0].get('nodes')[0].values()[0])