Allow multiple colors for components
This commit is contained in:
parent
2ede4f5a08
commit
2fc132bdb9
@ -309,7 +309,7 @@ class GraphicalComponent(Component): # abstract class, for future use
|
|||||||
class TopLevelGraphicalComponent(GraphicalComponent): # abstract class
|
class TopLevelGraphicalComponent(GraphicalComponent): # abstract class
|
||||||
# component properties
|
# component properties
|
||||||
designator: Designator = None
|
designator: Designator = None
|
||||||
color: Optional[SingleColor] = None
|
color: Optional[MultiColor] = None
|
||||||
image: Optional[Image] = None
|
image: Optional[Image] = None
|
||||||
additional_components: List[AdditionalComponent] = field(default_factory=list)
|
additional_components: List[AdditionalComponent] = field(default_factory=list)
|
||||||
notes: Optional[MultilineHypertext] = None
|
notes: Optional[MultilineHypertext] = None
|
||||||
@ -367,7 +367,7 @@ class Connector(TopLevelGraphicalComponent):
|
|||||||
|
|
||||||
self.bgcolor = SingleColor(self.bgcolor)
|
self.bgcolor = SingleColor(self.bgcolor)
|
||||||
self.bgcolor_title = SingleColor(self.bgcolor_title)
|
self.bgcolor_title = SingleColor(self.bgcolor_title)
|
||||||
self.color = SingleColor(self.color)
|
self.color = MultiColor(self.color)
|
||||||
|
|
||||||
# connectors do not support custom qty or amount
|
# connectors do not support custom qty or amount
|
||||||
self.qty = NumberAndUnit(1, None)
|
self.qty = NumberAndUnit(1, None)
|
||||||
@ -637,7 +637,7 @@ class Cable(TopLevelGraphicalComponent):
|
|||||||
|
|
||||||
self.bgcolor = SingleColor(self.bgcolor)
|
self.bgcolor = SingleColor(self.bgcolor)
|
||||||
self.bgcolor_title = SingleColor(self.bgcolor_title)
|
self.bgcolor_title = SingleColor(self.bgcolor_title)
|
||||||
self.color = SingleColor(self.color)
|
self.color = MultiColor(self.color)
|
||||||
|
|
||||||
if isinstance(self.image, dict):
|
if isinstance(self.image, dict):
|
||||||
self.image = Image(**self.image)
|
self.image = Image(**self.image)
|
||||||
|
|||||||
@ -450,7 +450,16 @@ def colored_cell(contents, bgcolor) -> Td:
|
|||||||
|
|
||||||
|
|
||||||
def colorbar_cell(color) -> Td:
|
def colorbar_cell(color) -> Td:
|
||||||
return Td("", bgcolor=color.html, width=4)
|
# return Td("", bgcolor=color.html, width=4)
|
||||||
|
cells = [
|
||||||
|
Td(
|
||||||
|
"",
|
||||||
|
bgcolor=subcolor.html,
|
||||||
|
width=8,
|
||||||
|
)
|
||||||
|
for subcolor in color.colors
|
||||||
|
]
|
||||||
|
return Td(Table(Tr(cells), border=0, cellspacing=0), cellspacing=0, cellpadding=0)
|
||||||
|
|
||||||
|
|
||||||
def color_minitable(color: Optional[MultiColor]) -> Union[Table, str]:
|
def color_minitable(color: Optional[MultiColor]) -> Union[Table, str]:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user