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

workspace dump

parent 0fb7307e
No related branches found
No related tags found
1 merge request!78Add scheduler GUI
Pipeline #72574 passed
"""B-ASIC Scheduler-gui Module.
Graphical user interface for B-ASIC scheduler.
"""
from b_asic.schedule-gui.main_window import *
\ No newline at end of file
"""B-ASIC Schedule-gui Diagram Module.
Contains the Diagram class for painting an schedule.
"""
# This Python file uses the following encoding: utf-8
from qtpy import QtCore
from qtpy import QtWidgets
from qtpy.QtGui import (
QPaintEvent, QPainter, QPainterPath, QColor, QBrush, QPen, QFont, QPolygon,
QLinearGradient)
from qtpy.QtWidgets import QCanvasView
# QPaintEvent is a class
class Diagram(QtWidgets.QWidget):
_antialiasing: bool = False
def __init__(self, parent):
pass
def add_component(self):
pass
def paintEvent(self, event):
# Create a few pen colors
self.black = '#000000'
self.blue = '#2041F1'
self.green = '#12A708'
self.purple = '#6512F0'
self.red = '#E00C0C'
self.orange = '#FF930A'
painter = QPainter(self)
#painter.Antialiasing(self._antialiasing)
painter.begin(self)
painter.drawLine(10, 10, 100, 100)
painter.end()
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
# This Python file uses the following encoding: utf-8 """B-ASIC Schedule-gui Module.
"""B-ASIC Schedule-gui Main Window Module.
This file opens the main window of the schedule-gui for B-ASIC when run. Contains the schedule-gui class for scheduling operations in an SFG.
""" """
# This Python file uses the following encoding: utf-8
import os import os
#from pathlib import Path #from pathlib import Path
import sys import sys
from typing import Any from typing import Any
#from matplotlib.pyplot import bar #from matplotlib.pyplot import bar
#from diagram import *
from qtpy import QtCore, QtGui, QtWidgets
from qtpy.QtCore import Qt, Slot
from qtpy.QtWidgets import QApplication, QMainWindow, QMessageBox from qtpy.QtWidgets import QApplication, QMainWindow, QMessageBox
#from qtpy.QtCore import QFile
# QPainter imports
from qtpy.QtWidgets import QGraphicsView, QGraphicsScene
from qtpy.QtGui import (
QPaintEvent, QPainter, QPainterPath, QColor, QBrush, QPen, QFont, QPolygon,
QLinearGradient)
class MainWindow(QMainWindow): class MainWindow(QMainWindow):
_test: int _ui: QMainWindow # <class '__main__.Ui_MainWindow'>
_ui: Any _widget: QMainWindow # <class 'PyQt5.QtWidgets.QMainWindow'>
def __init__(self): def __init__(self):
super(MainWindow, self).__init__() super(MainWindow, self).__init__()
self._test = 5 self._init_ui()
self.init_ui() self._init_graphics_view()
def _init_ui(self):
QT_API = os.environ.get('QT_API')
print("QT_API: " + QT_API)
def init_ui(self):
from qtpy import uic from qtpy import uic
#uic.compileUiDir('.', False, \ #uic.compileUiDir('.', False, \
# lambda dir, file : [dir+str('/ui/'), str('ui_')+file],) # lambda dir, file : [dir+str('/ui/'), str('ui_')+file],)
_ui = uic.loadUi("main_window.ui", self) # Load the .ui file
_ui.pushButton.clicked.connect(self.callback_pushButton)
_ui.actionLoad_SFG.triggered.connect(self.callback_menu_load_SFG)
_ui.actionSave_schedule.triggered.connect(self.callback_menu_save_schedule)
_ui.actionQuit.triggered.connect(self.close)
_ui.actionNode_info.triggered.connect(self.callback_menu_node_info)
#_ui.actionNode_info.triggered.connect(self.update_statusbar)
print(type(_ui))
#_ui, _base_class = uic.loadUiType("main_window_ui.ui", None) # Load the .ui file
#print(type(_base_class))
print(type(self._test))
QT_API = os.environ.get('QT_API')
print("QT_API: " + QT_API)
# self._ui = uic.loadUi("main_window.ui", None) # Load the .ui file
# #self._ui.setupUi(self)
# print('self:\t\t' + str(type(self)))
# print('self._ui:\t' + str(type(self._ui)))
# self._ui.pushbutton_add.clicked.connect(self.callback_pushButton)
# self._ui.menu_load_sfg.triggered.connect(self.load_sfg)
# self._ui.menu_save_schedule.triggered.connect(self.save_schedule)
# self._ui.menu_quit.triggered.connect(self._ui.close)
# self._ui.menu_node_info.triggered.connect(self.toggle_node_info)
# self._ui.show()
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()
#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)
@Slot()
def callback_pushButton(self): def callback_pushButton(self):
#diagram = Diagram()
self.printButtonPressed('callback_pushButton') self.printButtonPressed('callback_pushButton')
def callback_menu_load_SFG(self): @Slot()
self.printButtonPressed('callback_menu_load_SFG') def load_sfg(self):
self.printButtonPressed('load_sfg()')
self.update_statusbar('SFG loaded successfully') self.update_statusbar('SFG loaded successfully')
def callback_menu_save_schedule(self): @Slot()
self.printButtonPressed('callback_menu_save_schedule') def save_schedule(self):
self.printButtonPressed('save_schedule()')
self.update_statusbar('Schedule saved successfully') self.update_statusbar('Schedule saved successfully')
def callback_menu_node_info(self, checked: bool): @Slot(bool)
def toggle_node_info(self, checked: bool):
#if _ui.actionNode_info. #if _ui.actionNode_info.
print(type(checked)) print(type(checked))
print(checked) print(checked)
self.printButtonPressed('callback_menu_node_info') self.printButtonPressed('toggle_node_info()')
#self.update_statusbar() #self.update_statusbar()
def printButtonPressed(self, func_name: str): def printButtonPressed(self, func_name: str):
self.label_2.setText("hello") self.label_2.setText("hello")
...@@ -75,8 +107,8 @@ class MainWindow(QMainWindow): ...@@ -75,8 +107,8 @@ class MainWindow(QMainWindow):
def start_gui(): def start_gui():
app = QApplication(sys.argv) app = QApplication(sys.argv)
widget = MainWindow() window = MainWindow()
widget.show() #window.show()
sys.exit(app.exec_()) sys.exit(app.exec_())
if __name__ == "__main__": if __name__ == "__main__":
......
...@@ -23,14 +23,18 @@ ...@@ -23,14 +23,18 @@
</size> </size>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
<string>MainWindow</string> <string>B-ASIC scheduler</string>
</property>
<property name="windowIcon">
<iconset>
<normaloff>../../small_logo.png</normaloff>../../small_logo.png</iconset>
</property> </property>
<widget class="QWidget" name="centralwidget"> <widget class="QWidget" name="centralwidget">
<widget class="QScrollArea" name="scrollArea"> <widget class="QScrollArea" name="scrollArea">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>150</x> <x>80</x>
<y>90</y> <y>100</y>
<width>461</width> <width>461</width>
<height>351</height> <height>351</height>
</rect> </rect>
...@@ -47,24 +51,11 @@ ...@@ -47,24 +51,11 @@
<height>349</height> <height>349</height>
</rect> </rect>
</property> </property>
<widget class="QPushButton" name="pushButton">
<property name="geometry">
<rect>
<x>120</x>
<y>110</y>
<width>83</width>
<height>25</height>
</rect>
</property>
<property name="text">
<string>PushButton</string>
</property>
</widget>
<widget class="QLabel" name="label_2"> <widget class="QLabel" name="label_2">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>50</x> <x>10</x>
<y>40</y> <y>10</y>
<width>62</width> <width>62</width>
<height>17</height> <height>17</height>
</rect> </rect>
...@@ -88,6 +79,32 @@ ...@@ -88,6 +79,32 @@
<string>label</string> <string>label</string>
</property> </property>
</widget> </widget>
<widget class="QPushButton" name="pushbutton_add">
<property name="geometry">
<rect>
<x>560</x>
<y>100</y>
<width>83</width>
<height>25</height>
</rect>
</property>
<property name="text">
<string>+</string>
</property>
</widget>
<widget class="QPushButton" name="pushbutton_remove">
<property name="geometry">
<rect>
<x>560</x>
<y>150</y>
<width>83</width>
<height>25</height>
</rect>
</property>
<property name="text">
<string>-</string>
</property>
</widget>
</widget> </widget>
<widget class="QMenuBar" name="menubar"> <widget class="QMenuBar" name="menubar">
<property name="geometry"> <property name="geometry">
...@@ -102,33 +119,42 @@ ...@@ -102,33 +119,42 @@
<property name="title"> <property name="title">
<string>&amp;File</string> <string>&amp;File</string>
</property> </property>
<addaction name="actionLoad_SFG"/> <addaction name="menu_load_sfg"/>
<addaction name="actionSave_schedule"/> <addaction name="menu_save_schedule"/>
<addaction name="separator"/> <addaction name="separator"/>
<addaction name="actionQuit"/> <addaction name="menu_quit"/>
</widget> </widget>
<widget class="QMenu" name="menuView"> <widget class="QMenu" name="menuView">
<property name="title"> <property name="title">
<string>&amp;View</string> <string>&amp;View</string>
</property> </property>
<addaction name="actionNode_info"/> <addaction name="menu_node_info"/>
</widget>
<widget class="QMenu" name="menu_Edit">
<property name="title">
<string>&amp;Edit</string>
</property>
</widget> </widget>
<addaction name="menuFile"/> <addaction name="menuFile"/>
<addaction name="menu_Edit"/>
<addaction name="menuView"/> <addaction name="menuView"/>
</widget> </widget>
<widget class="QStatusBar" name="statusbar"/> <widget class="QStatusBar" name="statusbar"/>
<action name="actionLoad_SFG"> <action name="menu_load_sfg">
<property name="text"> <property name="text">
<string>&amp;Load SFG...</string> <string>&amp;Load SFG...</string>
</property> </property>
<property name="toolTip"> <property name="toolTip">
<string>Load Signal Flow Graph</string> <string>Load Signal Flow Graph</string>
</property> </property>
<property name="statusTip">
<string/>
</property>
<property name="shortcut"> <property name="shortcut">
<string>Ctrl+O</string> <string>Ctrl+O</string>
</property> </property>
</action> </action>
<action name="actionSave_schedule"> <action name="menu_save_schedule">
<property name="text"> <property name="text">
<string>&amp;Save schedule...</string> <string>&amp;Save schedule...</string>
</property> </property>
...@@ -136,15 +162,7 @@ ...@@ -136,15 +162,7 @@
<string>Ctrl+S</string> <string>Ctrl+S</string>
</property> </property>
</action> </action>
<action name="actionQuit"> <action name="menu_node_info">
<property name="text">
<string>&amp;Quit</string>
</property>
<property name="shortcut">
<string>Ctrl+Q</string>
</property>
</action>
<action name="actionNode_info">
<property name="checkable"> <property name="checkable">
<bool>true</bool> <bool>true</bool>
</property> </property>
...@@ -155,6 +173,14 @@ ...@@ -155,6 +173,14 @@
<string>Ctrl+I</string> <string>Ctrl+I</string>
</property> </property>
</action> </action>
<action name="menu_quit">
<property name="text">
<string>&amp;Quit</string>
</property>
<property name="shortcut">
<string>Ctrl+Q</string>
</property>
</action>
</widget> </widget>
<resources/> <resources/>
<connections/> <connections/>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment