mirror of
https://github.com/ihabunek/toot.git
synced 2025-02-02 15:07:51 -05:00
Converted LineBoxes to RoundedLineBoxes that look nicer
This commit is contained in:
parent
906cdd013b
commit
bdc0c06fbe
@ -24,7 +24,7 @@ from .poll import Poll
|
||||
from .timeline import Timeline
|
||||
from .utils import get_max_toot_chars, parse_content_links, copy_to_clipboard, ImageCache
|
||||
from PIL import Image
|
||||
from .widgets import ModalBox
|
||||
from .widgets import ModalBox, RoundedLineBox
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@ -806,7 +806,7 @@ class TUI(urwid.Frame):
|
||||
)
|
||||
|
||||
def open_overlay(self, widget, options={}, title=""):
|
||||
top_widget = urwid.LineBox(widget, title=title)
|
||||
top_widget = RoundedLineBox(widget, title=title)
|
||||
bottom_widget = self.body
|
||||
|
||||
_options = self.default_overlay_options.copy()
|
||||
|
@ -3,7 +3,7 @@ import urwid
|
||||
from toot import api
|
||||
from toot.exceptions import ApiError
|
||||
from toot.utils.datetime import parse_datetime
|
||||
from .widgets import Button, CheckBox, RadioButton
|
||||
from .widgets import Button, CheckBox, RadioButton, RoundedLineBox
|
||||
from .richtext import html_to_widgets
|
||||
|
||||
|
||||
@ -27,7 +27,7 @@ class Poll(urwid.ListBox):
|
||||
def build_linebox(self, contents):
|
||||
contents = urwid.Pile(list(contents))
|
||||
contents = urwid.Padding(contents, left=1, right=1)
|
||||
return urwid.LineBox(contents)
|
||||
return RoundedLineBox(contents)
|
||||
|
||||
def vote(self, button_widget):
|
||||
poll = self.status.original.data.get("poll")
|
||||
|
@ -14,10 +14,12 @@ from toot.utils.language import language_name
|
||||
|
||||
from toot.entities import Status
|
||||
from toot.tui.scroll import Scrollable, ScrollBar
|
||||
|
||||
from toot.tui.utils import highlight_keys, get_base_image, can_render_pixels
|
||||
from toot.tui.widgets import SelectableText, SelectableColumns
|
||||
from toot.tui.widgets import SelectableText, SelectableColumns, RoundedLineBox
|
||||
from term_image.widget import UrwidImage
|
||||
|
||||
|
||||
logger = logging.getLogger("toot")
|
||||
screen = urwid.raw_display.Screen()
|
||||
|
||||
@ -533,7 +535,7 @@ class StatusDetails(urwid.Pile):
|
||||
def build_linebox(self, contents):
|
||||
contents = urwid.Pile(list(contents))
|
||||
contents = urwid.Padding(contents, left=1, right=1)
|
||||
return urwid.LineBox(contents)
|
||||
return RoundedLineBox(contents)
|
||||
|
||||
def card_generator(self, card):
|
||||
yield urwid.Text(("card_title", card["title"].strip()))
|
||||
|
@ -75,3 +75,33 @@ class ModalBox(urwid.Frame):
|
||||
filler = urwid.Filler(text, valign='top', top=1, bottom=1)
|
||||
padding = urwid.Padding(filler, left=1, right=1)
|
||||
return super().__init__(padding)
|
||||
|
||||
|
||||
class RoundedLineBox(urwid.LineBox):
|
||||
"""LineBox that defaults to rounded corners."""
|
||||
def __init__(self,
|
||||
original_widget,
|
||||
title="",
|
||||
title_align="center",
|
||||
title_attr=None,
|
||||
tlcorner="\u256d",
|
||||
tline="─",
|
||||
lline="│",
|
||||
trcorner="\u256e",
|
||||
blcorner="\u2570",
|
||||
rline="│",
|
||||
bline="─",
|
||||
brcorner="\u256f",
|
||||
) -> None:
|
||||
return super().__init__(original_widget,
|
||||
title,
|
||||
title_align,
|
||||
title_attr,
|
||||
tlcorner,
|
||||
tline,
|
||||
lline,
|
||||
trcorner,
|
||||
blcorner,
|
||||
rline,
|
||||
bline,
|
||||
brcorner)
|
||||
|
Loading…
x
Reference in New Issue
Block a user