Python Curses windows are not shown properly every time I run the program -


i have wierd problem ncurses in python 3.4 trying make windows layout application , code looks this:

import curses import time class presentator():     def __init__(self, device_db, address_db):         self.curses_windows = {}     def update_all_windows(self):         wins in self.curses_windows.values():             wins.noutrefresh()         curses.doupdate()      def update_all_windows(self):         wins in self.curses_windows.values():             wins.noutrefresh()         curses.doupdate()      def create_windows(self):         max_height = curses.lines - 5         max_width = curses.cols - 5         self.curses_windows["border"] = curses.newwin(max_height, max_width, 0, 0)         self.curses_windows["border"].border()         self.curses_windows["title"] = curses.newwin(3, max_width, 0, 0)         self.curses_windows["title"].border()         title_msg = "ip monitoring"         self.curses_windows["title"].addstr(1, max_width // 2 - len(title_msg), title_msg)       def print_results(self, stdscr):         self.create_windows()         while true:             self.update_all_windows()             time.sleep(5)       def start_ui(self):         curses.wrapper(self.print_results)  if __name__ == "__main__":     p = presentator()     p.start_ui() 

two out of 5 times run program, 2 windows borders shown, title message ip-monitoring inside. correct however, rest 3 cases border of self.curses_windows["border"] window shown , nothing else. doing wrong refreshing? why result unpredictable?

thanks help.

when use non-numeric array index, that's associative array (also referred in python dictionary), , iteration

for wins in self.curses_windows.values(): 

does not have predefined order. 1 window last refreshed, another. if write border last, wipes out "contents".


Comments

Popular posts from this blog

account - Script error login visual studio DefaultLogin_PCore.js -

xcode - CocoaPod Storyboard error: -