def __init__(self, content, width=None, height=None, report_write_position_callback=None): assert is_dimension(width) assert is_dimension(height) assert report_write_position_callback is None or callable(report_write_position_callback) self.content = to_container(content) self.width = width self.height = height self.report_write_position_callback = report_write_position_callback
def __init__(self, content, width=None, height=None, report_write_position_callback=None): assert is_dimension(width) assert is_dimension(height) assert report_write_position_callback is None or callable( report_write_position_callback) self.content = to_container(content) self.width = width self.height = height self.report_write_position_callback = report_write_position_callback
def __init__(self, body, title='', style='', width=None, height=None, key_bindings=None, modal=False): assert is_container(body) assert is_formatted_text(title) assert isinstance(style, six.text_type) assert is_dimension(width) assert is_dimension(height) assert key_bindings is None or isinstance(key_bindings, KeyBindings) assert isinstance(modal, bool) fill = partial(Window, style='class:frame.border') style = 'class:frame ' + style if title: top_row = VSplit([ fill(width=1, height=1, char=Border.TOP_LEFT), fill(char=Border.HORIZONTAL), fill(width=1, height=1, char='|'), Label(Template(' {} ').format(title), style='class:frame.label', dont_extend_width=True), fill(width=1, height=1, char='|'), fill(char=Border.HORIZONTAL), fill(width=1, height=1, char=Border.TOP_RIGHT), ], height=1) else: top_row = VSplit([ fill(width=1, height=1, char=Border.TOP_LEFT), fill(char=Border.HORIZONTAL), fill(width=1, height=1, char=Border.TOP_RIGHT), ], height=1) self.container = HSplit( [ top_row, VSplit( [ fill(width=1, char=Border.VERTICAL), body, fill(width=1, char=Border.VERTICAL), # Padding is required to make sure that if the content is # too small, that the right frame border is still aligned. ], padding=0), VSplit([ fill(width=1, height=1, char=Border.BOTTOM_LEFT), fill(char=Border.HORIZONTAL), fill(width=1, height=1, char=Border.BOTTOM_RIGHT), ]), ], width=width, height=height, style=style, key_bindings=key_bindings, modal=modal)
def __init__(self, body, title='', style='', width=None, height=None, key_bindings=None, modal=False): assert is_container(body) assert is_formatted_text(title) assert isinstance(style, six.text_type) assert is_dimension(width) assert is_dimension(height) assert key_bindings is None or isinstance(key_bindings, KeyBindings) assert isinstance(modal, bool) self.title = title self.body = body fill = partial(Window, style='class:frame.border') style = 'class:frame ' + style top_row_with_title = VSplit( [ fill(width=1, height=1, char=Border.TOP_LEFT), fill(char=Border.HORIZONTAL), fill(width=1, height=1, char='|'), # Notice: we use `Template` here, because `self.title` can be an # `HTML` object for instance. Label(lambda: Template(' {} ').format(self.title), style='class:frame.label', dont_extend_width=True), fill(width=1, height=1, char='|'), fill(char=Border.HORIZONTAL), fill(width=1, height=1, char=Border.TOP_RIGHT), ], height=1) top_row_without_title = VSplit([ fill(width=1, height=1, char=Border.TOP_LEFT), fill(char=Border.HORIZONTAL), fill(width=1, height=1, char=Border.TOP_RIGHT), ], height=1) @Condition def has_title(): return bool(self.title) self.container = HSplit( [ ConditionalContainer(content=top_row_with_title, filter=has_title), ConditionalContainer(content=top_row_without_title, filter=~has_title), VSplit( [ fill(width=1, char=Border.VERTICAL), DynamicContainer(lambda: self.body), fill(width=1, char=Border.VERTICAL), # Padding is required to make sure that if the content is # too small, that the right frame border is still aligned. ], padding=0), VSplit([ fill(width=1, height=1, char=Border.BOTTOM_LEFT), fill(char=Border.HORIZONTAL), fill(width=1, height=1, char=Border.BOTTOM_RIGHT), ]), ], width=width, height=height, style=style, key_bindings=key_bindings, modal=modal)
def __init__(self, body, title='', style='', width=None, height=None, key_bindings=None, modal=False): assert is_container(body) #assert is_formatted_text(title) assert isinstance(style, six.text_type) assert is_dimension(width) assert is_dimension(height) assert key_bindings is None or isinstance(key_bindings, KeyBindings) assert isinstance(modal, bool) self.title = title self.body = body fill = partial(Window, style='class:frame.border') style = 'class:frame ' + style top_row_with_title = VSplit([ fill(width=1, height=1, char=Border.TOP_LEFT), fill(char=Border.HORIZONTAL), fill(width=1, height=1, char='|'), # Notice: we use `Template` here, because `self.title` can be an # `HTML` object for instance. Label(lambda: Template(' {} ').format(self.title), style='class:frame.label', dont_extend_width=True), fill(width=1, height=1, char='|'), fill(char=Border.HORIZONTAL), fill(width=1, height=1, char=Border.TOP_RIGHT), ], height=1) top_row_without_title = VSplit([ fill(width=1, height=1, char=Border.TOP_LEFT), fill(char=Border.HORIZONTAL), fill(width=1, height=1, char=Border.TOP_RIGHT), ], height=1) @Condition def has_title(): return bool(self.title) self.container = HSplit([ ConditionalContainer( content=top_row_with_title, filter=has_title), ConditionalContainer( content=top_row_without_title, filter= has_title), # VSplit([ fill(width=1, char=Border.VERTICAL), DynamicContainer(lambda: self.body), fill(width=1, char=Border.VERTICAL), # Padding is required to make sure that if the content is # too small, that the right frame border is still aligned. ], padding=0), VSplit([ fill(width=1, height=1, char=Border.BOTTOM_LEFT), fill(char=Border.HORIZONTAL), fill(width=1, height=1, char=Border.BOTTOM_RIGHT), ]), ], width=width, height=height, style=style, key_bindings=key_bindings, modal=modal)