I've created a NavView template and put it on GitHub for anyone to use as a starting point for creating a NavView based app using Pythonista. https://github.com/ncarding/NavViewTemplate
I've done this because it took me ages to workout how to do it myself and I wanted to give something back to the community that unknowingly helped me workout all the problems along the way.
There is however a fairly large bug with the template that needs fixing before it is truly useful. I've tried various things and I just can't workout why the bug is there and how to fix it.
As it stands the NavView has two levels: Groups and People. You can create as many Groups as you like and have as many People in each group as you like.
The UI is built with Pythonista's ui module. The logic uses a custom object orientated module called simple_module. The objects that are created are saved and loaded (for persistence) using the pickle module.
The People lists should be independent of the Group lists, but at the moment they are not.
If you add a new Group then add one or more People to that group and then add a second Group, the People from the first Group are automatically added to the second and any additional Groups.
I can't tell where the bug is but it only effects Groups created with each launch of the app. E.g. If you create three Groups they will all contain the same People. If you then quit the app and relaunch it those people will still be in each Group but if you create more Groups they will not contain the original list of People. These new Groups will however all share any new People added to any of the Groups created in this session.
Any suggestions as to why this is happening and how I might fix it are welcome.
All the code is at https://github.com/ncarding/NavViewTemplate
abcabc last edited by
The " init" method in simple_module.py is not correct. You can not have "empty list" as default parameter.
See the discussion here.
Mostly this should fix your bug. I have not tested it.
class Group(): def __init__(self, name, people = ): self.name = name # people is a list of People objects self.people = people
ccc last edited by
The "fix" code contains an empty list as a default parameter. :-(. I would suggest:
class Group(): def __init__(self, name, people=None): self.name = name # people is a list of People objects self.people = people or  # converts None into an empty list
abcabc last edited by
It is not the fix. It is the part of the code that has the problem. I should have worded that properly. Anyway thanks for the correction.
ccc last edited by ccc
I made a pull request on the repo so there is no ambiguity... I think you are correct that it should solve the open issue.
Thank you for your help. This has indeed fixed the problem.
The code is there for anyone that wants to make use of it.
Phuket2 last edited by Phuket2
@niz , thanks for sharing. I have just tried it as I have doing nothing with the nav view before, well at least that I can remember.
But 2 things that stand out.
Seems like it would be easy to make it Python 2.7 and 3 compatible with a try on the pickle import, and maybe a protocol change that either version of pickle loaded could read an existing file.
Support for different presentations, i.e. Sheet, panel.
Just an idea
Thanks @Phuket2 for the suggestions. I will look into them.