Commit b2066a2c authored by Yannick Kirschhoffer's avatar Yannick Kirschhoffer

Update the Links constructor interface to use two distinct widgets instead of a single root.

parent 5ef1add9
import math
from docker_ascii_map.widget import *
from docker_ascii_map.docker_config import Configuration, Container
from docker_ascii_map.widget import *
def build_container_widget(container: Container, encoding: str) -> Widget:
......@@ -101,7 +100,7 @@ class Renderer:
networks_box = VBox(network_widgets)
bridges_box = VBox(bridge_widgets)
links_box = Links(HBox([bridges_box, networks_box]), links)
links_box = Links(bridges_box, networks_box, links)
# Port mapping
......
......@@ -166,8 +166,8 @@ class Paragraph(Widget):
class Links(Widget):
def __init__(self, root: Widget, links: List[Tuple[Widget, Widget]]):
self._root = root
def __init__(self, left: Widget, right: Widget, links: List[Tuple[Widget, Widget]]):
self._root = HBox([left, right])
self._links = links
def preferred_size(self) -> Size:
......
import unittest
from docker_ascii_map.widget import *
from docker_ascii_map.raster import Boundary
from docker_ascii_map.widget import *
class ModelTests(unittest.TestCase):
......@@ -130,10 +129,11 @@ class ModelTests(unittest.TestCase):
self.maxDiff = None
w1 = Paragraph(['Hello', 'World !'])
w2 = Paragraph(['Hello', 'World !'])
model = Links(HBox([
model = Links(
Padding(w1, Size(4, 1)),
Padding(w2, Size(12, 3))
]), [(w1, w2)])
Padding(w2, Size(12, 3)),
[(w1, w2)]
)
self.assertEqual(
' \n'
......@@ -149,10 +149,11 @@ class ModelTests(unittest.TestCase):
def test_Links_Up(self):
w1 = Paragraph(['Hello', 'World !'])
w2 = Paragraph(['Hello', 'World !'])
model = Links(HBox([
model = Links(
Padding(w1, Size(4, 4)),
Padding(w2, Size(12, 1))
]), [(w1, w2)])
Padding(w2, Size(12, 1)),
[(w1, w2)]
)
self.assertEqual(
' \n'
......@@ -170,10 +171,11 @@ class ModelTests(unittest.TestCase):
def test_Links_Straight(self):
w1 = Paragraph(['Hello', 'World !'])
w2 = Paragraph(['Hello', 'World !'])
model = Links(HBox([
model = Links(
Padding(w1, Size(4, 2)),
Padding(w2, Size(12, 1))
]), [(w1, w2)])
Padding(w2, Size(12, 1)),
[(w1, w2)]
)
self.assertEqual(
' \n'
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment