Python curses.A_BOLD Examples
The following are 30
code examples of curses.A_BOLD().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
curses
, or try the search function
.
Example #1
Source File: curses_ui.py From lambda-packs with MIT License | 7 votes |
def _screen_create_command_textbox(self, existing_command=None): """Create command textbox on screen. Args: existing_command: (str) A command string to put in the textbox right after its creation. """ # Display the tfdbg prompt. self._stdscr.addstr(self._max_y - self._command_textbox_height, 0, self.CLI_PROMPT, curses.A_BOLD) self._stdscr.refresh() self._command_window.clear() # Command text box. self._command_textbox = textpad.Textbox( self._command_window, insert_mode=True) # Enter existing command. self._auto_key_in(existing_command)
Example #2
Source File: app.py From toot with GNU General Public License v3.0 | 6 votes |
def get_content(self): return [ ("toot v{}".format(__version__), Color.GREEN | curses.A_BOLD), "", "Key bindings:", "", " h - show help", " j or ↓ - move down", " k or ↑ - move up", " v - view current toot in browser", " b - toggle boost status", " f - toggle favourite status", " c - post a new status", " r - reply to status", " q - quit application", " s - show sensitive content" "", "Press q to exit help.", "", ("https://github.com/ihabunek/toot", Color.YELLOW), ]
Example #3
Source File: ahuman.py From gps3 with MIT License | 6 votes |
def show_nmea(): """NMEA output in curses terminal""" data_window = curses.newwin(24, 79, 0, 0) for new_data in gpsd_socket: if new_data: screen.nodelay(1) key_press = screen.getch() if key_press == ord('q'): shut_down() elif key_press == ord('j'): # raw gpsd_socket.watch(enable=False, gpsd_protocol='nmea') gpsd_socket.watch(gpsd_protocol='json') show_human() data_window.border(0) data_window.addstr(0, 2, 'AGPS3 Python {}.{}.{} GPSD Interface Showing NMEA protocol'.format(*sys.version_info), curses.A_BOLD) data_window.addstr(2, 2, '{}'.format(gpsd_socket.response)) data_window.refresh() else: sleep(.1)
Example #4
Source File: displayutil.py From onion-expose with BSD 3-Clause "New" or "Revised" License | 6 votes |
def draw_fancy_text(self, text, y, x, attr=0): """ Displays text. A unicode `Superscript Two` (U+00B2) toggles bold formatting; a unicode `Superscript Three` (U+00B3) toggles color inversion. The bold and inversion formatting flags are ORed with the `attr` parameter. """ # TODO: Allow formatting other than bold (possibly using other exotic Unicode characters). pos = 0 for i in range(len(text)): if text[i] == "\xb2": attr ^= curses.A_BOLD elif text[i] == "\xb3": attr ^= curses.A_REVERSE else: self.window.addch(y, x + pos, text[i], attr) pos += 1
Example #5
Source File: curses_ui.py From auto-alt-text-lambda-api with MIT License | 6 votes |
def _screen_create_command_textbox(self, existing_command): """Create command textbox on screen. Args: existing_command: (str) A command string to put in the textbox right after its creation. """ # Display the tfdbg prompt. self._stdscr.addstr(self._max_y - self._command_textbox_height, 0, self.CLI_PROMPT, curses.A_BOLD) self._stdscr.refresh() self._command_window.clear() # Command text box. self._command_textbox = textpad.Textbox( self._command_window, insert_mode=True) # Enter existing command. self._auto_key_in(existing_command)
Example #6
Source File: human.py From gps3 with MIT License | 6 votes |
def show_nmea(): """NMEA output in curses terminal""" data_window = curses.newwin(24, 79, 0, 0) for new_data in gpsd_socket: if new_data: screen.nodelay(1) key_press = screen.getch() if key_press == ord('q'): shut_down() elif key_press == ord('j'): # raw gpsd_socket.watch(enable=False, gpsd_protocol='nmea') gpsd_socket.watch(gpsd_protocol='json') show_human() data_window.border(0) data_window.addstr(0, 2, 'GPS3 Python {}.{}.{} GPSD Interface Showing NMEA protocol'.format(*sys.version_info), curses.A_BOLD) data_window.addstr(2, 2, '{}'.format(gpsd_socket.response)) data_window.refresh() else: sleep(.1)
Example #7
Source File: text.py From encompass with GNU General Public License v3.0 | 6 votes |
def print_balance(self): if not self.network: msg = _("Offline") elif self.network.is_connected(): if not self.wallet.up_to_date: msg = _("Synchronizing...") else: c, u = self.wallet.get_balance() msg = _("Balance")+": %f "%(Decimal( c ) / 100000000) if u: msg += " [%f unconfirmed]"%(Decimal( u ) / 100000000) else: msg = _("Not connected") self.stdscr.addstr( self.maxy -1, 3, msg) for i in range(self.num_tabs): self.stdscr.addstr( 0, 2 + 2*i + len(''.join(self.tab_names[0:i])), ' '+self.tab_names[i]+' ', curses.A_BOLD if self.tab == i else 0) self.stdscr.addstr( self.maxy -1, self.maxx-30, ' '.join([_("Settings"), _("Network"), _("Quit")]))
Example #8
Source File: wallet.py From bitcoind-ncurses with MIT License | 6 votes |
def draw_window(state, window): window.clear() window.refresh() win_header = curses.newwin(2, 76, 0, 0) unit = 'BTC' if 'testnet' in state: if state['testnet']: unit = 'TNC' if 'wallet' in state: if 'balance' in state: balance_string = "balance: " + "%0.8f" % state['balance'] + " " + unit if 'unconfirmedbalance' in state: if state['unconfirmedbalance'] != 0: balance_string += " (+" + "%0.8f" % state['unconfirmedbalance'] + " unconf)" window.addstr(0, 1, balance_string, curses.A_BOLD) draw_transactions(state) else: win_header.addstr(0, 1, "no wallet information loaded", curses.A_BOLD + curses.color_pair(3)) win_header.addstr(1, 1, "loading... (is -disablewallet on?)", curses.A_BOLD) win_header.refresh()
Example #9
Source File: wallet.py From bitcoind-ncurses with MIT License | 6 votes |
def draw_transactions(state): window_height = state['y'] - 3 win_transactions = curses.newwin(window_height, 76, 2, 0) win_transactions.addstr(0, 1, "transactions: (UP/DOWN: scroll, ENTER: view)", curses.A_BOLD + curses.color_pair(5)) offset = state['wallet']['offset'] for index in range(offset, offset+window_height-1): if index < len(state['wallet']['view_string']): condition = (index == offset+window_height-2) and (index+1 < len(state['wallet']['view_string'])) condition = condition or ( (index == offset) and (index > 0) ) if condition: win_transactions.addstr(index+1-offset, 1, "...") else: win_transactions.addstr(index+1-offset, 1, state['wallet']['view_string'][index]) if index == (state['wallet']['cursor']*4 + 1): win_transactions.addstr(index+1-offset, 1, ">", curses.A_REVERSE + curses.A_BOLD) win_transactions.refresh()
Example #10
Source File: peers.py From bitcoind-ncurses with MIT License | 6 votes |
def draw_window(state, window): window.clear() window.refresh() win_header = curses.newwin(3, 75, 0, 0) if 'peerinfo' in state: win_header.addstr(0, 1, "connected peers: " + str(len(state['peerinfo'])).ljust(10) + " (UP/DOWN: scroll)", curses.A_BOLD) win_header.addstr(2, 1, " Node IP Version Recv Sent Time Height", curses.A_BOLD + curses.color_pair(5)) draw_peers(state) else: win_header.addstr(0, 1, "no peer information loaded", curses.A_BOLD + curses.color_pair(3)) win_header.addstr(1, 1, "loading...", curses.A_BOLD) win_header.refresh()
Example #11
Source File: forks.py From bitcoind-ncurses with MIT License | 6 votes |
def draw_window(state, window): window.clear() window.refresh() win_header = curses.newwin(3, 75, 0, 0) if 'chaintips' in state: win_header.addstr(0, 1, "chain tips: " + str(len(state['chaintips'])).ljust(10) + " (UP/DOWN: scroll, F: refresh)", curses.A_BOLD) win_header.addstr(1, 1, "key: Active/Invalid/HeadersOnly/ValidFork/ValidHeaders", curses.A_BOLD) win_header.addstr(2, 1, "height length status 0-prefix hash", curses.A_BOLD + curses.color_pair(5)) draw_tips(state) else: win_header.addstr(0, 1, "no chain tip information loaded", curses.A_BOLD + curses.color_pair(3)) win_header.addstr(1, 1, "loading... (press F to try again)", curses.A_BOLD) win_header.refresh()
Example #12
Source File: curses_ui.py From deep_image_model with Apache License 2.0 | 6 votes |
def _screen_create_command_textbox(self, existing_command): """Create command textbox on screen. Args: existing_command: (str) A command string to put in the textbox right after its creation. """ # Display the tfdbg prompt. self._stdscr.addstr(self._max_y - self._command_textbox_height, 0, self.CLI_PROMPT, curses.A_BOLD) self._stdscr.refresh() self._command_window.clear() # Command text box. self._command_textbox = textpad.Textbox( self._command_window, insert_mode=True) # Enter existing command. self._auto_key_in(existing_command)
Example #13
Source File: pytrader.py From pytrader with MIT License | 6 votes |
def paint_item(self, posy, index): """paint one single order""" order = self.items[index] # self.instance.debug("order: %s, selected: %s" % (order, self.selected)) if order in self.selected: marker = "*" if index == self.item_sel: attr = COLOR_PAIR["dialog_sel_sel"] else: attr = COLOR_PAIR["dialog_sel_text"] + curses.A_BOLD else: marker = "" if index == self.item_sel: attr = COLOR_PAIR["dialog_sel"] else: attr = COLOR_PAIR["dialog_text"] self.addstr(posy, 2, marker, attr) self.addstr(posy, 5, order.typ, attr) self.addstr(posy, 9, str(order.price), attr) self.addstr(posy, 22, str(order.volume), attr)
Example #14
Source File: footer.py From bitcoind-ncurses with MIT License | 6 votes |
def draw_window(state): win_footer = curses.newwin(1, 76, state['y']-1, 0) color = curses.color_pair(1) if 'testnet' in state: if state['testnet']: color = curses.color_pair(2) win_footer.addstr(0, 1, "ncurses", color + curses.A_BOLD) x = 10 for mode_string in g.modes: modifier = curses.A_BOLD if state['mode'] == mode_string: modifier += curses.A_REVERSE win_footer.addstr(0, x, mode_string[0].upper(), modifier + curses.color_pair(5)) win_footer.addstr(0, x+1, mode_string[1:], modifier) x += len(mode_string) + 2 win_footer.refresh()
Example #15
Source File: graphics.py From costar_plan with Apache License 2.0 | 6 votes |
def drawWorld(self, world, draw_actors=True): for i in range(world.worldmap.shape[0]): for j in range(world.worldmap.shape[1]): if world.worldmap[i, j] == W.DirectionEast: self.stdscr.addstr(i, j, '>', curses.color_pair(0)) elif world.worldmap[i, j] == W.DirectionWest: self.stdscr.addstr(i, j, '<', curses.color_pair(0)) elif world.worldmap[i, j] == W.DirectionNorth: self.stdscr.addstr(i, j, '^', curses.color_pair(0)) elif world.worldmap[i, j] == W.DirectionSouth: self.stdscr.addstr(i, j, 'v', curses.color_pair(0)) elif world.worldmap[i, j] == W.Sidewalk: self.stdscr.addstr(i, j, '#', curses.color_pair(0)) elif world.worldmap[i, j] == W.Intersection: self.stdscr.addstr(i, j, 'X', curses.color_pair(0)) else: self.stdscr.addstr(i, j, ' ') if draw_actors: for actor in world.actors: if actor.state.x >= 0 and actor.state.y >= 0: self.stdscr.addstr( actor.state.y, actor.state.x, actor.name, curses.color_pair(1) + curses.A_BOLD + curses.A_UNDERLINE) self.bottom_row = i
Example #16
Source File: clockr.py From clockr with MIT License | 6 votes |
def print_time(now): """main time function""" twentyfourhours = twentyfourhourarg time_line = now.strftime("%H:%M:%S" if twentyfourhours else "%I:%M:%S") time_array = ["" for i in range(0, 7)] for char in time_line: char_array = glyph[char] for row in range(0, len(char_array)): time_array[row] += char_array[row] for y in range(0, len(time_array)): for x in range(0, len(time_array[y])): char = time_array[y][x] color = 1 if char == " " else 3 # If we run in 24-hour mode, the AM/PM will be omitted. # This then leads to a misaligned clock, thus # we need to move the clock to the right 2 columns addstr(y, x if not twentyfourhours else x + 2, " ", curses.color_pair(color)) if not twentyfourhours: addstr(6, len(time_array[0]), now.strftime("%p"), curses.color_pair(2) | curses.A_BOLD)
Example #17
Source File: worldmap.py From EasY_HaCk with Apache License 2.0 | 6 votes |
def run(self, scr): """ Initialize and run the application """ m = AsciiMap() curses.halfdelay(self.sleep) while True: now = int(time.time()) refresh = self.fetch_data(now) m.set_data(self.data) m.draw(scr) scr.addstr(0, 1, 'Shodan Radar', curses.A_BOLD) scr.addstr(0, 40, time.strftime("%c UTC", time.gmtime(now)).rjust(37), curses.A_BOLD) # Key Input # q - Quit event = scr.getch() if event == ord('q'): break # redraw window (to fix encoding/rendering bugs and to hide other messages to same tty) # user pressed 'r' or new data was fetched if refresh: m.window.redrawwin()
Example #18
Source File: curses_reporter.py From copycat with MIT License | 6 votes |
def depict_workspace_object(self, w, row, column, o, maxImportance, description_structures): if maxImportance != 0.0 and o.relativeImportance == maxImportance: attr = curses.A_BOLD else: attr = curses.A_NORMAL w.addstr(row, column, str(o), attr) column += len(str(o)) if o.descriptions: w.addstr(row, column, ' (', curses.A_NORMAL) column += 2 for i, d in enumerate(o.descriptions): if i != 0: w.addstr(row, column, ', ', curses.A_NORMAL) column += 2 s, attr = self.slipnode_name_and_attr(d.descriptor) if d not in description_structures: s = '[%s]' % s w.addstr(row, column, s, attr) column += len(s) w.addstr(row, column, ')', curses.A_NORMAL) column += 1 return column
Example #19
Source File: tui.py From wifiphisher with GNU General Public License v3.0 | 5 votes |
def gather_info(self, screen, info): """ Get the information from pywifiphisher and print them out :param self: A TuiMain object :param screen: A curses window object :param info: A namedtuple of printing information :type self: TuiMain :type screen: _curses.curses.window :type info: namedtuple :return: None :rtype: None """ # setup curses try: curses.curs_set(0) except curses.error: pass screen.nodelay(True) curses.init_pair(1, curses.COLOR_BLUE, screen.getbkgd()) curses.init_pair(2, curses.COLOR_YELLOW, screen.getbkgd()) curses.init_pair(3, curses.COLOR_RED, screen.getbkgd()) self.blue_text = curses.color_pair(1) | curses.A_BOLD self.yellow_text = curses.color_pair(2) | curses.A_BOLD self.red_text = curses.color_pair(3) | curses.A_BOLD while True: # catch the exception when screen size is smaller than # the text length is_done = self.display_info(screen, info) if is_done: return
Example #20
Source File: wgboxwidget.py From HomePWN with GNU General Public License v3.0 | 5 votes |
def get_footer_attributes(self, footer_text): footer_attributes = curses.A_NORMAL if self.do_colors() and not self.editing: footer_attributes = footer_attributes | self.parent.theme_manager.findPair(self, self.color) # | curses.A_BOLD elif self.editing: footer_attributes = footer_attributes | self.parent.theme_manager.findPair(self, 'HILIGHT') else: footer_attributes = footer_attributes # | curses.A_BOLD if self.editing: footer_attributes = footer_attributes | curses.A_BOLD # footer_attributes = self.parent.theme_manager.findPair(self, self.color) return self.make_attributes_list(footer_text, footer_attributes)
Example #21
Source File: curses_display.py From anyMesh-Python with MIT License | 5 votes |
def _setattr(self, a): if a is None: self.s.attrset(0) return elif not isinstance(a, AttrSpec): p = self._palette.get(a, (AttrSpec('default', 'default'),)) a = p[0] if self.has_color: if a.foreground_basic: if a.foreground_number >= 8: fg = a.foreground_number - 8 else: fg = a.foreground_number else: fg = 7 if a.background_basic: bg = a.background_number else: bg = 0 attr = curses.color_pair(bg * 8 + 7 - fg) else: attr = 0 if a.bold: attr |= curses.A_BOLD if a.standout: attr |= curses.A_STANDOUT if a.underline: attr |= curses.A_UNDERLINE if a.blink: attr |= curses.A_BLINK self.s.attrset(attr)
Example #22
Source File: window.py From lyrics-in-terminal with MIT License | 5 votes |
def set_titlebar(self): track_info = self.player.track.track_info(self.width - 1) # track_info -> ['title', 'artist', 'album'] - all algined self.stdscr.addstr(0, 1, track_info[0], curses.A_REVERSE) self.stdscr.addstr(1, 1, track_info[1], curses.A_REVERSE | curses.A_BOLD | curses.A_DIM) self.stdscr.addstr(2, 1, track_info[2], curses.A_REVERSE)
Example #23
Source File: clockr.py From clockr with MIT License | 5 votes |
def print_date(now): """main date function""" day_line = now.strftime("%A").center(11, " ") date_line = now.strftime("%B %d, %Y") if not dateformat \ else now.strftime(dateformat) if nodate: pass else: addstr(8, 0, day_line, curses.color_pair(2)) addstr(8, len(day_line) + 40, date_line, curses.color_pair(2) | curses.A_BOLD)
Example #24
Source File: window.py From lyrics-in-terminal with MIT License | 5 votes |
def add_text(self): self.win.refresh() h, w = self.win.getmaxyx() self.win.addstr(3, 3, 'Help Page', curses.A_BOLD | curses.A_UNDERLINE) self.win.addstr(h - 2, 3, f"{'Press any key to exit...':>{w-5}}") keys = { curses.KEY_UP : '↑', curses.KEY_DOWN : '↓', curses.KEY_LEFT: '←', curses.KEY_RIGHT: '→', } # keybinds i, j = 6, 3 self.win.addstr(i, j, 'Keybindings', curses.A_UNDERLINE) i += 2 i = self.add_config(i, j, self.keybinds, keys) # options if w // 2 >= 30: i, j = 6, w // 2 else: i += 2 self.win.addstr(i, j, 'Default Options', curses.A_UNDERLINE) i+= 2 self.add_config(i, j, self.options, keys)
Example #25
Source File: mitop.py From mitogen with BSD 3-Clause "New" or "Revised" License | 5 votes |
def paint(self): self.stdscr.erase() self.stdscr.addstr(0, 0, time.ctime()) all_procs = [] for host in self.hosts: all_procs.extend(host.procs.values()) all_procs.sort(key=(lambda proc: -proc.pcpu)) self.stdscr.addstr(1, 0, self.format % { 'hostname': 'HOST', 'pid': 'PID', 'ppid': 'PPID', 'pcpu': '%CPU', 'rss': 'RSS', 'command': 'COMMAND', }) for i, proc in enumerate(all_procs): if (i+3) >= self.height: break if proc.new: self.stdscr.attron(curses.A_BOLD) else: self.stdscr.attroff(curses.A_BOLD) self.stdscr.addstr(2+i, 0, self.format % dict( vars(proc), command=proc.command[:self.width-36] )) self.stdscr.refresh()
Example #26
Source File: wgboxwidget.py From EDCOP with Apache License 2.0 | 5 votes |
def get_footer_attributes(self, footer_text): footer_attributes = curses.A_NORMAL if self.do_colors() and not self.editing: footer_attributes = footer_attributes | self.parent.theme_manager.findPair(self, self.color) #| curses.A_BOLD elif self.editing: footer_attributes = footer_attributes | self.parent.theme_manager.findPair(self, 'HILIGHT') else: footer_attributes = footer_attributes #| curses.A_BOLD if self.editing: footer_attributes = footer_attributes | curses.A_BOLD #footer_attributes = self.parent.theme_manager.findPair(self, self.color) return self.make_attributes_list(footer_text, footer_attributes)
Example #27
Source File: curseradio.py From curseradio with MIT License | 5 votes |
def display(self, msg=None): """ Redraw the screen, possibly showing a message on the bottom row. """ self.screen.clear() width0 = 6*(self.maxx - 10)//10 width1 = 4*(self.maxx - 10)//10 showobjs = self.flat[self.top:self.top+self.maxy-1] for i, (obj, depth) in enumerate(showobjs): text = obj.render() style = curses.A_BOLD if i == self.cursor else curses.A_NORMAL self.screen.addstr(i, depth*2, text[0][:width0-depth*2], style) self.screen.addstr(i, width0+2, text[1][:width1-4]) self.screen.addstr(i, width0+width1, text[2][:4]) self.screen.addstr(i, width0+width1+5, text[3][:5]) if msg is not None: self.screen.addstr(self.maxy-1, 0, msg[:self.maxx-1], curses.A_BOLD) else: self.screen.addstr(self.maxy-1, 0, self.status[:self.maxx-1], curses.A_BOLD) self.screen.refresh() curses.doupdate()
Example #28
Source File: renderer.py From py_cui with BSD 3-Clause "New" or "Revised" License | 5 votes |
def _set_bold(self): """Sets bold draw mode """ self._stdscr.attron(curses.A_BOLD)
Example #29
Source File: recipe-577933.py From code with MIT License | 5 votes |
def display_header(scr): write(scr, 3, 0, 'Slot', curses.A_BOLD) write(scr, 3, 5, 'Host', curses.A_BOLD) write(scr, 3, 25, 'State', curses.A_BOLD) write(scr, 3, 45, 'Filename', curses.A_BOLD) #'%-4s %-20s %-15s %-40s%s' % ('Slot', 'Remote Host', 'State', 'Filename', ' '*(maxX-83)), curses.A_BOLD)
Example #30
Source File: renderer.py From py_cui with BSD 3-Clause "New" or "Revised" License | 5 votes |
def _unset_bold(self): """Unsets bold draw mode """ self._stdscr.attroff(curses.A_BOLD)