summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaweł Redman <pawel.redman@gmail.com>2019-05-02 19:33:40 +0200
committerPaweł Redman <pawel.redman@gmail.com>2019-05-02 19:33:40 +0200
commitb35ade41339ea95ec3c59eb45b813273304682e7 (patch)
treefdfdd9cfc7f39d04cbf0bf4866d0ad0ad20e9061
parent54c1daf63553578ec6272ce42563ad5b291dc896 (diff)
Close edition windows when deleting an element
-rw-r--r--src/ui.py16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/ui.py b/src/ui.py
index 84322b6..33da1ea 100644
--- a/src/ui.py
+++ b/src/ui.py
@@ -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)