settings.py 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. from helper import console
  2. from helper.settings import Settings
  3. def settings():
  4. while True:
  5. setting = console.option_picker('Choose which setting to change',
  6. Settings.__list__,
  7. quit=True,
  8. objects=[
  9. '__id__',
  10. 'x.name',
  11. 'x.str_value'
  12. ],
  13. table=[
  14. ('ID', 2),
  15. ('Setting', 20),
  16. ('Value', 100)
  17. ])
  18. if setting is None:
  19. console.output('Saving settings...')
  20. Settings.write()
  21. console.output('Settings saved')
  22. break
  23. else:
  24. entry = Settings.__list__[setting]
  25. value = console.ask_input('Enter new value', entry.type, quit=True)
  26. if value is None:
  27. console.output('Value not changed', console.DBG_INFO)
  28. continue
  29. else:
  30. console.output('Changing value of {x.name} from {x.value} to {new}'.format(x=entry, new=value), console.DBG_INFO)
  31. entry.set(value)
  32. return True