本文整理汇总了Python中curses.A_STANDOUT属性的典型用法代码示例。如果您正苦于以下问题:Python curses.A_STANDOUT属性的具体用法?Python curses.A_STANDOUT怎么用?Python curses.A_STANDOUT使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类curses
的用法示例。
在下文中一共展示了curses.A_STANDOUT属性的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: print_cursor
# 需要导入模块: import curses [as 别名]
# 或者: from curses import A_STANDOUT [as 别名]
def print_cursor(self):
_cur_loc_x = self.cursor_position - self.begin_at + self.relx + self.left_margin
try:
char_under_cur = self.decode_token(self.value[self.cursor_position]) #use the real value
char_under_cur = self.safe_string(char_under_cur)
except IndexError:
char_under_cur = ' '
if isinstance(char_under_cur, bytes):
char_under_cur = char_under_cur.decode(self.encoding, 'replace')
offset = self.find_cursor_offset_on_screen(self.cursor_position)
if self.do_colors():
ATTR_LIST = self.parent.theme_manager.findPair(self) | curses.A_STANDOUT
else:
ATTR_LIST = curses.A_STANDOUT
self.add_line(self.rely,
self.begin_at + self.relx + self.left_margin + offset,
char_under_cur,
self.make_attributes_list(char_under_cur, ATTR_LIST),
# I don't understand why the "- self.begin_at" is needed in the following line
# but it is or the cursor can end up overrunning the end of the widget.
self.maximum_string_length+1 - self.left_margin - offset - self.begin_at,
)
示例2: print_cursor
# 需要导入模块: import curses [as 别名]
# 或者: from curses import A_STANDOUT [as 别名]
def print_cursor(self):
# This needs fixing for Unicode multi-width chars.
# Cursors do not seem to work on pads.
#self.parent.curses_pad.move(self.rely, self.cursor_position - self.begin_at)
# let's have a fake cursor
_cur_loc_x = self.cursor_position - self.begin_at + self.relx + self.left_margin
# The following two lines work fine for ascii, but not for unicode
#char_under_cur = self.parent.curses_pad.inch(self.rely, _cur_loc_x)
#self.parent.curses_pad.addch(self.rely, self.cursor_position - self.begin_at + self.relx, char_under_cur, curses.A_STANDOUT)
#The following appears to work for unicode as well.
try:
#char_under_cur = self.value[self.cursor_position] #use the real value
char_under_cur = self._get_string_to_print()[self.cursor_position]
char_under_cur = self.safe_string(char_under_cur)
except IndexError:
char_under_cur = ' '
except TypeError:
char_under_cur = ' '
if self.do_colors():
self.parent.curses_pad.addstr(self.rely, self.cursor_position - self.begin_at + self.relx + self.left_margin, char_under_cur, self.parent.theme_manager.findPair(self, 'CURSOR_INVERSE'))
else:
self.parent.curses_pad.addstr(self.rely, self.cursor_position - self.begin_at + self.relx + self.left_margin, char_under_cur, curses.A_STANDOUT)
示例3: do_keyboard_shortcuts
# 需要导入模块: import curses [as 别名]
# 或者: from curses import A_STANDOUT [as 别名]
def do_keyboard_shortcuts(self):
w = self.temperatureWindow # just a random window
ordch = w.getch()
if ordch in [ord('P'), ord('p')]:
w.addstr(0, 0, 'PAUSE', curses.A_STANDOUT)
w.refresh()
ordch = None
while ordch not in [ord('P'), ord('p'), 27, ord('Q'), ord('q')]:
time.sleep(0.1)
ordch = w.getch()
self.fpsTicks = 0
self.fpsSince = time.time()
w.erase()
w.border()
w.refresh()
if ordch in [27, ord('Q'), ord('q')]:
raise KeyboardInterrupt()
if ordch in [ord('F')]:
self.fpsGoal = (self.fpsGoal or self.fpsMeasured) * 1.25
if ordch in [ord('f')]:
self.fpsGoal = (self.fpsGoal or self.fpsMeasured) * 0.8
示例4: get_int_value
# 需要导入模块: import curses [as 别名]
# 或者: from curses import A_STANDOUT [as 别名]
def get_int_value(self, message):
dimensions = self.screen.getmaxyx()
if len(message) < dimensions[1]:
empty = dimensions[1] - len(message) - 2
self.screen.addstr(dimensions[0] - 2, len(message) + 1, \
" " * empty, curses.A_STANDOUT)
self.screen.addstr(dimensions[0] - 2, 1, message, curses.A_STANDOUT)
curses.curs_set(1);
curses.echo() # show cursor
value = self.screen.getstr()
self.draw_help()
curses.curs_set(0);
curses.noecho()
try:
return int(value)
except ValueError:
return None
示例5: display
# 需要导入模块: import curses [as 别名]
# 或者: from curses import A_STANDOUT [as 别名]
def display(self):
self.win.erase()
addstr(self.win, 1, 1, self.title[:self.term_cols - 3],
curses.A_STANDOUT)
visible_rows = self.tdata[self.hid_rows:self.hid_rows +
self.nlines]
addstr(self.win, 2, 1, '\n '.join(visible_rows))
self.win.box()
self.win.refresh()
示例6: _render_graph
# 需要导入模块: import curses [as 别名]
# 或者: from curses import A_STANDOUT [as 别名]
def _render_graph(window, bandwidth_rates):
window.erase()
download_rates = [entry[0] for entry in bandwidth_rates]
upload_rates = [entry[1] for entry in bandwidth_rates]
# show the latest values at the top
label = "Downloaded (%s/s):" % str_tools.size_label(download_rates[0], 1)
window.addstr(0, 1, label, DOWNLOAD_COLOR, curses.A_BOLD)
label = "Uploaded (%s/s):" % str_tools.size_label(upload_rates[0], 1)
window.addstr(0, GRAPH_WIDTH + 7, label, UPLOAD_COLOR, curses.A_BOLD)
# draw the graph bounds in KB
max_download_rate = max(download_rates)
max_upload_rate = max(upload_rates)
window.addstr(1, 1, "%4i" % (max_download_rate / 1024), DOWNLOAD_COLOR)
window.addstr(GRAPH_HEIGHT, 1, " 0", DOWNLOAD_COLOR)
window.addstr(1, GRAPH_WIDTH + 7, "%4i" % (max_upload_rate / 1024), UPLOAD_COLOR)
window.addstr(GRAPH_HEIGHT, GRAPH_WIDTH + 7, " 0", UPLOAD_COLOR)
# draw the graph
for col in range(GRAPH_WIDTH):
col_height = GRAPH_HEIGHT * download_rates[col] / max(max_download_rate, 1)
for row in range(col_height):
window.addstr(GRAPH_HEIGHT - row, col + 6, " ", DOWNLOAD_COLOR, curses.A_STANDOUT)
col_height = GRAPH_HEIGHT * upload_rates[col] / max(max_upload_rate, 1)
for row in range(col_height):
window.addstr(GRAPH_HEIGHT - row, col + GRAPH_WIDTH + 12, " ", UPLOAD_COLOR, curses.A_STANDOUT)
window.refresh()
示例7: _print
# 需要导入模块: import curses [as 别名]
# 或者: from curses import A_STANDOUT [as 别名]
def _print(self, left_margin=0):
if not hasattr(self._tree_real_value, 'selected'):
return None
self.left_margin = left_margin
self.parent.curses_pad.bkgdset(' ',curses.A_NORMAL)
self.left_margin += self._print_tree(self.relx)
self.left_margin += self._print_select_controls() + 1
if self.highlight:
self.parent.curses_pad.bkgdset(' ',curses.A_STANDOUT)
super(wgmultilinetree.TreeLine, self)._print()
示例8: _print
# 需要导入模块: import curses [as 别名]
# 或者: from curses import A_STANDOUT [as 别名]
def _print(self, left_margin=0):
self.left_margin = left_margin
self.parent.curses_pad.bkgdset(' ',curses.A_NORMAL)
self.left_margin += self._print_tree(self.relx)
if self.highlight:
self.parent.curses_pad.bkgdset(' ',curses.A_STANDOUT)
super(TreeLine, self)._print()
示例9: print_cursor_pre_unicode
# 需要导入模块: import curses [as 别名]
# 或者: from curses import A_STANDOUT [as 别名]
def print_cursor_pre_unicode(self):
# Cursors do not seem to work on pads.
#self.parent.curses_pad.move(self.rely, self.cursor_position - self.begin_at)
# let's have a fake cursor
_cur_loc_x = self.cursor_position - self.begin_at + self.relx + self.left_margin
# The following two lines work fine for ascii, but not for unicode
#char_under_cur = self.parent.curses_pad.inch(self.rely, _cur_loc_x)
#self.parent.curses_pad.addch(self.rely, self.cursor_position - self.begin_at + self.relx, char_under_cur, curses.A_STANDOUT)
#The following appears to work for unicode as well.
try:
char_under_cur = self.display_value(self.value)[self.cursor_position]
except:
char_under_cur = ' '
self.parent.curses_pad.addstr(self.rely, self.cursor_position - self.begin_at + self.relx + self.left_margin, char_under_cur, curses.A_STANDOUT)
示例10: update
# 需要导入模块: import curses [as 别名]
# 或者: from curses import A_STANDOUT [as 别名]
def update(self, clear=True):
if clear: self.clear()
if self.hidden:
self.clear()
return False
if self.value and self.do_colors():
self.parent.curses_pad.addstr(self.rely, self.relx, '>', self.parent.theme_manager.findPair(self))
self.parent.curses_pad.addstr(self.rely, self.relx+self.width-1, '<', self.parent.theme_manager.findPair(self))
elif self.value:
self.parent.curses_pad.addstr(self.rely, self.relx, '>')
self.parent.curses_pad.addstr(self.rely, self.relx+self.width-1, '<')
if self.editing:
button_state = curses.A_STANDOUT
else:
button_state = curses.A_NORMAL
button_name = self.name
if isinstance(button_name, bytes):
button_name = button_name.decode(self.encoding, 'replace')
button_name = button_name.center(self.label_width)
if self.do_colors():
if self.cursor_color:
if self.editing:
button_attributes = self.parent.theme_manager.findPair(self, self.cursor_color)
else:
button_attributes = self.parent.theme_manager.findPair(self, self.color)
else:
button_attributes = self.parent.theme_manager.findPair(self, self.color) | button_state
else:
button_attributes = button_state
self.add_line(self.rely, self.relx+1,
button_name,
self.make_attributes_list(button_name, button_attributes),
self.label_width
)
示例11: update
# 需要导入模块: import curses [as 别名]
# 或者: from curses import A_STANDOUT [as 别名]
def update(self, clear=True):
if clear: self.clear()
if self.hidden:
self.clear()
return False
if self.hide: return True
if self.value:
cb_display = self.__class__.True_box
else:
cb_display = self.__class__.False_box
if self.do_colors():
self.parent.curses_pad.addstr(self.rely, self.relx, cb_display, self.parent.theme_manager.findPair(self, 'CONTROL'))
else:
self.parent.curses_pad.addstr(self.rely, self.relx, cb_display)
if self.editing:
if self.value:
char_under_cur = 'X'
else:
char_under_cur = ' '
if self.do_colors():
self.parent.curses_pad.addstr(self.rely, self.relx + 1, char_under_cur, self.parent.theme_manager.findPair(self) | curses.A_STANDOUT)
else:
self.parent.curses_pad.addstr(self.rely, self.relx + 1, curses.A_STANDOUT)
示例12: draw
# 需要导入模块: import curses [as 别名]
# 或者: from curses import A_STANDOUT [as 别名]
def draw(self):
"""
Redraws the menu and refreshes the screen. Should be called whenever something changes that needs to be redrawn.
"""
self.screen.border(0)
if self.title is not None:
self.screen.addstr(2, 2, self.title, curses.A_STANDOUT)
if self.subtitle is not None:
self.screen.addstr(4, 2, self.subtitle, curses.A_BOLD)
for index, item in enumerate(self.items):
if self.current_option == index:
text_style = self.highlight
else:
text_style = self.normal
self.screen.addstr(5 + index, 4, item.show(index), text_style)
screen_rows, screen_cols = CursesMenu.stdscr.getmaxyx()
top_row = 0
if 6 + len(self.items) > screen_rows:
if screen_rows + self.current_option < 6 + len(self.items):
top_row = self.current_option
else:
top_row = 6 + len(self.items) - screen_rows
self.screen.refresh(top_row, 0, 0, 0, screen_rows - 1, screen_cols - 1)
示例13: slipnode_name_and_attr
# 需要导入模块: import curses [as 别名]
# 或者: from curses import A_STANDOUT [as 别名]
def slipnode_name_and_attr(self, slipnode):
if slipnode.activation == 100:
return (slipnode.name.upper(), curses.A_STANDOUT)
if slipnode.activation > 50:
return (slipnode.name.upper(), curses.A_BOLD)
else:
return (slipnode.name.lower(), curses.A_NORMAL)
示例14: _setattr
# 需要导入模块: import curses [as 别名]
# 或者: from curses import A_STANDOUT [as 别名]
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)