diff --git a/b_asic/scheduler-gui/main_window.py b/b_asic/scheduler-gui/main_window.py index 46213f49a91cc5c0b19684201b19db820e05bae5..05c4f871f99e80767f7371fbd9aa925b50ac6d39 100644 --- a/b_asic/scheduler-gui/main_window.py +++ b/b_asic/scheduler-gui/main_window.py @@ -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 + '!') diff --git a/b_asic/scheduler-gui/main_window.ui b/b_asic/scheduler-gui/main_window.ui index 613c249aca41aa977d9625bef78bbefe5ac64a8a..a6319b422d03a81de87c9189d2e9144a0eca3958 100644 --- a/b_asic/scheduler-gui/main_window.ui +++ b/b_asic/scheduler-gui/main_window.ui @@ -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>&Load SFG...</string> diff --git a/b_asic/scheduler-gui/schedule.py b/b_asic/scheduler-gui/schedule.py deleted file mode 100644 index 9b02e59f70e2d7fc482431bfbda5ba9e748ecffb..0000000000000000000000000000000000000000 --- a/b_asic/scheduler-gui/schedule.py +++ /dev/null @@ -1,61 +0,0 @@ -"""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 - - diff --git a/b_asic/scheduler-gui/schedule2.py b/b_asic/scheduler-gui/schedule2.py deleted file mode 100644 index 1caf29478b3ff1f158769a6b4806c0fa5a42a53e..0000000000000000000000000000000000000000 --- a/b_asic/scheduler-gui/schedule2.py +++ /dev/null @@ -1,31 +0,0 @@ -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