Help with JSON external ui
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.
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)
# 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: #show me dicts in list if s == 'nodes': print s + ' = ', for d in settings.values()[i]: print d print else: print s + ' = ' + str(settings.values()[i]) print i += 1 print 'get attributes of the first node:' print "settings.get('nodes').values() = " + str(settings.get('nodes').values())