當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。