From d67ef723f3c8bbbe8661bf83ee7d2693bb5f42f6 Mon Sep 17 00:00:00 2001
From: Johannes Kung <johku144@student.liu.se>
Date: Thu, 1 Aug 2024 10:18:55 +0200
Subject: [PATCH] Minor documentation

---
 .../gui/module_graphics_item/module_widget.py | 23 ++++++++++++-------
 src/simudator/gui/port_widget.py              |  7 +++++-
 2 files changed, 21 insertions(+), 9 deletions(-)

diff --git a/src/simudator/gui/module_graphics_item/module_widget.py b/src/simudator/gui/module_graphics_item/module_widget.py
index bcb95b4..53bfaf4 100644
--- a/src/simudator/gui/module_graphics_item/module_widget.py
+++ b/src/simudator/gui/module_graphics_item/module_widget.py
@@ -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())
 
diff --git a/src/simudator/gui/port_widget.py b/src/simudator/gui/port_widget.py
index e78ed6c..b35555f 100644
--- a/src/simudator/gui/port_widget.py
+++ b/src/simudator/gui/port_widget.py
@@ -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
 
-- 
GitLab