Skip to content
Snippets Groups Projects
Commit e0041d36 authored by Andreas Bolin's avatar Andreas Bolin
Browse files

workspace dump

parent ca210f50
No related branches found
No related tags found
1 merge request!78Add scheduler GUI
Pipeline #72611 passed
......@@ -2,4 +2,5 @@
Graphical user interface for B-ASIC scheduler.
"""
from b_asic.schedule-gui.main_window import *
\ No newline at end of file
from b_asic.schedule-gui.main_window import *
from b_asic.schedule-gui.schedule import *
\ No newline at end of file
"""B-ASIC Schedule-gui Module.
"""B-ASIC Scheduler-gui Module.
Contains the schedule-gui class for scheduling operations in an SFG.
Contains the scheduler-gui class for scheduling operations in an SFG.
"""
# This Python file uses the following encoding: utf-8
import os
#from pathlib import Path
from pathlib import Path
import sys
from typing import Any
#from matplotlib.pyplot import bar
#from diagram import *
from qtpy import QtCore, QtGui, QtWidgets
from qtpy import uic, QtCore, QtGui, QtWidgets
from qtpy.QtCore import Qt, Slot
from qtpy.QtWidgets import QApplication, QMainWindow, QMessageBox
from PyQt5.uic import compileUi as comp
# QPainter imports
from qtpy.QtWidgets import QGraphicsView, QGraphicsScene
......@@ -21,14 +22,34 @@ from qtpy.QtGui import (
QPaintEvent, QPainter, QPainterPath, QColor, QBrush, QPen, QFont, QPolygon,
QLinearGradient)
if __debug__:
argv = sys.orig_argv
argv.insert(1, '-O')
argv = ' '.join(argv)
print("DEBUG: Running in debug mode. To disable, start program with: '" + argv + "'")
if __debug__:
def _map_func(dir: str, file: str) -> tuple[str, str]:
file_base,_ = os.path.splitext(file)
print('DEBUG: Compile \'' + file_base + '.ui\' to \'' + os.getcwd() + '/ui/' + file_base + '_ui.py\'...')
return (dir+'/ui/', file_base+'_ui.py')
uic.compileUiDir('.', False, _map_func)
from ui.main_window_ui import Ui_MainWindow
class MainWindow(QMainWindow):
"""Schedule of an SFG with scheduled Operations."""
_ui: QMainWindow # <class '__main__.Ui_MainWindow'>
_widget: QMainWindow # <class 'PyQt5.QtWidgets.QMainWindow'>
#_ui: QMainWindow # <class '__main__.Ui_MainWindow'>
#_widget: QMainWindow # <class 'PyQt5.QtWidgets.QMainWindow'>
ui = Ui_MainWindow() # DEBUG, remove later
def __init__(self):
"""Construct a Schedule from an SFG and show it in the UI."""
super(MainWindow, self).__init__()
self._init_ui()
self._init_graphics_view()
......@@ -36,10 +57,7 @@ class MainWindow(QMainWindow):
def _init_ui(self):
QT_API = os.environ.get('QT_API')
print("QT_API: " + QT_API)
from qtpy import uic
#uic.compileUiDir('.', False, \
# lambda dir, file : [dir+str('/ui/'), str('ui_')+file],)
# self._ui = uic.loadUi("main_window.ui", None) # Load the .ui file
# #self._ui.setupUi(self)
......@@ -52,22 +70,30 @@ class MainWindow(QMainWindow):
# self._ui.menu_node_info.triggered.connect(self.toggle_node_info)
# self._ui.show()
uic.loadUi("main_window.ui", self) # Load the .ui file
if __debug__:
self.ui = Ui_MainWindow()
self.ui.setupUi(self)
print(type(self.ui))
else:
uic.loadUi("main_window.ui", self) # Load the .ui file
self.pushbutton_add.clicked.connect(self.callback_pushButton)
self.menu_load_sfg.triggered.connect(self.load_sfg)
self.menu_save_schedule.triggered.connect(self.save_schedule)
self.menu_quit.triggered.connect(self.close)
self.menu_node_info.triggered.connect(self.toggle_node_info)
self.show()
#self.show()
#print('self:\t\t' + str(type(self)))
def _init_graphics_view(self):
self.scene = QGraphicsScene(self)
self.graphic_view = QGraphicsView(self.scene, self)
self.graphic_view.setRenderHint(QPainter.Antialiasing)
self.graphic_view.setGeometry(20, 20, self.width(), self.height())
self.graphic_view.setDragMode(QGraphicsView.RubberBandDrag)
print(self.ui.centralwidget.baseSize())
@Slot()
......@@ -108,7 +134,7 @@ class MainWindow(QMainWindow):
def start_gui():
app = QApplication(sys.argv)
window = MainWindow()
#window.show()
window.show()
sys.exit(app.exec_())
if __name__ == "__main__":
......
......@@ -112,7 +112,7 @@
<x>0</x>
<y>0</y>
<width>800</width>
<height>20</height>
<height>22</height>
</rect>
</property>
<widget class="QMenu" name="menuFile">
......
This diff is collapsed.
from qtpy import QtCore, QtGui, QtWidgets
from schedule import Schedule
from scheduler import Scheduler
app = QtWidgets.QApplication([])
schedule = Schedule()
schedule = Scheduler()
schedule.show()
app.exec_()
\ No newline at end of file
"""B-ASIC Schedule-gui Schedule Module.
Contains the Schedule class for painting an schedule.
"""
# This Python file uses the following encoding: utf-8
from qtpy import QtCore
#from qtpy import QtGui
from qtpy import QtWidgets
from qtpy.QtCore import Qt
from qtpy.QtGui import (
QPaintEvent, QPainter, QPainterPath, QColor, QBrush, QPen, QFont, QPolygon,
QLinearGradient)
class _Component(QtWidgets.QWidget):
"""Contains the Component of each hardware block of an Scheduler."""
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.setSizePolicy(
QtWidgets.QSizePolicy.MinimumExpanding,
QtWidgets.QSizePolicy.MinimumExpanding
)
def sizeHint(self) -> QtCore.QSize:
return QtCore.QSize(40,120)
def paintEvent(self, e) -> None:
painter = QPainter(self)
pen = QPen()
pen.setColor(Qt.green)
pen.setWidth(10)
painter.setPen(pen)
#brush.setStyle(Qt.SolidPattern)
#rect = QtCore.QRect(0, 0, painter.device().width(), painter.device().height())
#painter.fillRect(rect, brush)
painter.drawRect(0, 0, painter.device().width(), painter.device().height())
# QPaintEvent is a class
class Scheduler(QtWidgets.QWidget):
"""Contains the the Scheduler painter widget placed in MainWindow."""
_antialiasing: bool = False
_component: _Component = []
def __init__(self, *args, **kwargs):
super(Scheduler, self).__init__(*args, **kwargs)
layout = QtWidgets.QVBoxLayout()
self._component.append(_Component())
self._component.append(_Component())
layout.addWidget(self._component[0])
layout.addWidget(self._component[1])
self.setLayout(layout)
def add_component(self) -> None:
pass
from qtpy import QtGui
from qtpy.QtWidgets import QApplication, QMainWindow
import sys
from qtpy.QtGui import QPainter, QBrush, QPen
from qtpy.QtCore import Qt
class Window(QMainWindow):
def __init__(self):
super().__init__()
self.title = "PyQt5 Drawing Tutorial"
self.top= 150
self.left= 150
self.width = 500
self.height = 500
self.InitWindow()
def InitWindow(self):
self.setWindowTitle(self.title)
self.setGeometry(self.top, self.left, self.width, self.height)
self.show()
def paintEvent(self, event):
painter = QPainter(self)
painter.setPen(QPen(Qt.green, 8, Qt.SolidLine))
painter.setBrush(QBrush(Qt.red, Qt.SolidPattern))
painter.drawEllipse(40, 40, 400, 400)
App = QApplication(sys.argv)
window = Window()
sys.exit(App.exec())
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment