-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_widget_stage.py
More file actions
70 lines (49 loc) · 2.08 KB
/
test_widget_stage.py
File metadata and controls
70 lines (49 loc) · 2.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
import sys
from PyQt5.QtWidgets import QApplication, QWidget, QLabel, QVBoxLayout, QMainWindow, QSlider, QPushButton, QMessageBox
from PyQt5.QtGui import QPainter, QColor
from PyQt5.QtCore import Qt, QSize, pyqtSignal, QThread
from hardware import AttoCom,DummyStage
from gui import StageWidget, IconProvider
from core.utils import create_dark_iconoir
import qtmodern.styles
# def custom_assert_handler(exc_type, exc_value, exc_traceback):
# if exc_type == AssertionError:
# app = QApplication.instance() or QApplication(sys.argv) # Ensure QApplication exists
# QMessageBox.critical(None, "Assertion Failed", str(exc_value))
# sys.exit(1) # Optional: exit the app after showing the message box
# # Override default exception handler
# sys.excepthook = custom_assert_handler
# import qdarkstyle
class MainWindow(QMainWindow):
def __init__(self):
super().__init__()
self.setWindowTitle("Stage")
# Main central widget
main_widget = QWidget(self)
layout = QVBoxLayout()
#self.stage_driver = AttoCom(com_port='COM5')
self.stage_driver = DummyStage('AttoCube')
self.stage_driver.show_commands = True
self.stage_driver.set_mode_mixed()
self.stage_driver.positioning_fine_absolute(1,75)
self.stage_driver.positioning_fine_absolute(2,75)
self.stage_driver.positioning_fine_absolute(3,75)
stage_widget = StageWidget(self.stage_driver,self.stage_driver.name)
layout.addWidget(stage_widget)
main_widget.setLayout(layout)
self.setCentralWidget(main_widget)
def __del__(self):
self.stage_driver.free()
create_dark_iconoir()
app = QApplication.instance() # Check if QApplication is already running
if not app:
app = QApplication(sys.argv)
qtmodern.styles.dark(app)
# app.setStyleSheet(qdarkstyle.load_stylesheet_pyqt5())
# app.setStyleSheet(qdarkstyle.load_stylesheet(qt_api='pyqt5'))
icon_prov = IconProvider()
icon_prov.load_dark_mode()
window = MainWindow()
window.show()
app.exec_()
# %%