From 0fb7307ef8d558795730d6d7e3d06ad3c06f61fc Mon Sep 17 00:00:00 2001
From: Andreas Bolin <andbo467@student.liu.se>
Date: Mon, 4 Jul 2022 12:13:05 +0200
Subject: [PATCH] dump branch

---
 .gitignore                         |   4 +-
 b_asic/schedule-gui/main_window.py |  83 +++++++++++++++
 b_asic/schedule-gui/main_window.ui | 161 +++++++++++++++++++++++++++++
 3 files changed, 247 insertions(+), 1 deletion(-)
 create mode 100644 b_asic/schedule-gui/main_window.py
 create mode 100644 b_asic/schedule-gui/main_window.ui

diff --git a/.gitignore b/.gitignore
index 94c4e149..eddcfd56 100644
--- a/.gitignore
+++ b/.gitignore
@@ -109,4 +109,6 @@ venv/
 _b_asic_debug_log.txt
 .idea/
 .qt_for_python/
-*.user
\ No newline at end of file
+*.pyproject.user
+*.pyproject
+*/schedule-gui/ui/
\ No newline at end of file
diff --git a/b_asic/schedule-gui/main_window.py b/b_asic/schedule-gui/main_window.py
new file mode 100644
index 00000000..7424c82e
--- /dev/null
+++ b/b_asic/schedule-gui/main_window.py
@@ -0,0 +1,83 @@
+# This Python file uses the following encoding: utf-8
+"""B-ASIC Schedule-gui Main Window Module.
+
+This file opens the main window of the schedule-gui for B-ASIC when run.
+"""
+import os
+#from pathlib import Path
+import sys
+from typing import Any
+#from matplotlib.pyplot import bar
+
+from qtpy.QtWidgets import QApplication, QMainWindow, QMessageBox
+#from qtpy.QtCore import QFile
+
+
+
+class MainWindow(QMainWindow):
+
+    _test: int
+    _ui: Any
+
+    def __init__(self):
+        super(MainWindow, self).__init__()
+        self._test = 5
+        self.init_ui()
+
+    def init_ui(self):
+        from qtpy import uic
+        #uic.compileUiDir('.', False, \
+        #    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)
+
+    def callback_pushButton(self):
+        self.printButtonPressed('callback_pushButton')
+
+    def callback_menu_load_SFG(self):
+        self.printButtonPressed('callback_menu_load_SFG')
+        self.update_statusbar('SFG loaded successfully')
+    
+    def callback_menu_save_schedule(self):
+        self.printButtonPressed('callback_menu_save_schedule')
+        self.update_statusbar('Schedule saved successfully')
+    
+    def callback_menu_node_info(self, checked: bool):
+        #if _ui.actionNode_info.
+        print(type(checked))
+        print(checked)
+        self.printButtonPressed('callback_menu_node_info')
+        #self.update_statusbar()
+
+
+    def printButtonPressed(self, func_name: str):
+        self.label_2.setText("hello")
+
+        alert = QMessageBox(self)
+        alert.setText("Called from " + func_name + '!')
+        alert.exec_()
+
+    def update_statusbar(self, msg: str):
+        self.statusbar.showMessage(msg)
+
+
+def start_gui():
+    app = QApplication(sys.argv)
+    widget = MainWindow()
+    widget.show()
+    sys.exit(app.exec_())
+
+if __name__ == "__main__":
+    start_gui()
diff --git a/b_asic/schedule-gui/main_window.ui b/b_asic/schedule-gui/main_window.ui
new file mode 100644
index 00000000..9be1254c
--- /dev/null
+++ b/b_asic/schedule-gui/main_window.ui
@@ -0,0 +1,161 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>MainWindow</class>
+ <widget class="QMainWindow" name="MainWindow">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>800</width>
+    <height>600</height>
+   </rect>
+  </property>
+  <property name="sizePolicy">
+   <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
+    <horstretch>0</horstretch>
+    <verstretch>0</verstretch>
+   </sizepolicy>
+  </property>
+  <property name="minimumSize">
+   <size>
+    <width>800</width>
+    <height>600</height>
+   </size>
+  </property>
+  <property name="windowTitle">
+   <string>MainWindow</string>
+  </property>
+  <widget class="QWidget" name="centralwidget">
+   <widget class="QScrollArea" name="scrollArea">
+    <property name="geometry">
+     <rect>
+      <x>150</x>
+      <y>90</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="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">
+      <property name="geometry">
+       <rect>
+        <x>50</x>
+        <y>40</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>
+  <widget class="QMenuBar" name="menubar">
+   <property name="geometry">
+    <rect>
+     <x>0</x>
+     <y>0</y>
+     <width>800</width>
+     <height>22</height>
+    </rect>
+   </property>
+   <widget class="QMenu" name="menuFile">
+    <property name="title">
+     <string>&amp;File</string>
+    </property>
+    <addaction name="actionLoad_SFG"/>
+    <addaction name="actionSave_schedule"/>
+    <addaction name="separator"/>
+    <addaction name="actionQuit"/>
+   </widget>
+   <widget class="QMenu" name="menuView">
+    <property name="title">
+     <string>&amp;View</string>
+    </property>
+    <addaction name="actionNode_info"/>
+   </widget>
+   <addaction name="menuFile"/>
+   <addaction name="menuView"/>
+  </widget>
+  <widget class="QStatusBar" name="statusbar"/>
+  <action name="actionLoad_SFG">
+   <property name="text">
+    <string>&amp;Load SFG...</string>
+   </property>
+   <property name="toolTip">
+    <string>Load Signal Flow Graph</string>
+   </property>
+   <property name="shortcut">
+    <string>Ctrl+O</string>
+   </property>
+  </action>
+  <action name="actionSave_schedule">
+   <property name="text">
+    <string>&amp;Save schedule...</string>
+   </property>
+   <property name="shortcut">
+    <string>Ctrl+S</string>
+   </property>
+  </action>
+  <action name="actionQuit">
+   <property name="text">
+    <string>&amp;Quit</string>
+   </property>
+   <property name="shortcut">
+    <string>Ctrl+Q</string>
+   </property>
+  </action>
+  <action name="actionNode_info">
+   <property name="checkable">
+    <bool>true</bool>
+   </property>
+   <property name="text">
+    <string>&amp;Node info</string>
+   </property>
+   <property name="shortcut">
+    <string>Ctrl+I</string>
+   </property>
+  </action>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
-- 
GitLab