当前位置: 首页>>代码示例>>Python>>正文


Python curses.A_NORMAL属性代码示例

本文整理汇总了Python中curses.A_NORMAL属性的典型用法代码示例。如果您正苦于以下问题:Python curses.A_NORMAL属性的具体用法?Python curses.A_NORMAL怎么用?Python curses.A_NORMAL使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在curses的用法示例。


在下文中一共展示了curses.A_NORMAL属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: addstr

# 需要导入模块: import curses [as 别名]
# 或者: from curses import A_NORMAL [as 别名]
def addstr(self, y, x, msg, color = None, attr = curses.A_NORMAL):
    # Curses throws an error if we try to draw a message that spans out of the
    # window's bounds (... seriously?), so doing our best to avoid that.

    if color is not None:
      if color not in self._colors:
        recognized_colors = ", ".join(self._colors.keys())
        raise ValueError("The '%s' color isn't recognized: %s" % (color, recognized_colors))

      attr |= self._colors[color]

    max_y, max_x = self._stdscr.getmaxyx()

    if max_x > x and max_y > y:
      try:
        self._stdscr.addstr(y, x, msg[:max_x - x], attr)
      except:
        pass  # maybe an edge case while resizing the window 
开发者ID:torproject,项目名称:stem,代码行数:20,代码来源:event_listening.py

示例2: _screen_draw_text_line

# 需要导入模块: import curses [as 别名]
# 或者: from curses import A_NORMAL [as 别名]
def _screen_draw_text_line(self, row, line, attr=curses.A_NORMAL, color=None):
    """Render a line of text on the screen.

    Args:
      row: (int) Row index.
      line: (str) The line content.
      attr: curses font attribute.
      color: (str) font foreground color name.

    Raises:
      TypeError: If row is not of type int.
    """

    if not isinstance(row, int):
      raise TypeError("Invalid type in row")

    if len(line) > self._max_x:
      line = line[:self._max_x]

    color_pair = (self._default_color_pair if color is None else
                  self._color_pairs[color])

    self._stdscr.addstr(row, 0, line, color_pair | attr)
    self._screen_refresh() 
开发者ID:ryfeus,项目名称:lambda-packs,代码行数:26,代码来源:curses_ui.py

示例3: _screen_draw_text_line

# 需要导入模块: import curses [as 别名]
# 或者: from curses import A_NORMAL [as 别名]
def _screen_draw_text_line(self, row, line, attr=curses.A_NORMAL, color=None):
    """Render a line of text on the screen.

    Args:
      row: (int) Row index.
      line: (str) The line content.
      attr: curses font attribute.
      color: (str) font foreground color name.

    Raises:
      TypeError: If row is not of type int.
    """

    if not isinstance(row, int):
      raise TypeError("Invalid type in row")

    if len(line) > self._max_x:
      line = line[:self._max_x]

    if color is None:
      self._stdscr.addstr(row, 0, line, attr)
    else:
      self._stdscr.addstr(row, 0, line, self._color_pairs[color])
    self._screen_refresh() 
开发者ID:tobegit3hub,项目名称:deep_image_model,代码行数:26,代码来源:curses_ui.py

示例4: depict_fps

# 需要导入模块: import curses [as 别名]
# 或者: from curses import A_NORMAL [as 别名]
def depict_fps(self):
        w = self.fpsWindow
        now = time.time()
        elapsed = now - self.fpsSince
        fps = self.fpsTicks / elapsed
        if self.fpsGoal is not None:
            seconds_of_work_per_frame = (elapsed / self.fpsTicks) - self.fpsDelay
            desired_time_working_per_second = self.fpsGoal * seconds_of_work_per_frame
            if desired_time_working_per_second < 1.0:
                self.fpsDelay = (1.0 - desired_time_working_per_second) / fps
            else:
                self.fpsDelay = 0
        w.addstr(1, 1, 'FPS:%3d' % fps, curses.A_NORMAL)
        w.refresh()
        self.fpsSince = now
        self.fpsTicks = 0
        self.fpsMeasured = fps 
