Skip to content
Snippets Groups Projects
Commit 627639cb authored by Martin's avatar Martin
Browse files

added error msg box to grx and it now handles incorrect input instead of crashing

parent 659d0545
No related branches found
No related tags found
1 merge request!36Grx displays error message instead of crashing
Pipeline #133051 failed
......@@ -185,6 +185,10 @@ class ModuleGraphicsItem(QGraphicsObject, QGraphicsItem):
parsed_value = ast.literal_eval(value)
except SyntaxError as e:
self.errorMessageWidget.showMessage(str(e))
except ValueError as e:
self.errorMessageWidget.showMessage(
"Value Error. Unable to parse input. Make sure it is in the correct base."
)
else:
module_state = self.module.get_state()
module_state[state] = parsed_value
......
......@@ -3,6 +3,7 @@ import math
from qtpy.QtCore import QPointF
from qtpy.QtGui import QPolygonF
from qtpy.QtWidgets import (
QErrorMessage,
QGraphicsLineItem,
QGraphicsPolygonItem,
QGraphicsRectItem,
......@@ -32,6 +33,7 @@ class GrxGraphicsItem(ModuleGraphicsItem):
def __init__(self, module: GRX):
self.register_text_labels = []
self.errorMessageWidget = QErrorMessage()
super().__init__(module)
def draw_graphics_item(self):
......@@ -126,14 +128,18 @@ class GrxGraphicsItem(ModuleGraphicsItem):
)
# Add ports to and from bus
from_bus_port = PortGraphicsItem(self.module.signals["in_input"], Orientation.RIGHT, self)
from_bus_port = PortGraphicsItem(
self.module.signals["in_input"], Orientation.RIGHT, self
)
from_bus_port.setPos(
rect_width + self.LINE_LENGTH + self.MUX_WIDTH,
# Use the buses port margins so the ports align nicely
mux_height / 2 - BusGraphicsItem.PORT_MARGIN / 2,
)
to_bus_port = PortGraphicsItem(self.module.signals["out_content"], Orientation.RIGHT, self)
to_bus_port = PortGraphicsItem(
self.module.signals["out_content"], Orientation.RIGHT, self
)
to_bus_port.setPos(
rect_width + self.LINE_LENGTH + self.MUX_WIDTH,
# Use the buses port margins so the ports align nicely
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment