diff options
-rw-r--r-- | src/ui.py | 16 |
1 files changed, 12 insertions, 4 deletions
@@ -50,6 +50,13 @@ class ElementEditorWindow(QMainWindow): win.show() ElementEditorWindow.windows.append(win) + @staticmethod + def close_all(pol=None): + for win in ElementEditorWindow.windows: + if pol is None or pol == win.pol: + win.close() + del(win) + def __init__(self, pol): super().__init__(flags=Qt.Dialog) self.pol = pol @@ -168,7 +175,7 @@ class OptBox(QVBoxLayout): self.addWidget(self.enable) # Angle - self.angle = AngleSlider("Angle") + self.angle = AngleSlider() self.angle.setValue(pol.angle * 180 / np.pi) self.angle.on_change = lambda: TableRow.angle_change(row) self.addLayout(self.angle) @@ -310,10 +317,12 @@ def half_assed_element_creation(index=None): GUI.table_frame = QFrame() GUI.table_frame.setLayout(GUI.table) GUI.scroll.setWidget(GUI.table_frame) + ElementEditorWindow.open(pol) update() def half_assed_clear(): + ElementEditorWindow.close_all() system.elements = list() populate_table() GUI.table_frame = QFrame() @@ -322,8 +331,7 @@ def half_assed_clear(): update() def half_assed_element_deletion(index): - del(system.elements[index]) - + ElementEditorWindow.close_all(pol=system.elements[pol]) populate_table() GUI.table_frame = QFrame() GUI.table_frame.setLayout(GUI.table) @@ -394,7 +402,7 @@ def setup_menubar(win): # System add = QAction("&Add a new element", win) add.setShortcut("Ctrl+N") - add.triggered.connect(half_assed_element_creation) + add.triggered.connect(lambda: half_assed_element_creation()) clear = QAction("&Remove all elements", win) clear.triggered.connect(half_assed_clear) |