Skip to content
Snippets Groups Projects
Commit d67ef723 authored by Johannes Kung's avatar Johannes Kung
Browse files

Minor documentation

parent 50f3b25b
No related branches found
No related tags found
1 merge request!45General gui module
Pipeline #134575 failed
......@@ -23,6 +23,11 @@ class ModuleWidget(QGraphicsWidget):
appearance of a module can be customized by changing its properties and
by choosing which state variables to display and in what formats.
The default appearance is a 150x150 rectangle with an outline of width 1
and inner padding set to 5. Text id by default displayed in Sans Serif 9pt.
The default brushes for outline, text and background are the ones provided
by the palette of the widget.
Parameters
----------
module : Module
......@@ -39,8 +44,13 @@ class ModuleWidget(QGraphicsWidget):
Optional window flags for the window of this widget.
"""
_DEFAULT_WIDTH = 50 * 3
_DEFAULT_HEIGHT = 50 * 3
# Used for controlling the default appearance. Make sure these are
# consistent with the class docstring
_DEFAULT_WIDTH = 150
_DEFAULT_HEIGHT = 150
_DEFAULT_OUTLINE_WIDTH = 1
_DEFAULT_TEXT_FONT = QFont("Sans Serif", 9)
_DEFAULT_PADDING = 5
state_changed = pyqtSignal()
......@@ -61,13 +71,12 @@ class ModuleWidget(QGraphicsWidget):
self._port_widgets: list[PortWidget] = []
# Default values for properties for appearance
# TODO: Put these values in constants?
self._outline_width = 1
self._outline_width = self._DEFAULT_OUTLINE_WIDTH
self._outline = self.palette().windowText()
self._background = self.palette().window()
self._text_color = self.palette().windowText().color()
self._text_font = QFont("Sans Serif", 9)
self._padding = 5
self._text_font = self._DEFAULT_TEXT_FONT
self._padding = self._DEFAULT_PADDING
# Set the size of the module depending on the number of state variables
width = self._DEFAULT_WIDTH
......@@ -175,8 +184,6 @@ class ModuleWidget(QGraphicsWidget):
"""
Toggle the visibility of the signal ports of the displayed module.
"""
# TODO: Set the visibility to the same value for all ports rather than
# switching the visibility for each port
for port in self._port_widgets:
port.setVisible(not port.isVisible())
......
......@@ -281,7 +281,12 @@ class PortWidget(QGraphicsWidget):
def line_width(self) -> float:
"""
Return the width of the port line length.
Return the width of the port line.
Returns
-------
float
Port line width.
"""
return self._line_width
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment