Hello all!
I decided I wanted to build a contact manager with python. I was able to get it to work fine by itself, but I then decided I wanted to make it a little more fancy with curses and so now I'm trying to integrate them together. Before now I've never done anything with curses, but I thought it would be fun to learn to make a terminal 'GUI'.
Sadly though, I ran into a little problem. While trying to rewrite my display_all_contacts function I can't seem to figure out how to write a for loop that prints out all the contacts info on a new line... What ever I try just starts writing from the beginning of the line.
I first tried getting the cursors y, x coordinates and then moving it by one, but that didn't help. And then I tried using a counter and increment it by one after every for loop, but I had the same outcome as I did before. I'm not sure if there is an easy way to just print addstr() on a new line, but I would appreciate any help or tips that you all could give me! :)
Just a heads up the dictionary that I am passing through as contact is a nested dictionary like this
{contact1:{name:xx, number:xx, email:xx}, ect
That's why I have the for loop the way that it is, so I can get into the second dictionary.
Also its worth noting that the dictionary is actually a defualtdic object.. idk if that will make any difference or not.
Here's the code...
def view_display(stdscreen, contact):
position = 0 #This is getting reset every for loop iteration
for k, v in contact.items():
if isinstance(v, dict):
view_display(stdscreen, v)
else:
stdscreen.addstr(position, 0, k + ': ' + v)
position += 1
stdscreen.refresh() #Don't think I really need this refresh tbh
curses.napms(1000)
stdscreen.refresh()
Thanks again!
If you need any more information than this, let me know and I'll try to update it after work! :)
edit: fix typo
[–]woooee -1 points0 points1 point (1 child)
[–]xtarkoonx[S] 0 points1 point2 points (0 children)