示例#1
0
 def add_child(self, child, start_num=None):
     if not isinstance(child, Dom):
         raise pycurses.error('child must be dom.')
     if start_num is None:
         self.context.append(child)
     else:
         if not isinstance(start_num, int):
             raise pycurses.error('child_num must be int.')
         self.context.insert(start_num, child)
示例#2
0
 def add_child(self, child, start_num=None):
     child = str(child) if isinstance(child, int) else child
     if not isinstance(child, str):
         raise pycurses.error('span\'s child must be str.')
     if start_num is None:
         self.context = self.context + child
     else:
         if not isinstance(start_num, int):
             raise pycurses.error('child_num must be int.')
         self.context = self.context[:start_num] + child + self.context[
             start_num:]
示例#3
0
 def __init__(self,
              name='',
              context='',
              position=doms.POSITION_STATIC,
              begin_top=None,
              begin_left=None,
              display=doms.DISPLAY_INLINE,
              width='100%',
              height='100%',
              padding=(0, 0, 0, 0),
              margin=(0, 0, 0, 0),
              text_blink=doms.CSS_UNSET,
              text_decoration=doms.CSS_UNSET,
              text_align=doms.TEXT_ALIGN_LEFT,
              font_weight=doms.FONT_WEIGHT_NORMAL,
              color=pairs.PAIR_THEME_FONT):
     context = str(context) if isinstance(context, int) else context
     if not isinstance(context, str):
         raise pycurses.error('span\'s context must be str.')
     super().__init__(kind=doms.DOM_KIND_SPAN,
                      name=name,
                      context=context,
                      position=position,
                      begin_top=begin_top,
                      begin_left=begin_left,
                      display=display,
                      width=width,
                      height=height,
                      padding=padding,
                      margin=margin,
                      text_blink=text_blink,
                      text_decoration=text_decoration,
                      text_align=text_align,
                      font_weight=font_weight,
                      color=color)
示例#4
0
 def show(self, target=None, parent=None):
     window = Window(height=10, width=20, begin_top=20, begin_left=40)
     # window = pycurses.newwin(10, 20, 20, 20)
     for x in self.context:
         if not isinstance(x, Dom):
             raise pycurses.error('dom\'s context must be dom.')
         x.show(target=window, parent=self)
     window.refresh()
示例#5
0
 def init_color():
     # curses provide 256 colors, if you want to replace it
     # 1. assess can_change_color
     # 2. select nearest color from constant.colors, replace it to the color you want
     # 3. and use this func when initialize
     # if pycurses.can_change_color():
     #     pycurses.init_rgb_color_255(colors.GREY_808080, 0, 43, 54)
     raise pycurses.error('rewrite it.')
示例#6
0
 def show(self, target=None, parent=None):
     for x in self.context:
         if not isinstance(x, Dom):
             raise pycurses.error('dom\'s context must be dom.')
         x.show(target=target, parent=self)
     target.refresh()
示例#7
0
 def del_child(self, child_num):
     if not isinstance(child_num, int):
         raise pycurses.error('child_num must be int.')
     self.context = self.context.replace(child_num, "", 1)