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

dump workspace

parent 5461a8a8
No related branches found
No related tags found
1 merge request!78Add scheduler GUI
Pipeline #72634 passed
......@@ -44,22 +44,22 @@ if __debug__:
raise
elif QT_API.lower() == 'pyside2':
# try:
# from ui.main_window_ui import Ui_MainWindow
# except ImportError:
try:
from ui.main_window_ui import Ui_MainWindow
except ImportError:
try:
import subprocess
OS = sys.platform
if OS.startswith('linux'):
cmds = ["mkdir -p ui", "pyside2-uic -o ui/main_window_ui.py main_window.ui"]
for cmd in cmds:
print('$ ' + cmd)
subprocess.call(cmd.split())
else:
print('ERROR: Autocompile for ' + OS + ' is currently not supported.')
raise SystemExit
except:
raise
import subprocess
OS = sys.platform
if OS.startswith('linux'):
cmds = ["mkdir -p ui", "pyside2-uic -o ui/main_window_ui.py main_window.ui"]
for cmd in cmds:
print('$ ' + cmd)
subprocess.call(cmd.split())
else:
print('ERROR: Autocompile for ' + OS + ' is currently not supported.')
raise SystemExit
except:
raise
except:
print("ERROR: Could not import 'Ui_MainWindow'.")
print("ERROR: Can't autocompile under " + QT_API + " eviroment. Try to manual compile 'main_window.ui' to 'ui/main_window_ui.py'")
......@@ -127,15 +127,16 @@ class MainWindow(QMainWindow, Ui_MainWindow):
#print('self:\t\t' + str(type(self)))
def _init_graphics_view(self):
self.setCentralWidget(self.graphicsView)
# pass
# 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.centralwidget.baseSize())
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.centralwidget.baseSize())
self.setupUi(self) # Need to setup ui again
#self.setupUi(self) # Need to setup ui again
@Slot()
......@@ -163,7 +164,8 @@ class MainWindow(QMainWindow, Ui_MainWindow):
def printButtonPressed(self, func_name: str):
self.label_2.setText("hello")
self.label.setText("hello")
alert = QMessageBox(self)
alert.setText("Called from " + func_name + '!')
......
......@@ -16,12 +16,6 @@
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>800</width>
<height>600</height>
</size>
</property>
<property name="windowTitle">
<string>B-ASIC scheduler</string>
</property>
......@@ -30,80 +24,37 @@
<normaloff>:/icons/small_logo.png</normaloff>:/icons/small_logo.png</iconset>
</property>
<widget class="QWidget" name="centralwidget">
<widget class="QScrollArea" name="scrollArea">
<property name="geometry">
<rect>
<x>80</x>
<y>100</y>
<width>461</width>
<height>351</height>
</rect>
</property>
<property name="widgetResizable">
<bool>true</bool>
</property>
<widget class="QWidget" name="scrollAreaWidgetContents">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>459</width>
<height>349</height>
</rect>
</property>
<widget class="QLabel" name="label_2">
<property name="geometry">
<rect>
<x>10</x>
<y>10</y>
<width>62</width>
<height>17</height>
</rect>
</property>
<property name="text">
<string>label_2</string>
</property>
</widget>
</widget>
</widget>
<widget class="QLabel" name="label">
<property name="geometry">
<rect>
<x>110</x>
<y>50</y>
<width>62</width>
<height>17</height>
</rect>
</property>
<property name="text">
<string>label</string>
</property>
</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="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<widget class="QWidget" name="layoutWidget">
<property name="geometry">
<rect>
<x>560</x>
<y>150</y>
<width>83</width>
<height>25</height>
<x>30</x>
<y>90</y>
<width>258</width>
<height>225</height>
</rect>
</property>
<property name="text">
<string>-</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>TextLabel</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QGraphicsView" name="graphicsView"/>
</item>
</layout>
</widget>
</widget>
<widget class="QMenuBar" name="menubar">
......@@ -112,7 +63,7 @@
<x>0</x>
<y>0</y>
<width>800</width>
<height>22</height>
<height>20</height>
</rect>
</property>
<widget class="QMenu" name="menuFile">
......@@ -140,6 +91,52 @@
<addaction name="menuView"/>
</widget>
<widget class="QStatusBar" name="statusbar"/>
<widget class="QDockWidget" name="dockWidget_2">
<attribute name="dockWidgetArea">
<number>4</number>
</attribute>
<widget class="QWidget" name="dockWidgetContents_2">
<widget class="QPushButton" name="pushbutton_add">
<property name="geometry">
<rect>
<x>30</x>
<y>0</y>
<width>81</width>
<height>23</height>
</rect>
</property>
<property name="text">
<string>+</string>
</property>
</widget>
<widget class="QPushButton" name="pushbutton_remove">
<property name="geometry">
<rect>
<x>190</x>
<y>0</y>
<width>61</width>
<height>23</height>
</rect>
</property>
<property name="text">
<string>-</string>
</property>
</widget>
</widget>
</widget>
<widget class="QToolBar" name="toolBar">
<property name="windowTitle">
<string>toolBar</string>
</property>
<attribute name="toolBarArea">
<enum>TopToolBarArea</enum>
</attribute>
<attribute name="toolBarBreak">
<bool>false</bool>
</attribute>
<addaction name="menu_load_sfg"/>
<addaction name="menu_save_schedule"/>
</widget>
<action name="menu_load_sfg">
<property name="text">
<string>&amp;Load SFG...</string>
......
"""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):
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(1000)
#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 Schedule(QtWidgets.QWidget):
_antialiasing: bool = False
_component: _Component = []
def __init__(self, *args, **kwargs):
super(Schedule, 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