-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c0d4bbf
commit 44087fe
Showing
4 changed files
with
96 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from . import gui |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
from PyQt6.QtWidgets import QApplication, QStyleFactory | ||
import sys | ||
from PyQt6.QtGui import QIcon, QPalette, QColor | ||
from .util import resource_path | ||
import sys | ||
from .gui import StageWindow | ||
|
||
app = QApplication(sys.argv) | ||
|
||
app.setApplicationName("PyStages") | ||
app.setWindowIcon(QIcon(resource_path(":/icons/logo.png"))) | ||
app.setStyle(QStyleFactory.create("Fusion")) | ||
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.AlternateBase, QColor(255, 0, 0)) | ||
palette.setColor(QPalette.ColorRole.ToolTipBase, QColor(25, 25, 25)) | ||
palette.setColor(QPalette.ColorRole.ToolTipText, QColor(255, 255, 255)) | ||
palette.setColor(QPalette.ColorRole.Text, QColor(200, 200, 200)) | ||
palette.setColor(QPalette.ColorRole.Button, QColor(40, 40, 40)) | ||
palette.setColor( | ||
QPalette.ColorGroup.Disabled, QPalette.ColorRole.Button, QColor(30, 30, 30) | ||
) | ||
palette.setColor(QPalette.ColorRole.ButtonText, QColor(200, 200, 200)) | ||
palette.setColor( | ||
QPalette.ColorGroup.Disabled, QPalette.ColorRole.ButtonText, QColor(100, 100, 100) | ||
) | ||
palette.setColor(QPalette.ColorRole.BrightText, QColor(255, 0, 0)) | ||
palette.setColor(QPalette.ColorRole.Link, QColor(255, 0, 0)) | ||
palette.setColor(QPalette.ColorRole.Highlight, QColor(40, 120, 233)) | ||
palette.setColor(QPalette.ColorRole.HighlightedText, QColor(255, 255, 255)) | ||
app.setPalette(palette) | ||
|
||
win = StageWindow() | ||
win.show() | ||
sys.exit(app.exec()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#!/bin/python3 | ||
from PyQt6.QtWidgets import QWidget, QHBoxLayout, QLabel, QComboBox, QPushButton | ||
from ..cncrouter import CNCRouter | ||
from ..corvus import Corvus | ||
from ..smc100 import SMC100 | ||
from ..stage import Stage | ||
from enum import StrEnum | ||
|
||
|
||
class StageType(StrEnum): | ||
CNC = "CNC" | ||
Corvus = "Corvus" | ||
SMC = "SMC100" | ||
|
||
|
||
class StageWindow(QWidget): | ||
def connect(self, on_off): | ||
print(on_off, selected := self.stage_selection.currentText()) | ||
if on_off: | ||
# Instanciate stage according to current stage selection | ||
if selected == StageType.CNC: | ||
self.stage = CNCRouter() | ||
elif selected == StageType.Corvus: | ||
self.stage = Corvus() | ||
elif selected == StageType.SMC: | ||
self.stage = SMC100() | ||
|
||
def __init__(self): | ||
super().__init__() | ||
|
||
# Current stage | ||
self.stage: Stage = None | ||
|
||
box = QHBoxLayout() | ||
w = QLabel("Stage Selection") | ||
box.addWidget(w) | ||
self.stage_selection = w = QComboBox() | ||
w.addItems([StageType.CNC, StageType.Corvus, StageType.SMC]) | ||
|
||
box.addWidget(w) | ||
self.setLayout(box) | ||
|
||
self.connect_button = w = QPushButton("Connect") | ||
w.setCheckable(True) | ||
w.clicked.connect(self.connect) | ||
box.addWidget(w) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import os | ||
|
||
__dirname = os.path.dirname(os.path.realpath(__file__)) | ||
|
||
|
||
def resource_path(path: str) -> str: | ||
""" | ||
Transforms a .":/path/to/file" path to the relative path from the main script | ||
""" | ||
if not path.startswith(":/"): | ||
return path | ||
return os.path.join(__dirname, path[2:]) |