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

dump workspace

parent 5461a8a8
Branches
No related tags found
1 merge request!78Add scheduler GUI
Pipeline #72634 passed
...@@ -44,22 +44,22 @@ if __debug__: ...@@ -44,22 +44,22 @@ if __debug__:
raise raise
elif QT_API.lower() == 'pyside2': elif QT_API.lower() == 'pyside2':
# try:
# from ui.main_window_ui import Ui_MainWindow
# except ImportError:
try: try:
from ui.main_window_ui import Ui_MainWindow import subprocess
except ImportError: OS = sys.platform
try: if OS.startswith('linux'):
import subprocess cmds = ["mkdir -p ui", "pyside2-uic -o ui/main_window_ui.py main_window.ui"]
OS = sys.platform for cmd in cmds:
if OS.startswith('linux'): print('$ ' + cmd)
cmds = ["mkdir -p ui", "pyside2-uic -o ui/main_window_ui.py main_window.ui"] subprocess.call(cmd.split())
for cmd in cmds: else:
print('$ ' + cmd) print('ERROR: Autocompile for ' + OS + ' is currently not supported.')
subprocess.call(cmd.split()) raise SystemExit
else: except:
print('ERROR: Autocompile for ' + OS + ' is currently not supported.') raise
raise SystemExit
except:
raise
except: except:
print("ERROR: Could not import 'Ui_MainWindow'.") 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'") 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): ...@@ -127,15 +127,16 @@ class MainWindow(QMainWindow, Ui_MainWindow):
#print('self:\t\t' + str(type(self))) #print('self:\t\t' + str(type(self)))
def _init_graphics_view(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.setupUi(self) # Need to setup ui again
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
@Slot() @Slot()
...@@ -163,7 +164,8 @@ class MainWindow(QMainWindow, Ui_MainWindow): ...@@ -163,7 +164,8 @@ class MainWindow(QMainWindow, Ui_MainWindow):
def printButtonPressed(self, func_name: str): def printButtonPressed(self, func_name: str):
self.label_2.setText("hello") self.label.setText("hello")
alert = QMessageBox(self) alert = QMessageBox(self)
alert.setText("Called from " + func_name + '!') alert.setText("Called from " + func_name + '!')
......
...@@ -16,12 +16,6 @@ ...@@ -16,12 +16,6 @@
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
</property> </property>
<property name="minimumSize">
<size>
<width>800</width>
<height>600</height>
</size>
</property>
<property name="windowTitle"> <property name="windowTitle">
<string>B-ASIC scheduler</string> <string>B-ASIC scheduler</string>
</property> </property>
...@@ -30,80 +24,37 @@ ...@@ -30,80 +24,37 @@
<normaloff>:/icons/small_logo.png</normaloff>:/icons/small_logo.png</iconset> <normaloff>:/icons/small_logo.png</normaloff>:/icons/small_logo.png</iconset>
</property> </property>
<widget class="QWidget" name="centralwidget"> <widget class="QWidget" name="centralwidget">
<widget class="QScrollArea" name="scrollArea"> <property name="sizePolicy">
<property name="geometry"> <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<rect> <horstretch>0</horstretch>
<x>80</x> <verstretch>0</verstretch>
<y>100</y> </sizepolicy>
<width>461</width> </property>
<height>351</height> <widget class="QWidget" name="layoutWidget">
</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="geometry"> <property name="geometry">
<rect> <rect>
<x>560</x> <x>30</x>
<y>150</y> <y>90</y>
<width>83</width> <width>258</width>
<height>25</height> <height>225</height>
</rect> </rect>
</property> </property>
<property name="text"> <layout class="QVBoxLayout" name="verticalLayout">
<string>-</string> <item>
</property> <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> </widget>
<widget class="QMenuBar" name="menubar"> <widget class="QMenuBar" name="menubar">
...@@ -112,7 +63,7 @@ ...@@ -112,7 +63,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>800</width> <width>800</width>
<height>22</height> <height>20</height>
</rect> </rect>
</property> </property>
<widget class="QMenu" name="menuFile"> <widget class="QMenu" name="menuFile">
...@@ -140,6 +91,52 @@ ...@@ -140,6 +91,52 @@
<addaction name="menuView"/> <addaction name="menuView"/>
</widget> </widget>
<widget class="QStatusBar" name="statusbar"/> <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"> <action name="menu_load_sfg">
<property name="text"> <property name="text">
<string>&amp;Load SFG...</string> <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