Skip to content
Snippets Groups Projects

Fixed save/load, sfg creating, simulation, bug fixes

Merged Jacob Wahlman requested to merge gui-bug-fixes into develop
1 file
+ 9
2
Compare changes
  • Side-by-side
  • Inline
from PySide2.QtWidgets import QDialog, QLineEdit, QPushButton, QVBoxLayout, QHBoxLayout,\
QLabel, QCheckBox, QGridLayout
from PySide2.QtCore import Qt
from PySide2.QtGui import QIntValidator
from PySide2.QtGui import QDoubleValidator
class PropertiesWindow(QDialog):
def __init__(self, operation, main_window):
@@ -22,13 +22,17 @@ class PropertiesWindow(QDialog):
self.vertical_layout = QVBoxLayout()
self.vertical_layout.addLayout(self.name_layout)
if self.operation.operation_path_name == "c":
if hasattr(self.operation.operation, "value") or hasattr(self.operation.operation, "initial_value"):
self.constant_layout = QHBoxLayout()
self.constant_layout.setSpacing(50)
self.constant_value = QLabel("Constant:")
self.edit_constant = QLineEdit(str(self.operation.operation.value))
self.only_accept_int = QIntValidator()
self.edit_constant.setValidator(self.only_accept_int)
self.constant_value = QLabel("Value:")
if hasattr(self.operation.operation, "value"):
self.edit_constant = QLineEdit(str(self.operation.operation.value))
else:
self.edit_constant = QLineEdit(str(self.operation.operation.initial_value))
self.only_accept_float = QDoubleValidator()
self.edit_constant.setValidator(self.only_accept_float)
self.constant_layout.addWidget(self.constant_value)
self.constant_layout.addWidget(self.edit_constant)
self.vertical_layout.addLayout(self.constant_layout)
@@ -66,7 +70,7 @@ class PropertiesWindow(QDialog):
input_value.setPlaceholderText(str(self.operation.operation.latency))
except ValueError:
input_value.setPlaceholderText("-1")
int_valid = QIntValidator()
int_valid = QDoubleValidator()
int_valid.setBottom(-1)
input_value.setValidator(int_valid)
input_value.setFixedWidth(50)
@@ -101,7 +105,7 @@ class PropertiesWindow(QDialog):
input_value.setPlaceholderText(str(self.operation.operation.latency))
except ValueError:
input_value.setPlaceholderText("-1")
int_valid = QIntValidator()
int_valid = QDoubleValidator()
int_valid.setBottom(-1)
input_value.setValidator(int_valid)
input_value.setFixedWidth(50)
@@ -122,9 +126,13 @@ class PropertiesWindow(QDialog):
def save_properties(self):
self._window.logger.info(f"Saving properties of operation: {self.operation.name}.")
self.operation.name = self.edit_name.text()
self.operation.operation.name = self.edit_name.text()
self.operation.label.setPlainText(self.operation.name)
if self.operation.operation_path_name == "c":
self.operation.operation.value = int(self.edit_constant.text())
if hasattr(self.operation.operation, "value"):
self.operation.operation.value = float(self.edit_constant.text().replace(",", "."))
elif hasattr(self.operation.operation, "initial_value"):
self.operation.operation.initial_value = float(self.edit_constant.text().replace(",", "."))
if self.check_show_name.isChecked():
self.operation.label.setOpacity(1)
self.operation.is_show_name = True
@@ -132,6 +140,6 @@ class PropertiesWindow(QDialog):
self.operation.label.setOpacity(0)
self.operation.is_show_name = False
self.operation.operation.set_latency_offsets({port: int(self.latency_fields[port].text()) if self.latency_fields[port].text() and int(self.latency_fields[port].text()) > 0 else None for port in self.latency_fields})
self.operation.operation.set_latency_offsets({port: float(self.latency_fields[port].text().replace(",", ".")) if self.latency_fields[port].text() and float(self.latency_fields[port].text().replace(",", ".")) > 0 else None for port in self.latency_fields})
self.reject()
\ No newline at end of file
Loading