summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaweł Redman <pawel.redman@gmail.com>2019-05-01 12:17:01 +0200
committerPaweł Redman <pawel.redman@gmail.com>2019-05-01 12:17:01 +0200
commitd39c23895857ef9ae8080ddd125e845eaa1c8aa3 (patch)
tree425658fdbfb8cca9a72d530245a48ebd1dd1786e
parent8f4c3bdff4f15dd16458f16aa751d9f75e2f21c6 (diff)
Optbox improvements
-rw-r--r--src/main.py5
-rw-r--r--src/ui.py42
2 files changed, 28 insertions, 19 deletions
diff --git a/src/main.py b/src/main.py
index df90be5..3997835 100644
--- a/src/main.py
+++ b/src/main.py
@@ -3,9 +3,10 @@ from PyQt5.QtWidgets import *
from PyQt5.QtGui import *
from PyQt5.QtCore import *
-import ui, phys, io
+import ui, phys, file
-system = phys.System()
+#system = phys.System()
+system = file.open_system("3.woz")
class Window(QMainWindow):
def __init__(self):
diff --git a/src/ui.py b/src/ui.py
index d58ab3a..4f6b189 100644
--- a/src/ui.py
+++ b/src/ui.py
@@ -50,8 +50,8 @@ class OptBox(QVBoxLayout):
self.addWidget(self.name)
# Type / Enable box
- self.hbox = QHBoxLayout()
- self.addLayout(self.hbox)
+ box = QHBoxLayout()
+ self.addLayout(box)
# Type combo
self.type = QComboBox()
@@ -59,19 +59,17 @@ class OptBox(QVBoxLayout):
self.type.addItem("Quarterwave plate", "quarterwave")
self.type.setCurrentIndex(0 if pol.type == "linear" else 1)
self.type.currentIndexChanged.connect(lambda : TableRow.type_change(row))
- self.hbox.addWidget(self.type)
+ box.addWidget(self.type)
# Enable checkbox
self.enable = QCheckBox("Enable")
self.enable.setChecked(True)
self.enable.stateChanged.connect(update)
- self.hbox.addWidget(self.enable)
+ box.addWidget(self.enable)
- # Delta angle
- self.delta = AngleSlider("Delta")
- self.delta.setValue(pol.delta * 180 / np.pi)
- self.delta.on_change = lambda: TableRow.angle_change(row)
- self.addLayout(self.delta)
+ # Delta / Reference layout
+ box = QHBoxLayout()
+ self.addLayout(box)
# Angle reference
self.ref = QComboBox()
@@ -79,13 +77,20 @@ class OptBox(QVBoxLayout):
for i, _ in enumerate(system.elements):
if i >= rownum - 1:
continue
- self.ref.addItem("Relative to element #%d" % (i + 1), i)
+ self.ref.addItem("Relative to #%d" % (i + 1), i)
if row.ref is not False and i == row.ref:
self.ref.setCurrentIndex(row.ref + 1)
self.ref.currentIndexChanged.connect(update)
- self.addWidget(self.ref)
+ box.addWidget(self.ref)
+
+ # Delta angle
+ box.addWidget(QLabel("Delta"))
+ self.delta = QLineEdit("0")
+ self.delta.textChanged.connect(lambda: TableRow.angle_change(row))
+ box.addWidget(self.delta)
+ box.addWidget(QLabel("°"))
# Angle
self.angle = AngleSlider("Angle")
@@ -102,11 +107,11 @@ class OptBox(QVBoxLayout):
self.delete = QPushButton("Delete")
self.delete.clicked.connect(lambda: half_assed_element_deletion(rownum - 1))
- self.buttons = QHBoxLayout()
- self.buttons.addWidget(self.add_above)
- self.buttons.addWidget(self.add_below)
- self.buttons.addWidget(self.delete)
- self.addLayout(self.buttons)
+ box = QHBoxLayout()
+ box.addWidget(self.add_above)
+ box.addWidget(self.add_below)
+ box.addWidget(self.delete)
+ self.addLayout(box)
@@ -140,7 +145,10 @@ class TableRow:
@staticmethod
def angle_change(row):
row.angle = row.optbox.angle.angle / 180 * np.pi
- row.delta = row.optbox.delta.angle / 180 * np.pi
+ try:
+ row.delta = float(row.optbox.delta.text()) / 180 * np.pi
+ except ValueError:
+ pass
update()
@staticmethod