开发者ID:fargonauts,项目名称:copycat,代码行数:19,代码来源:curses_reporter.py

示例5: depict_workspace_object

# 需要导入模块: import curses [as 别名]
# 或者: from curses import A_NORMAL [as 别名]
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 
开发者ID:fargonauts,项目名称:copycat,代码行数:24,代码来源:curses_reporter.py

示例6: _items

# 需要导入模块: import curses [as 别名]
# 或者: from curses import A_NORMAL [as 别名]
def _items(self):
        """A list of items in the menu represented as dictionaries.

        Overrides method from Menu; see documentation in that class.
        """
        result = []
        for episode in self._filtered_episodes:
            tags = []
            if episode.downloaded:
                tags.append('D')

            result.append({
                'attr': curses.color_pair(5) if episode.played else
                curses.A_NORMAL,
                'tags': tags,
                'text': str(episode)
            })
        return result 
开发者ID:xgi,项目名称:castero,代码行数:20,代码来源:episodemenu.py

示例7: _screen_draw_text_line

# 需要导入模块: import curses [as 别名]
# 或者: from curses import A_NORMAL [as 别名]
def _screen_draw_text_line(self, row, line, attr=curses.A_NORMAL, color=None):
    pass 
开发者ID:abhisuri97,项目名称:auto-alt-text-lambda-api,代码行数:4,代码来源:curses_ui_test.py

示例8: _printyx

# 需要导入模块: import curses [as 别名]
# 或者: from curses import A_NORMAL [as 别名]
def _printyx(self, y: int, x: int, lines, attr=curses.A_NORMAL):
        try:
            for line in lines:
                self.stdscr.insstr(y, x, line, attr)
                y += 1
            return len(lines)
        except Exception as e:
            raise ValueError("%d %d (%d %d)[%s]" % (
                y, x, self.h, self.w, e)) 
开发者ID:robertmuth,项目名称:PyZwaver,代码行数:11,代码来源:example_simple.py

示例9: _print_select_controls

# 需要导入模块: import curses [as 别名]
# 或者: from curses import A_NORMAL [as 别名]
def _print_select_controls(self):
        SELECT_DISPLAY = None
        
        if self._tree_real_value.selectable:
            if self.value.selected:
                SELECT_DISPLAY = self.CAN_SELECT_SELECTED
            else:
                SELECT_DISPLAY = self.CAN_SELECT
        else:
            if self.value.selected:
                SELECT_DISPLAY = self.CANNOT_SELECT_SELECTED
            else:
                SELECT_DISPLAY = self.CANNOT_SELECT
        
        
        if self.do_colors():
            attribute_list = self.parent.theme_manager.findPair(self, 'CONTROL')
        else:
            attribute_list = curses.A_NORMAL
        
        
        #python2 compatibility
        if isinstance(SELECT_DISPLAY, bytes):
            SELECT_DISPLAY = SELECT_DISPLAY.decode()
        
        
        
        self.add_line(self.rely,
                      self.left_margin+self.relx,
                      SELECT_DISPLAY, 
                      self.make_attributes_list(SELECT_DISPLAY, attribute_list),
                      self.width-self.left_margin,
        )
        
        return len(SELECT_DISPLAY) 
开发者ID:hexway,项目名称:apple_bleee,代码行数:37,代码来源:wgmultilinetreeselectable.py

示例10: _print

# 需要导入模块: import curses [as 别名]
# 或者: from curses import A_NORMAL [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() 
开发者ID:hexway,项目名称:apple_bleee,代码行数:15,代码来源:wgmultilinetreeselectable.py

示例11: get_literal_text_and_highlighting_generator

