def __init__ (self, h, l, y, x, headline, status_obj): self.status_obj = status_obj self.log = status_obj.log self.stateless_client = status_obj.stateless_client self.stats = status_obj.stats self.general_stats = status_obj.general_stats self.h = h self.l = l self.y = y self.x = x self.headline = headline self.win = curses.newwin(h, l, y, x) self.win.erase() self.win.box() self.win.addstr(1, 2, headline, curses.A_UNDERLINE) self.win.refresh() panel.new_panel(self.win) self.panel = panel.new_panel(self.win) self.panel.top()
def start(): global READY global thr global scr global win_input global pan_input global win_status global pan_status global win_msg global pan_msg if not READY: scr = curses.initscr() scr.keypad(1) curses.noecho() curses.halfdelay(1) win_msg = curses.newwin(11,53,0,0) win_msg.scrollok(1) pan_msg = panel.new_panel(win_msg) pan_msg.show() win_input = curses.newwin(3,53,12,0) pan_input = panel.new_panel(win_input) pan_input.show() win_status = curses.newwin(3,53,14,0) pan_status = panel.new_panel(win_status) pan_status.show() READY = True thr = threading.Thread(target=reading_thread) thr.start()
def main(): global my_wins0 global my_wins1 win = curses.initscr() curses.cbreak() curses.noecho() (y,x) = win.getmaxyx() lines = (y-1*3)/2 cols = (x-1*3)/2 my_wins0 = curses.newwin(lines,cols,0,0) my_wins1 = curses.newwin(lines,cols,0,cols) my_wins2 = curses.newwin(lines,cols,lines,0) my_wins3 = curses.newwin(lines,cols,lines,cols) # my_wins2 = curses.newwin(lines,cols,y+2,x+50) # my_wins2 = curses.newwin(lines,cols,y+2,x+50) my_wins2.box() my_wins3.box() my_wins1.box() my_wins0.box() my_panels1 = panel.new_panel(my_wins0) my_panels2 = panel.new_panel(my_wins1) my_panels3 = panel.new_panel(my_wins2) my_panels4 = panel.new_panel(my_wins3) #display(my_panels1) global a a=1 while 1: go1() go2() curses.panel.update_panels() curses.doupdate()
def __init__(self, items, stdscreen, IFL): if not IFL: self.pytify = get_pytify_class_by_platform()() self.window = stdscreen.subwin(0, 0) self.window.keypad(1) self.panel = panel.new_panel(self.window) self.panel.hide() panel.update_panels() self.position = 2 self.items = items self.song_length = len(items) - 1 self.items.append(' ') self.items.append('<UP> and <DOWN> for navigation.') self.items.append('<Enter> to select song.') self.items.append('<Esc> for search.') self.items.append('<LEFT> and <RIGHT> for prev/next song.') self.items.append('<SPACEBAR> for play/pause.') else: self.position = 2 self.items = items self.window = stdscreen.subwin(0, 0) self.window.keypad(1) self.panel = panel.new_panel(self.window) self.panel = panel.new_panel(self.window) self.panel.hide() panel.update_panels() self.pytify = get_pytify_class_by_platform()() self.pytify.listen(1) self.pytify.play_pause() self.panel.hide() self.window.clear() curses.endwin(); exit();
def start(self): """Initialize the game """ stdscr = self.stdscr curses.curs_set(0) self.WINHW = (stdscr.getmaxyx()[0] - 1, stdscr.getmaxyx()[1] - 3) self.cur = [0, 0] self.mapscr = [0, 0] self.MAPHW = (99, 99) map = curses.newpad(self.MAPHW[0]+1, self.MAPHW[1]+1) # curses.init_pair(1, curses.COLOR_BLACK, curses.COLOR_WHITE) curses.init_pair(1, curses.COLOR_WHITE, curses.COLOR_CYAN) curses.init_pair(2, curses.COLOR_WHITE, curses.COLOR_YELLOW) curses.init_pair(3, curses.COLOR_WHITE, curses.COLOR_GREEN) # CP_FWHITE_BGRAY = curses.color_pair(1) | curses.A_REVERSE | curses.A_BOLD CP1 = curses.color_pair(1) CP2 = curses.color_pair(2) CP3 = curses.color_pair(3) for y in range(0, self.MAPHW[0]): for x in range(0, self.MAPHW[1]+1): # map.addch(y, x, random.randint(32, 122)) # if ((x + (y%2) + 2) / 2) % 2: # map.addch(y, x, '.', CP_FWHITE_BGRAY) # else: # map.addch(y, x, '.') # grid = ((x + (y%2)*3) / 2) % 3 grid = (x + (y%2)*2) % 4 if grid == 3: map.addch(y, x, ' ') # elif grid == 0: # map.addch(y, x, '.') else: map.addch(y, x, ':') # elif grid == 1: # map.addch(y, x, '.') # elif grid == 2: # map.addch(y, x, '.') self.map = map dia = curses.newwin(3, 20, self.WINHW[0]/2, (self.WINHW[1]-20)/2) dia.border() dia.addstr(1, 4, 'Hello World!') dia2 = curses.newwin(5,5,11,40) dia2.border() self.dia = dia self.dia2 = dia2 self.pdia = cpanel.new_panel(dia) self.p2 = cpanel.new_panel(dia2) cpanel.update_panels() curses.doupdate() self._draw_cur() # stdscr.refresh() self._draw_map() self.run()
def main(): """ Entry point for example 15 """ # Initialize curses screen = curses.initscr() curses.start_color() curses.cbreak() curses.noecho() screen.keypad(True) # Initialize all the colors curses.init_pair(1, curses.COLOR_RED, curses.COLOR_BLACK) curses.init_pair(2, curses.COLOR_GREEN, curses.COLOR_BLACK) curses.init_pair(3, curses.COLOR_BLUE, curses.COLOR_BLACK) curses.init_pair(4, curses.COLOR_CYAN, curses.COLOR_BLACK) my_wins = init_wins(3) # Attach a panel to each window. Order is bottom up my_panels = ( panel.new_panel(my_wins[0]), # Push 0, order: stdscr-0 panel.new_panel(my_wins[1]), # Push 1, order: stdscr-0-1 panel.new_panel(my_wins[2]), # Push 2, order: stdscr-0-1-2 ) # Set up the user pointers to the next panel my_panels[0].set_userptr(my_panels[1]) my_panels[1].set_userptr(my_panels[2]) my_panels[2].set_userptr(my_panels[0]) # Update the stacking order. 2nd panel will be on top panel.update_panels() # Show it on the screen screen.attron(curses.color_pair(4)) screen.addstr(curses.LINES - 2, 0, "Use tab to browse through the windows (F2 to Exit)") screen.attroff(curses.color_pair(4)) curses.doupdate() top = my_panels[2] char = screen.getch() while char != curses.KEY_F2: if char == ord("\t"): top = top.userptr() top.top() panel.update_panels() curses.doupdate() char = screen.getch() curses.endwin() sys.exit(0)
def draw_new_hand(self, hand_size: int): for i in range(len(self.cb.players)): if i == self.cb.active_position: self.hand_windows[0] = [ curses.newwin(C_HEIGHT, C_WIDTH, (5 * PADDING) + (2 * C_HEIGHT) + (12 * V_SPACING) + I_HEIGHT + self.rows_offset, (2 * PADDING) + C_WIDTH + (j * H_SPACING) + self.cols_offset) for j in range(hand_size) ] self.hand_panels[0] = [ panel.new_panel(self.hand_windows[0][j]) for j in range(hand_size) ] elif i == (self.cb.active_position + 1) % 4: self.hand_windows[1] = [ curses.newwin(C_HEIGHT, C_WIDTH, (5 * PADDING) + C_HEIGHT + (j * V_SPACING) + self.rows_offset, PADDING + self.cols_offset) for j in range(hand_size) ] self.hand_panels[1] = [ panel.new_panel(self.hand_windows[1][j]) for j in range(hand_size) ] elif i == (self.cb.active_position + 2) % 4: self.hand_windows[2] = [ curses.newwin(C_HEIGHT, C_WIDTH, PADDING + self.rows_offset, (2 * PADDING) + C_WIDTH + (j * H_SPACING) + self.cols_offset) for j in range(hand_size) ] self.hand_panels[2] = [ panel.new_panel(self.hand_windows[2][j]) for j in range(hand_size) ] elif i == (self.cb.active_position + 3) % 4: self.hand_windows[3] = [ curses.newwin(C_HEIGHT, C_WIDTH, (5 * PADDING) + C_HEIGHT + (j * V_SPACING) + self.rows_offset, (3 * PADDING) + (2 * C_WIDTH) + (12 * H_SPACING) + self.cols_offset) for j in range(hand_size) ] self.hand_panels[3] = [ panel.new_panel(self.hand_windows[3][j]) for j in range(hand_size) ] self.draw_hand(self.cb.players[i]) self.draw_trump() self.draw_new_info_window() self.draw_score_window()
def add_panel (self, h, l, y, x, headline): win = curses.newwin(h, l, y, x) win.erase() win.box() win.addstr(1, 2, headline) win.refresh() panel.new_panel(win) panel1 = panel.new_panel(win) panel1.top() return win, panel1
def add_panel(self, h, l, y, x, headline): win = curses.newwin(h, l, y, x) win.erase() win.box() win.addstr(1, 2, headline) win.refresh() panel.new_panel(win) panel1 = panel.new_panel(win) panel1.top() return win, panel1
def refresh(self): self.win = curses.newwin(1, 5, self.y, self.x) self.win.addstr(0, 1, '[{}]'.format('X' if self.value else ' ')) self.win.move(0, 2) self.panel = panel.new_panel(self.win) self.panel.show()
def __init__(self, y=0, x=0, lines=None, cols=None, label=None): if lines is None: lines = curses.LINES if cols is None: cols = curses.COLS self.win = curses.newwin(lines, cols, y, x) self.panel = panel.new_panel(self.win) self.win.box() if label: self.win_l = curses.newwin(1, len(label) + 2, y, x + 1) self.panel_l = panel.new_panel(self.win_l) if type(label) is str: label = TermStr(label) label.addstr(self.win_l, 0, 1)
def __init__(self, screen, item): self.screen = screen self.window = screen.subwin(0, 0) self.item = item self.panel = panel.new_panel(self.window) self.panel.hide() panel.update_panels()
def choose(self): curses.noecho() y, x = self.stdscr.getmaxyx() height = min(len(self.items) + 5, y - 2) if len(self.items) > 0: width = self.get_optimal_width() else: width = 10 width = max(len(self.message) + 4, width) self.win = curses.newwin(height, width, int((y - height) / 2), int((x - width) / 2)) self.panel = panel.new_panel(self.win) self.panel.top() self.update() panel.update_panels() curses.doupdate() self.key_loop() self.panel.bottom() panel.update_panels() curses.doupdate() del self.win del self.panel if self.selected < 0: return None else: return self.get_chosen()
def init(viewo_height, viewo_width, line_y, lst_window_width, keeper): viewo_window = newwin(viewo_height, viewo_width, line_y, lst_window_width) #viewo_window.scrollok(True) #viewo_window.idlok(True) viewo_panel = new_panel(viewo_window) viewo_window.box() return viewo_window
def update(sel_panel): global log for i in range(len(panels)): if panels[i].window == None: panels[i].window = curses.newwin(7, 30, 0, 30 * i) panels[i].panel = panel.new_panel(panels[i].window) panels[i].window.erase() panels[i].window.addstr(0, 2, panels[i].device_type()[:27]) log += "\n>window " + str( i) + " device type: " + panels[i].device_type()[:27] + "\n" panels[i].window.addstr(1, 0, panels[i].get_report()[:29]) log += ">window " + str( i) + " device report: " + panels[i].get_report()[:29] + "\n" for j in range(panels[i].meth_n): if j == panels[i].select: if i == sel_panel: panels[i].window.addstr(2 + j, 0, panels[i].meth[j], curses.A_REVERSE) log += ">window " + str( i) + " " + panels[i].meth[j] + " [selected]\n" else: panels[i].window.addstr(2 + j, 0, panels[i].meth[j], curses.A_BOLD) log += ">window " + str( i) + " " + panels[i].meth[j] + " [highlighted]\n" else: panels[i].window.addstr(2 + j, 0, panels[i].meth[j]) log += ">window " + str(i) + " " + panels[i].meth[j] + "\n" panel.update_panels() curses.doupdate() log += ">update exits\n"
def __init__(self, starty, startx, width, new_win=False): self.timer = None self.loadding_timer = None self.timer_lock = threading.Lock() self.loadding_timer_lock = threading.Lock() self.loading_interval = 0.4 self.loading_chars = [' ', '. ', '.. ', '... ', '....'] self.loading_count = 0 self.width = width - 1 self.window = curses.newwin(5, width) self.window.bkgd(' ', curses.color_pair(2)) #defaultbackground color self.progress = 0 self.new_win = new_win self.x=startx self.y=starty if new_win: self.contentwin = curses.newwin(7, width+2) self.contentwin.bkgd(' ', curses.color_pair(2)) #Default Window color self.contentwin.erase() self.contentwin.box() self.contentpanel = curses.panel.new_panel(self.contentwin) self.contentpanel.move(starty-1, startx-1) self.contentpanel.hide() self.panel = panel.new_panel(self.window) self.panel.move(starty, startx) self.panel.hide() panel.update_panels()
def display(self, wng_msg): """ Display **wng_msg** in a panel. """ # Init Menu wng_msg = str_reduce(wng_msg, self.app.screen_width - 2) wng_width = len(wng_msg) + 2 menu_wng = self.app.stdscr.subwin( 3, wng_width, 3, int((self.app.screen_width - wng_width) / 2)) menu_wng.bkgd(self.app.c_warn_txt | curses.A_BOLD) menu_wng.attrset(self.app.c_warn_bdr | curses.A_BOLD) # change border color menu_wng.border(0) menu_wng.keypad(1) # Send menu to a panel panel_wng = panel.new_panel(menu_wng) panel_wng.top() # Push the panel to the bottom of the stack. menu_wng.addstr(1, 1, wng_msg, self.app.c_warn_txt) panel_wng.show() # Display the panel (which might have been hidden) menu_wng.refresh() sleep(1) # Erase the panel menu_wng.clear() panel_wng.hide()
def new_obj_window(panel_offset): obj = None window = curses.newwin(10, 50, 1, 30 * panel_offset) pan = panel.new_panel(window) run2 = True sel = 0 while run2: window.erase() window.addstr(0, 0, "What device to add?") for i in range(len(devices.dev_class)): if sel == i: window.addstr(1 + i, 0, devices.dev_class[i], curses.A_REVERSE) else: window.addstr(1 + i, 0, devices.dev_class[i]) panel.update_panels() curses.doupdate() key2 = scr.getch() if key2 == 259: #UP if sel > 0: sel -= 1 elif key2 == 258: #DOWN if sel < len(devices.dev_class) - 1: sel += 1 elif key2 == 10: #RETURN obj = devices.make(devices.dev_class[sel]) run2 = False return obj
def __init__(self, screen, title, items, selected, resp): self.resp = resp self.screen = screen self.items = list(items) self.position = 0 if selected: for index, item in enumerate(self.items): if item.tid == selected.tid: self.position = index break self.offset = 0 self.window = screen.subwin(0, 0) self.height = height = self.window.getmaxyx()[0] if self.position + 2 >= height: self.offset = self.position - 1 if use_unicode: self.title = "┤ {0} (q to cancel) ├".format(title) else: self.title = "| {0} (q to cancel) |".format(title) self.window.keypad(1) self.panel = panel.new_panel(self.window) self.panel.hide() panel.update_panels() try: curses.curs_set(0) curses.use_default_colors() except curses.error: pass self.start()
def curses_print_map(self): """ Prints the map grid (Starts on floor 1) """ map_window = self.stdscreen.subwin(5,5) map_keypad = map_window.keypad(1) map_panel = panel.new_panel(map_window) map_panel.update_panels() map_panel.top() map_panel.show() map_window.clear() x = 0; y=0; z=0 # Print map phase draw_map(self,[x,y,z]) def draw_map(game,loc): grid = game.world.grid z = loc[2] # Load the current floor (z) for x in range(game.conf.x_dim): for y in range(game.conf.y_dim): # Draw a map here! pass
def __init__(self, items): self.pytify = get_pytify_class_by_platform()() self.items = items self.position = 2 self.song_length = len(items) - 1 # Init curses screen self.window = curses.initscr() self.window.keypad(1) self.panel = panel.new_panel(self.window) self.panel.hide() panel.update_panels() # Show shortcuts self.shortcuts() # Disable echoing of keys to the screen curses.noecho() # Disable blinking cursor curses.curs_set(False) # Use user terminal settings curses.endwin() # Display window curses.wrapper(self.display)
def draw_hands(self, players, name): for player in players.values(): seat = self.id_to_seat(player['id'], players[name]['id']) hand_size = len(player['cards_in_hand']) # initialize curses windows self.windows['hand_windows'][seat] = [ curses.newwin( self.sizes['card_height'], self.sizes['card_width'], self.y_offsets['hand'][seat][i] + self.rows_offset, self.x_offsets['hand'][seat][i] + self.cols_offset) for i in range(hand_size) ] # initialize curses panels self.windows['hand_panels'][seat] = [ panel.new_panel(self.windows['hand_windows'][seat][i]) for i in range(hand_size) ] # draw each card in the hand for c in range(hand_size): card = player['cards_in_hand'][c] card_window = self.windows['hand_windows'][seat][c] card_window.erase() if (card.visible): card_window.attron(curses.color_pair(card.color())) card_window.addstr(card.to_ascii()) card_window.refresh()
def __init__(self, starty, startx, width, new_win=False): self.timer = None self.loadding_timer = None self.timer_lock = threading.Lock() self.loadding_timer_lock = threading.Lock() self.loading_interval = 0.4 self.loading_chars = [' ', '. ', '.. ', '... ', '....'] self.loading_count = 0 self.width = width - 1 self.window = curses.newwin(5, width) self.window.bkgd(' ', curses.color_pair(2)) #defaultbackground color self.progress = 0 self.new_win = new_win self.x = startx self.y = starty if new_win: self.contentwin = curses.newwin(7, width + 2) self.contentwin.bkgd(' ', curses.color_pair(2)) #Default Window color self.contentwin.erase() self.contentwin.box() self.contentpanel = curses.panel.new_panel(self.contentwin) self.contentpanel.move(starty - 1, startx - 1) self.contentpanel.hide() self.panel = panel.new_panel(self.window) self.panel.move(starty, startx) self.panel.hide() panel.update_panels()
def __init__(self, title, associatedToolbar=None, height=None, width=W, prow=1, pcol=0): ## Inizializzo le variabili per gestire menu, eventualmente multipli self.menuDict = {} self.textEntries = {} self.activeMenu = None self.menuPosDict = {} self.menuposition = 0 ## Controllo la toolbar self.toolbar = associatedToolbar if self.toolbar: htool = self.toolbar.h else: htool = 0 ## Geometria self.h = height if height else H-2-htool self.w = width ## Creo la struttura via Curses self.page = curses.newwin(self.h, self.w, prow, pcol) self.panel = panel.new_panel(self.page) self.page.box() ## Altre proprietà della pagina self.isActive = False self.title = title pageDict[title] = self logger.debug(IFACE,'creata pagina \''+title+'\' di dimensioni H='+str(self.h)+' righe e W='+str(self.w)+' colonne')
def __init__(self, cnn, items, stdscreen, title='', type='main', record_index=None): self.window = stdscreen.subwin(0, 0) self.window.keypad(1) self.panel = panel.new_panel(self.window) self.panel.hide() panel.update_panels() self.position = 0 self.items = items if type == 'edit': self.items.append({ 'field': 'Save and exit', 'function': 'save_changes' }) else: self.items.append({'field': 'Exit', 'function': 'exit'}) self.title = title self.type = type self.edited_fields = dict() self.record_index = record_index self.cnn = cnn
def __init__(self, *args, **kwargs) -> None: super(PanelWindow, self).__init__(*args, **kwargs) self.panel = panel.new_panel(self.window) self.panel.top() flush()
def __init__(self, position, size, callback): self.__editable = True self.w, self.h = size self.x, self.y = position self.y += 2 self.__has_focus = False self.__last_size = None h, w = self.__size__() win = curses.newwin(h, w, self.y, self.x) win.bkgd(' ', curses.color_pair(4)) self.__panel__ = panel.new_panel(win) self.__rows__ = [] self.__changed = True # which row is selected self.selected = 0 self.active = 0 self.callback = callback
def __init__(self, items): self.pytify = get_pytify_class_by_platform()() self.items = items self.position = 2 self.song_length = len(items) - 1 # Init curses screen self.window = curses.initscr() self.window.keypad(1) self.panel = panel.new_panel(self.window) self.panel.hide() panel.update_panels() # Show shortcuts self.shortcuts() # Disable echoing of keys to the screen curses.noecho() # Disable blinking cursor curses.curs_set(False) # Use user terminal settings curses.endwin() # Display window self.display()
def __main__(screen): global hwin, cwin, mwin, HEIGHT, WIDTH, card_sizes, rwin, rpan HEIGHT, WIDTH = screen.getmaxyx() if HEIGHT < min_height or WIDTH < min_width: curses.endwin() sys.stderr.write( 'Your terminal is too small to run this application.\n' + 'If you are on a unix console (not in X11 terminal application,)' + 'you could try to see if there is smaller consolefont awaiable ' + 'and use setfont command to use it.\n') exit(5) # Too small screen hwin = screen.subwin(6, WIDTH, 0, 0) # Header and winning numbers cwin = screen.subwin(HEIGHT - 6, WIDTH - 21, 6, 0) # Players cards mwin = screen.subwin(14, 21, 6, WIDTH - 21) # Menu and results rwin = screen.subwin(9, 30, 0, 0) # Panel showing results and asking for rpan = panel.new_panel(rwin) # if user want a new game curses.init_pair(1, curses.COLOR_RED, curses.COLOR_BLACK) curses.init_pair(2, curses.COLOR_MAGENTA, curses.COLOR_BLACK) curses.init_pair(3, curses.COLOR_GREEN, curses.COLOR_BLACK) card_sizes = [] for size in (3, 4, 5, 6, 7): if (((size * 2) + 5) <= cwin.getmaxyx()[0] and ((size * 3) + 3) <= cwin.getmaxyx()[1]): card_sizes.append(size ** 2) run_game()
def main(scr): h, w = scr.getmaxyx() hghts = [h // 3 + (1 if 3 - h % 3 <= i else 0) for i in range(3)] pr = 0 wins = [] for i in hghts: wins.append(newwin(i, w, pr, 0)) pr += i for i in range(3): wins[i].box(0, 0) panels = [new_panel(i) for i in wins] update_panels() doupdate() x = 0 while x != ord('q'): x = scr.getch() wn = wins[0] wn.addstr(1, 1, "%x" % x) wn.addstr(2, 1, repr([ i for i in dir(wn) if not i.startswith('__')])[:w-3]) def_prog_mode() endwin() print(dir(wn)) reset_prog_mode() wins[0].refresh()
def __init__(self, parent, height, width, y, x, header, offset=None, indent=None, func=None, pad_height_factor=3, **kwargs): # initialize regular Subwindow self.pad_initialized = False self.pad_indent = 1 if indent is None else indent self.pad_offset = 1 if offset is None else offset super(SubWindowAndPad, self).__init__(parent, height, width, y, x, header, offset=0, indent=0, func=func, **kwargs) # add a scrollable pad with same width and pad_height_factor * height self.pad_height = self.height * pad_height_factor pad = curses.newpad(self.pad_height, self.width) # define some variables with regard to refreshing the pad self.pad_line = 0 self.top_left = [self.pos_y + 1 + self.pad_offset, self.pos_x + 1 + self.pad_indent] self.bottom_right = [self.pos_y + self.height - 2, self.pos_x + self.width - 1 - self.pad_indent] self.pad_display_coordinates = self.top_left + self.bottom_right self.scroll_limit = self.pad_height - self.height + 1 # substitute self.screen with pad, move self.screen to self.window self.window = self.screen self.screen = pad if self.args: self.args[0] = pad self.pad_initialized = True # move subwindow underneath pad (panel has to be stored, otherwise it is garbage collected) self.panel = panel.new_panel(self.window) self.panel.bottom() # adjust indent and offset due to pad self.indent -= 1 if self.indent > 0 else 0 self.offset -= 1 if self.offset > 0 else 0
def __init__(self, app, sock, logger): """ Class Constructor """ # Instance arguments self.app = app self.sock = sock self.logger = logger # Init constants self.resize = False self.pkey = -1 # Init Prompt self.prompt = Prompt(self.app) self.prompt_time = 0 self.prompt_msg = '' # Update dimensions self.screen_height, self.screen_width = self.app.stdscr.getmaxyx( ) # Local dimensions # Init subwin self.gwin = self.app.stdscr.subwin(self.app.panel_height, self.app.screen_width, 0, 0) self.gwin.keypad(1) # Init Panel self.gpan = panel.new_panel(self.gwin) self.gpan.hide()
def _build_page(stdscr, page, P_STACK, COLOR_PAIRS, debug): """ low end build function is resposible for initializing the jcurses app by drawing the app and starting the contoller """ # build this pages curses window object _make_win(page) # color the window page._win.bkgd(" ", cs.color_pair(COLOR_PAIRS["black," + page.color])) # add all the labels for lbl in page.labels: _add_label(page, lbl, COLOR_PAIRS) # make a new panel for the new window and add the panel to the pan_stk panel = cp.new_panel(page._win) # add the new panel to the panel_stack P_STACK.add_panel(page.groups, panel) # update the page page._win.noutrefresh() # build the subpages for subpage in page.subpages: _build_page(stdscr, subpage, P_STACK, COLOR_PAIRS, debug)
def __init__(self, text_path, stdscreen, path_flag=True): self.window=stdscreen.subwin(0,0) self.window.keypad(1) self.panel = panel.new_panel(self.window) self.panel.hide() panel.update_panels() self.position = 0 if path_flag: # If the flag indicates text_path is a path, # the file at that location is read with open(text_path,'rb') as txt: self.txt = txt.readlines() else: # Otherwise the text in the text_path parameter # is used self.txt = text_path self.txt = '\n'.join(self.txt) self.txt+='\nPress any key to return...' with open('log.txt','wb') as lg: lg.write(self.txt) self.window.addstr(self.txt) self.panel.top() self.panel.show() self.window.clear() key = self.window.getch() self.window.clear() self.panel.hide() panel.update_panels() curses.doupdate()
def __init__(self, stdscreen, title, debug_console, threadcount): self.debug_console = debug_console self.threadcount = threadcount self.runningthreads = threadcount self.title = title self.index = [] self.totalsums = [] self.height = int(terminal.height/2) self.width = terminal.width - 2 self.window = stdscreen.subwin(self.height,self.width,1,1) self.window.border(0) self.window.addstr(0,1,title) self.padding = 1 #padding between drawed items self.panel = panel.new_panel(self.window) self.panel.hide() panel.update_panels() # Add the Border for i in range(0, self.threadcount): self.index.append(0) self.totalsums.append(0) #for the running time self.i = 7 self.start_time = time.time() self.debug_console.log("Init of InfoContainer complete")
def __init__ (self, h, l, y, x, headline): self.h = h self.l = l self.y = y self.x = x self.headline = headline self.win = curses.newwin(h, l, y, x) self.win.erase() self.win.box() self.win.addstr(1, 2, headline, curses.A_UNDERLINE) self.win.refresh() panel.new_panel(self.win) self.panel = panel.new_panel(self.win) self.panel.top()
def __init__(self, items, title, stdscreen, exit = True): height, width = stdscreen.getmaxyx() self.horizCenter = width/2 self.window = stdscreen.subwin(18,0) self.window.keypad(1) self.panel = panel.new_panel(self.window) self.panel.hide() panel.update_panels() self.titlestr = title self.position = 0 self.items = items self.hasExit = exit self.top = curses.newwin(0,0,0,0) self.topPanel = panel.new_panel(self.top) self.terminate = False if exit : self.items.append(('Back','exit'))
def make_panel(stdscreen): window = stdscreen.subwin(0, 0) window.keypad(1) pan = panel.new_panel(window) #print "created pan" , pan pan.hide() panel.update_panels() return window, pan
def __init__(self, h, l, y, x, headline): self.h = h self.l = l self.y = y self.x = x self.headline = headline self.win = curses.newwin(h, l, y, x) self.win.erase() self.win.box() self.win.addstr(1, 2, headline, curses.A_UNDERLINE) self.win.refresh() panel.new_panel(self.win) self.panel = panel.new_panel(self.win) self.panel.top()
def __init__(self, window, consistent, map_dir, stdscr): self.window = window self.consistent = consistent self.map_dir = map_dir self.window.keypad(1) self.panel = panel.new_panel(self.window) self.panel.hide() panel.update_panels()
def __init__(self, items, stdscreen): self.window = stdscreen.subwin(0, 0) self.window.keypad(1) self.panel = panel.new_panel(self.window) self.panel.hide() panel.update_panels() self.items = items
def window(self, window): window.keypad(1) self.panel = panel.new_panel(window) self.panel.hide() panel.update_panels() self.height, self.width = window.getmaxyx() self.__window = window
def __init__(self, screen, h, w, y, x): self.h = h self.w = w self.win = curses.newwin(h, w, y, x) self.panel = panel.new_panel(self.win) self.win.clear() self.panel.hide() panel.update_panels()
def setup_screen(self, screen): logging.debug("Setting up screen") self.screen = screen curses.curs_set(0) screen_y, screen_x = self.screen.getmaxyx() win = curses.newwin(screen_y, screen_x, 0, 0) self.main_window = panel.new_panel(win)
def createWindow(self,stdscreen): self.stdscreen = stdscreen self.calcSize() self.window = self.stdscreen.subwin(self.height + 2,self.width + 2,self.y,self.x) self.window.keypad(1) self.panel = panel.new_panel(self.window) self.panel.hide() panel.update_panels()
def __init__(self, items, stdscreen): self.window = stdscreen.subwin(0,0) self.window.keypad(1) self.panel = panel.new_panel(self.window) self.panel.hide() panel.update_panels() self.position = 0 self.items = items self.items.append(('exit', 'exit'))
def refresh(self): if getattr(self, 'win', None): del self.win self.win = curses.newwin(1, self.cols, self.y, self.x) self.win.addstr(0, 1, self.label) self.panel = panel.new_panel(self.win) self.panel.show()
def displayTop(self) : self.top = curses.newwin(16,78,0,0) self.topPanel = panel.new_panel(self.top) self.updateTop() self.topPanel.top() self.topPanel.show() self.top.refresh() panel.update_panels() curses.doupdate()
def RunUI(self, stdscr): win = curses.newwin(8,8,1,1) pan = panel.new_panel(win) pan.show() while 1: stdscr.addstr(0, 0, "Current mode: Typing mode", curses.A_REVERSE) panel.update_panels() curses.doupdate() stdscr.refresh()
def __init__(self): self.data = None self.selected_row = 0 self.page = 0 self.total_pages = 0 self.win = curses.newwin(0, 0) self.win.box() self.panel = panel.new_panel(self.win) self.panel.set_userptr(self) self.refresh_data()
def __init__(self, data, stdscreen): self.window = stdscreen.subwin(0,0) self.window.keypad(1) self.panel = panel.new_panel(self.window) self.panel.hide() panel.update_panels() self.position = 0 self.items = ['Pressure'] self.values=data
def __init__(self, screen, y, x): self.__screen = screen self.win = curses.newwin(int(y), int(x), 0, 0) self.win.box() self.__options = [MenuItem("User", UserTable()), MenuItem("Devices", DeviceTable())] self.__current_focus = 0 self.panel = panel.new_panel(self.win) self.panel.set_userptr(self) self.select()
def refresh(self): if self.win: del self.win self.win = curses.newwin(1, self.cols, self.y, self.x) self.win.addstr(0, 1, self.label) self.panel = panel.new_panel(self.win) self.panel.show() if self.widget: self.widget.refresh()
def __init__(self, stdscreen): self.window = stdscreen.subwin(0,0) self.window.keypad(1) self.panel = panel.new_panel(self.window) self.panel.hide() panel.update_panels() self.position = 0 self.items = ['P4','P3','T3','exit'] self.values=[0.0 for i in range(len(self.items)-1)] self.values.append('')
def refresh(self): if self.win: del self.win label = self.popup.value self.win = curses.newwin(1, len(label) + 2, self.y, self.x) self.win.addstr(0, 1, label) self.panel = panel.new_panel(self.win) self.panel.show()
def __init__(self, items, stdscreen): self.window = stdscreen.subwin(0,0) self.window.keypad(1) self.panel = panel.new_panel(self.window) self.panel.hide() panel.update_panels() self.position = 0 self.items = items self.items.append(('==== OUTPUT ==== (press "q" for exit)','nothing')) self.items.append(('>','nothing'))