diff --git a/laserstudio/__main__.py b/laserstudio/__main__.py index 1561dd8..54ec9bc 100644 --- a/laserstudio/__main__.py +++ b/laserstudio/__main__.py @@ -6,9 +6,10 @@ import sys import yaml import os.path -from .utils.util import resource_path import logging import argparse +from .utils.util import resource_path +from .utils.colors import LedgerColors if __name__ == "__main__": app = QApplication(sys.argv) @@ -42,12 +43,12 @@ palette = QPalette() palette.setColor(QPalette.ColorRole.Window, QColor(25, 25, 25)) palette.setColor(QPalette.ColorRole.WindowText, QColor(240, 240, 240)) - palette.setColor(QPalette.ColorRole.Base, QColor(40, 40, 40)) + palette.setColor(QPalette.ColorRole.Base, QColor(50, 50, 50)) palette.setColor(QPalette.ColorRole.AlternateBase, Qt.GlobalColor.red) palette.setColor(QPalette.ColorRole.ToolTipBase, QColor(25, 25, 25)) palette.setColor(QPalette.ColorRole.ToolTipText, Qt.GlobalColor.white) palette.setColor(QPalette.ColorRole.Text, Qt.GlobalColor.lightGray) - palette.setColor(QPalette.ColorRole.Button, QColor(40, 40, 40)) + palette.setColor(QPalette.ColorRole.Button, QColor(45, 45, 45)) palette.setColor( QPalette.ColorGroup.Disabled, QPalette.ColorRole.Button, QColor(30, 30, 30) ) @@ -59,9 +60,15 @@ ) palette.setColor(QPalette.ColorRole.BrightText, Qt.GlobalColor.red) palette.setColor(QPalette.ColorRole.Link, Qt.GlobalColor.red) - palette.setColor(QPalette.ColorRole.Highlight, QColor(40, 120, 233)) + palette.setColor(QPalette.ColorRole.Highlight, LedgerColors.SafetyOrange.value) palette.setColor(QPalette.ColorRole.HighlightedText, QColor(255, 255, 255)) app.setPalette(palette) + app.setStyleSheet("QToolBar { " + "border: 1px solid #252525;" + "border-radius: 4px;" + "margin: 3px;" + "padding: 6px;" + "background-color: #252525 }") QLocale.setDefault(QLocale.c()) diff --git a/laserstudio/widgets/keyboardbox.py b/laserstudio/widgets/keyboardbox.py index 3909ea5..2322d59 100644 --- a/laserstudio/widgets/keyboardbox.py +++ b/laserstudio/widgets/keyboardbox.py @@ -41,9 +41,11 @@ def __init__(self, stage: StageInstrument, *__args): self.displacement_xy = 100.0 vbox = QVBoxLayout() + vbox.setContentsMargins(0, 0, 0, 0) self.setLayout(vbox) grid = QGridLayout() + grid.setContentsMargins(0, 0, 0, 0) if num_axis > 0: w = QPushButton(Direction.left) w.setFixedWidth(30) @@ -75,16 +77,15 @@ def __init__(self, stage: StageInstrument, *__args): w.setFixedWidth(30) w.pressed.connect(lambda: self.move_stage(Direction.down)) grid.addWidget(w, 2, 2, alignment=Qt.AlignmentFlag.AlignCenter) - grid.setColumnStretch(2, 1) if num_axis > 2: w = QPushButton(Direction.zup) w.setFixedWidth(30) w.pressed.connect(lambda: self.move_stage(Direction.zup)) - grid.addWidget(w, 1, 4) + grid.addWidget(w, 1, 4, alignment=Qt.AlignmentFlag.AlignCenter) w = QPushButton(Direction.zdown) w.setFixedWidth(30) w.pressed.connect(lambda: self.move_stage(Direction.zdown)) - grid.addWidget(w, 2, 4) + grid.addWidget(w, 2, 4, alignment=Qt.AlignmentFlag.AlignCenter) grid.setColumnStretch(4, 1) w = QDoubleSpinBox() @@ -97,9 +98,7 @@ def __init__(self, stage: StageInstrument, *__args): w.setSingleStep(10) grid.addWidget(w, 3, 4) - w = QWidget() - w.setLayout(grid) - vbox.addWidget(w) + vbox.addLayout(grid) self.setFocusPolicy(Qt.FocusPolicy.ClickFocus) diff --git a/laserstudio/widgets/return_line_edit.py b/laserstudio/widgets/return_line_edit.py index e62d83e..adea9ec 100644 --- a/laserstudio/widgets/return_line_edit.py +++ b/laserstudio/widgets/return_line_edit.py @@ -14,7 +14,7 @@ def __init__(self): self.returnPressed.connect(self.reset) def highlight(self): - self.setStyleSheet("background: #344266;") + self.setStyleSheet("background: #b86a45;") def reset(self): self.setStyleSheet("") diff --git a/laserstudio/widgets/toolbars/cameranittoolbar.py b/laserstudio/widgets/toolbars/cameranittoolbar.py index 2f871b8..ce44cb5 100644 --- a/laserstudio/widgets/toolbars/cameranittoolbar.py +++ b/laserstudio/widgets/toolbars/cameranittoolbar.py @@ -45,6 +45,7 @@ def __init__(self, laser_studio: "LaserStudio"): hbox = QHBoxLayout() vbox.addLayout(hbox) hbox.addWidget(QLabel("Gain:")) + vbox.setContentsMargins(0, 0, 0, 0) w = self.hist_low_input = ReturnSpinBox() w.setMinimum(0) w.setMaximum(0xFFFF) diff --git a/laserstudio/widgets/toolbars/cameratoolbar.py b/laserstudio/widgets/toolbars/cameratoolbar.py index abe99a5..071c3ff 100644 --- a/laserstudio/widgets/toolbars/cameratoolbar.py +++ b/laserstudio/widgets/toolbars/cameratoolbar.py @@ -37,8 +37,9 @@ def __init__(self, laser_studio: "LaserStudio"): w = QWidget() self.addWidget(w) - hbox = QHBoxLayout() - w.setLayout(hbox) + grid = QGridLayout() + grid.setContentsMargins(0, 0, 0, 0) + w.setLayout(grid) # Button to toggle off or on the camera image presentation in main viewer w = QPushButton(self) @@ -57,25 +58,23 @@ def __init__(self, laser_studio: "LaserStudio"): QIcon.State.Off, ) w.setIcon(icon) - w.setIconSize(QSize(24, 24)) + w.setIconSize(QSize(16, 16)) w.toggled.connect( lambda b: laser_studio.viewer.stage_sight.__setattr__("show_image", b) ) - hbox.addWidget(w) + grid.addWidget(w, 1, 1) - vbox2 = QVBoxLayout() - hbox.addLayout(vbox2) - w = QPushButton(self) - w.setText("Distortion Wizard") + # Distortion wizard button + w = QPushButton("Distortion Wizard") self.camera_distortion_wizard = CameraDistortionWizard(laser_studio, self) w.clicked.connect(lambda: self.camera_distortion_wizard.show()) - vbox2.addWidget(w) + grid.addWidget(w, 2, 1) + # Probes wizard button self.probes_distortion_wizard = ProbesPositionWizard(laser_studio, self) - w = QPushButton(self) - w.setText("Probes/Spots Position Wizard") + w = QPushButton("Probes/Spots Wizard") w.clicked.connect(lambda: (self.probes_distortion_wizard.show())) - vbox2.addWidget(w) + grid.addWidget(w, 2, 2) w.setHidden( len(laser_studio.instruments.probes) + len(laser_studio.instruments.lasers) == 0 @@ -85,14 +84,11 @@ def __init__(self, laser_studio: "LaserStudio"): stage_sight = StageSight(None, self.camera) w = StageSightViewer(stage_sight) w.setHidden(True) - self.addWidget(w) + grid.addWidget(w, 3, 1, 1, 2) # Refresh interval w = QWidget() - self.addWidget(w) - hbox = QHBoxLayout() - w.setLayout(hbox) - hbox.addWidget(QLabel("Refresh interval:")) + grid.addWidget(QLabel("Refresh interval:"), 3, 1) self.refresh_interval = w = ReturnSpinBox() w.setSuffix("ms") w.setMinimum(20) @@ -106,7 +102,7 @@ def __init__(self, laser_studio: "LaserStudio"): "refresh_interval", self.refresh_interval.value() ) ) - hbox.addWidget(w) + grid.addWidget(w, 3, 2) self.image_dialog = QDialog() self.image_dialog.setWindowTitle("Image Adjustment") @@ -115,7 +111,7 @@ def __init__(self, laser_studio: "LaserStudio"): w.setToolTip(self.image_dialog.windowTitle()) w.setIcon(QIcon(colored_image(":/icons/fontawesome-free/sliders-solid.svg"))) w.clicked.connect(lambda: self.image_dialog.exec()) - self.addWidget(w) + grid.addWidget(w, 1, 2) grid = QGridLayout() # Image adjustment dialog (for USB camera) diff --git a/laserstudio/widgets/toolbars/maintoolbar.py b/laserstudio/widgets/toolbars/maintoolbar.py index 512316a..a161007 100644 --- a/laserstudio/widgets/toolbars/maintoolbar.py +++ b/laserstudio/widgets/toolbars/maintoolbar.py @@ -24,7 +24,7 @@ def __init__(self, laser_studio: "LaserStudio"): w = QLabel() w.setPixmap( QPixmap(resource_path(":/icons/logo.svg")).scaled( - 64, 64, transformMode=Qt.TransformationMode.SmoothTransformation + 32, 32, transformMode=Qt.TransformationMode.SmoothTransformation ) ) w.setAlignment(Qt.AlignmentFlag.AlignCenter) diff --git a/laserstudio/widgets/toolbars/pdmtoolbar.py b/laserstudio/widgets/toolbars/pdmtoolbar.py index d297a99..6122300 100644 --- a/laserstudio/widgets/toolbars/pdmtoolbar.py +++ b/laserstudio/widgets/toolbars/pdmtoolbar.py @@ -5,6 +5,7 @@ QWidget, QSpinBox, QDoubleSpinBox, + QCheckBox, ) from PyQt6.QtCore import Qt, QSize, QVariant from PyQt6.QtGui import QIcon, QPixmap @@ -34,6 +35,8 @@ def __init__(self, laser: PDMInstrument, laser_num: int): self.setFloatable(True) w = self.on_off_button = QPushButton(self) + if self.laser.label is not None: + w.setText(self.laser.label) w.setToolTip("On/Off Laser") w.setCheckable(True) w.setChecked(False) @@ -58,6 +61,7 @@ def __init__(self, laser: PDMInstrument, laser_num: int): self.addWidget(w) grid = QGridLayout() + grid.setContentsMargins(0, 4, 0, 0) row = 0 # Laser pulsed power diff --git a/laserstudio/widgets/toolbars/stagetoolbar.py b/laserstudio/widgets/toolbars/stagetoolbar.py index f73eba6..69610ab 100644 --- a/laserstudio/widgets/toolbars/stagetoolbar.py +++ b/laserstudio/widgets/toolbars/stagetoolbar.py @@ -37,6 +37,7 @@ def __init__(self, laser_studio: "LaserStudio"): w = QWidget() vbox = QVBoxLayout() + vbox.setContentsMargins(0, 0, 0, 0) w.setLayout(vbox) self.addWidget(w) @@ -87,16 +88,8 @@ def __init__(self, laser_studio: "LaserStudio"): hbox.addWidget(w) vbox.addLayout(hbox) - # Keyboard box - self.keyboardbox = w = KeyboardBox(self.stage) - self.addWidget(w) - - w = QWidget() - vbox = QVBoxLayout() - w.setLayout(vbox) - self.addWidget(w) - hbox = QHBoxLayout() + hbox.setContentsMargins(0, 0, 0, 0) vbox.addLayout(hbox) # Move for self.move_for_selector = box = QComboBox() @@ -109,6 +102,10 @@ def __init__(self, laser_studio: "LaserStudio"): hbox.addWidget(QLabel("Focus on:")) hbox.addWidget(box) + # Keyboard box + self.keyboardbox = w = KeyboardBox(self.stage) + vbox.addWidget(w) + # Joysticks self.joystick: Optional[Union[JoystickInstrument, JoystickHIDInstrument]] = None input_dir = os.path.join(os.sep, "dev", "input")