# 需要导入模块: import curses [as 别名]
# 或者: from curses import A_NORMAL [as 别名]
def get_literal_text_and_highlighting_generator(self, start_at=0,):
        # could perform initialization here.
        index = start_at
        string_length = 0
        output = ''
        while string_length <= self.maximum_string_length and len(self.value) > index:
            token_output = self.decode_token(self.value[index])
            if isinstance(token_output, bytes):
                token_output = token_output.decode(self.encoding, 'replace')
            highlighting = [curses.A_NORMAL for c in token_output]
            yield(token_output, highlighting)
            index += 1 
开发者ID:hexway,项目名称:apple_bleee,代码行数:14,代码来源:wgtexttokens.py

示例12: draw_form

# 需要导入模块: import curses [as 别名]
# 或者: from curses import A_NORMAL [as 别名]
def draw_form(self):
        super(FormWithMenus, self).draw_form()
        menu_advert = " " + self.__class__.MENU_KEY + ": Menu "
        y, x = self.display_menu_advert_at()
        if isinstance(menu_advert, bytes):
            menu_advert = menu_advert.decode('utf-8', 'replace')
        self.add_line(y, x, 
            menu_advert, 
            self.make_attributes_list(menu_advert, curses.A_NORMAL),
            self.columns - x - 1
            )

# The following class does not inherit from FormWithMenus and so some code is duplicated.  
# The pig is getting to inherit edit() from ActionForm, but draw_form from FormWithMenus 
开发者ID:hexway,项目名称:apple_bleee,代码行数:16,代码来源:fmFormWithMenus.py

示例13: _print

# 需要导入模块: import curses [as 别名]
# 或者: from curses import A_NORMAL [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() 
开发者ID:hexway,项目名称:apple_bleee,代码行数:9,代码来源:wgmultilinetree.py

示例14: draw_title_and_help

# 需要导入模块: import curses [as 别名]
# 或者: from curses import A_NORMAL [as 别名]
def draw_title_and_help(self):
        try:
            if self.name:
                _title = self.name[:(self.columns-4)]
                _title = ' ' + str(_title) + ' '
                #self.curses_pad.addstr(0,1, ' '+str(_title)+' ')
                if isinstance(_title, bytes):
                    _title = _title.decode('utf-8', 'replace')
                self.add_line(0,1, 
                    _title, 
                    self.make_attributes_list(_title, curses.A_NORMAL),
                    self.columns-4
                    )
        except:
            pass

        if self.help and self.editing:
            try:
                help_advert = " Help: F1 or ^O "
                if isinstance(help_advert, bytes):
                    help_advert = help_advert.decode('utf-8', 'replace')
                self.add_line(
                 0, self.curses_pad.getmaxyx()[1]-len(help_advert)-2, 
                 help_advert,
                 self.make_attributes_list(help_advert, curses.A_NORMAL),
                 len(help_advert)
                 )
            except:
                pass 
开发者ID:hexway,项目名称:apple_bleee,代码行数:31,代码来源:fmForm.py

示例15: display_page_number

# 需要导入模块: import curses [as 别名]
# 或者: from curses import A_NORMAL [as 别名]
def display_page_number(self):
        if not self.display_pages:
            return False
            
        if len(self._pages__) > 1:
            display_text = "%s%s %s %s %s%s" % (
                self.page_info_pre_pages_display,
                self.page_info_pages_name,
                self._active_page + 1,
                self.page_info_out_of,
                len(self._pages__),
                self.page_info_post_pages_display,
            )
        # for python2
            if isinstance(display_text, bytes):
                display_text = display_text.decode('utf-8', 'replace')
        
            maxy,maxx = self.curses_pad.getmaxyx()
        
            if (maxx-5) <= len(display_text):
                # then give up.
                return False
        
            self.add_line(
                maxy - 1,
                maxx - len(display_text) - 2,
                display_text,
                self.make_attributes_list(display_text, 
                     curses.A_NORMAL | self.theme_manager.findPair(self, 
                                                                  self.pages_label_color)),
                maxx - len(display_text) - 2,
            ) 
开发者ID:hexway,项目名称:apple_bleee,代码行数:34,代码来源:fmFormMultiPage.py


注:本文中的curses.A_NORMAL属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。