Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B-ASIC - Better ASIC Toolbox
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Computer Engineering
B-ASIC - Better ASIC Toolbox
Commits
f0c6ca92
Commit
f0c6ca92
authored
2 years ago
by
Andreas Bolin
Browse files
Options
Downloads
Patches
Plain Diff
workspace dump
parent
032d62cc
No related branches found
No related tags found
1 merge request
!78
Add scheduler GUI
Pipeline
#72659
passed
2 years ago
Stage: test
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
b_asic/scheduler-gui/main_window.py
+83
-40
83 additions, 40 deletions
b_asic/scheduler-gui/main_window.py
b_asic/scheduler-gui/main_window.ui
+84
-51
84 additions, 51 deletions
b_asic/scheduler-gui/main_window.ui
with
167 additions
and
91 deletions
b_asic/scheduler-gui/main_window.py
+
83
−
40
View file @
f0c6ca92
...
...
@@ -4,20 +4,19 @@ Contains the scheduler-gui class for scheduling operations in an SFG.
"""
# This Python file uses the following encoding: utf-8
import
os
import
os
,
sys
from
pathlib
import
Path
import
sys
from
typing
import
Any
from
pytest
import
ExitCode
#from matplotlib.pyplot import bar
#from diagram import *
from
qtpy
import
uic
,
QtCore
,
QtGui
,
QtWidgets
from
qtpy.QtCore
import
Qt
,
Slot
from
qtpy
import
uic
,
QtCore
,
QtGui
,
QtWidgets
from
qtpy.QtCore
import
Qt
,
Slot
,
QSettings
from
qtpy.QtGui
import
QCloseEvent
from
qtpy.QtWidgets
import
QApplication
,
QMainWindow
,
QMessageBox
# QPainter imports
from
qtpy.QtWidgets
import
QGraphicsView
,
QGraphicsScene
from
qtpy.QtWidgets
import
QGraphicsView
,
QGraphicsScene
,
QMessageBox
from
qtpy.QtGui
import
(
QPaintEvent
,
QPainter
,
QPainterPath
,
QColor
,
QBrush
,
QPen
,
QFont
,
QPolygon
,
QLinearGradient
)
...
...
@@ -72,7 +71,6 @@ if __debug__:
argv
=
'
'
.
join
(
argv
)
print
(
"
DEBUG: Running in debug mode. To disable, start program with:
'"
+
argv
+
"'"
)
# Only availible when the form is compiled
from
ui.main_window_ui
import
Ui_MainWindow
...
...
@@ -82,20 +80,17 @@ from ui.main_window_ui import Ui_MainWindow
class
MainWindow
(
QMainWindow
,
Ui_MainWindow
):
"""
Schedule of an SFG with scheduled Operations.
"""
#_ui: QMainWindow # <class '__main__.Ui_MainWindow'>
#_widget: QMainWindow # <class 'PyQt5.QtWidgets.QMainWindow'>
#ui = Ui_MainWindow() # DEBUG, remove later
_settings
:
QSettings
def
__init__
(
self
):
"""
Construct a Schedule from an SFG and show it in the UI
.
"""
"""
Initialize Schedule-gui
.
"""
super
(
MainWindow
,
self
).
__init__
()
self
.
_init_ui
()
self
.
_init_graphics_view
()
def
_init_ui
(
self
):
def
_init_ui
(
self
)
->
None
:
# self._ui = uic.loadUi("main_window.ui", None) # Load the .ui file
# #self._ui.setupUi(self)
# print('self:\t\t' + str(type(self)))
...
...
@@ -115,55 +110,102 @@ class MainWindow(QMainWindow, Ui_MainWindow):
# else:
# uic.loadUi("main_window.ui", self) # Load the .ui file
self
.
_settings
=
QSettings
()
self
.
setupUi
(
self
)
# Init signals/slots
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_load_sfg
.
triggered
.
connect
(
self
.
open
)
self
.
menu_save_schedule
.
triggered
.
connect
(
self
.
save
)
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
.
setCentralWidget
(
self
.
graphicsView
)
self
.
menu_node_info
.
triggered
.
connect
(
self
.
_toggle_component_info
)
self
.
splitter_center
.
splitterMoved
.
connect
(
self
.
_splitter_center_moved
)
# Init info sidebar
for
i
in
range
(
10
):
self
.
listWidget
.
addItem
(
'
this is a very very very very long string that says abolutly nothing
'
+
str
(
i
))
self
.
listWidget
.
addItem
(
'
this is a short string
'
+
str
(
i
))
# Init central-widget splitter
self
.
splitter_center
.
setStretchFactor
(
0
,
1
)
self
.
splitter_center
.
setStretchFactor
(
1
,
0
)
self
.
splitter_center
.
setCollapsible
(
0
,
False
)
self
.
splitter_center
.
setCollapsible
(
1
,
True
)
def
_init_graphics_view
(
self
)
->
None
:
pass
#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)
self
.
graphic_scene
=
QGraphicsScene
(
self
)
self
.
graphic_view
.
setScene
(
self
.
graphic_scene
)
#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
###############
#### Slots ####
###############
@Slot
()
def
callback_pushButton
(
self
):
def
callback_pushButton
(
self
)
->
None
:
#diagram = Diagram()
self
.
printButtonPressed
(
'
callback_pushButton
'
)
@Slot
()
def
load_sfg
(
self
):
def
open
(
self
)
->
None
:
"""
This method loads an SFG and create a base schedule in gui.
"""
#TODO: all
self
.
printButtonPressed
(
'
load_sfg()
'
)
self
.
update_statusbar
(
'
SFG loaded successfully
'
)
@Slot
()
def
save_schedule
(
self
):
def
save
(
self
)
->
None
:
"""
This method save an schedule.
"""
#TODO: all
self
.
printButtonPressed
(
'
save_schedule()
'
)
self
.
update_statusbar
(
'
Schedule saved successfully
'
)
@Slot
(
bool
)
def
toggle_node_info
(
self
,
checked
:
bool
):
#if _ui.actionNode_info.
print
(
type
(
checked
))
print
(
checked
)
self
.
printButtonPressed
(
'
toggle_node_info()
'
)
#self.update_statusbar()
def
_toggle_component_info
(
self
,
checked
:
bool
)
->
None
:
widths
=
list
(
self
.
splitter_center
.
sizes
())
max_range
=
widths
[
0
]
+
widths
[
1
]
if
checked
:
self
.
splitter_center
.
restoreState
(
self
.
_settings
.
value
(
"
splitterSizes
"
));
else
:
self
.
_settings
.
setValue
(
"
splitterSizes
"
,
self
.
splitter_center
.
saveState
());
self
.
splitter_center
.
moveSplitter
(
max_range
,
1
)
# Note: splitter index starts at 1
@Slot
(
int
,
int
)
def
_splitter_center_moved
(
self
,
pos
:
int
,
index
:
int
)
->
None
:
widths
:
list
[
int
,
int
]
=
list
(
self
.
splitter_center
.
sizes
())
#TODO: Custom move handler, save state on click-release?
if
widths
[
1
]
==
0
:
self
.
menu_node_info
.
setChecked
(
False
)
else
:
self
.
menu_node_info
.
setChecked
(
True
)
################
#### Events ####
################
def
closeEvent
(
self
,
event
:
QCloseEvent
)
->
None
:
"""
Overloads QMainWindow default closeEvent(QCloseEvent) event
"""
QMessageBox
.
StandardButton
resBtn
=
QMessageBox
::
question
(
this
,
APP_NAME
,
self
.
tr
(
"
Are you sure?
\n
"
),
QMessageBox
::
Cancel
|
QMessageBox
::
No
|
QMessageBox
::
Yes
,
QMessageBox
::
Yes
);
pass
def
printButtonPressed
(
self
,
func_name
:
str
):
#################################
#### Helper member functions ####
#################################
def
printButtonPressed
(
self
,
func_name
:
str
)
->
None
:
#TODO: remove
self
.
label
.
setText
(
"
hello
"
)
...
...
@@ -171,7 +213,8 @@ class MainWindow(QMainWindow, Ui_MainWindow):
alert
.
setText
(
"
Called from
"
+
func_name
+
'
!
'
)
alert
.
exec_
()
def
update_statusbar
(
self
,
msg
:
str
):
def
update_statusbar
(
self
,
msg
:
str
)
->
None
:
"""
Write the given str to the statusbar with temporarily policy.
"""
self
.
statusbar
.
showMessage
(
msg
)
...
...
This diff is collapsed.
Click to expand it.
b_asic/scheduler-gui/main_window.ui
+
84
−
51
View file @
f0c6ca92
...
...
@@ -30,32 +30,48 @@
<verstretch>
0
</verstretch>
</sizepolicy>
</property>
<widget
class=
"QWidget"
name=
"layoutWidget"
>
<property
name=
"geometry"
>
<rect>
<x>
30
</x>
<y>
90
</y>
<width>
258
</width>
<height>
225
</height>
</rect>
<layout
class=
"QHBoxLayout"
name=
"horizontalLayout"
>
<property
name=
"spacing"
>
<number>
0
</number>
</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>
<property
name=
"leftMargin"
>
<number>
0
</number>
</property>
<property
name=
"topMargin"
>
<number>
0
</number>
</property>
<property
name=
"rightMargin"
>
<number>
0
</number>
</property>
<property
name=
"bottomMargin"
>
<number>
0
</number>
</property>
<item>
<widget
class=
"QSplitter"
name=
"splitter_center"
>
<property
name=
"orientation"
>
<enum>
Qt::Horizontal
</enum>
</property>
<widget
class=
"QGraphicsView"
name=
"graphic_view"
/>
<widget
class=
"QListWidget"
name=
"listWidget"
>
<property
name=
"enabled"
>
<bool>
true
</bool>
</property>
<property
name=
"minimumSize"
>
<size>
<width>
0
</width>
<height>
0
</height>
</size>
</property>
<property
name=
"baseSize"
>
<size>
<width>
0
</width>
<height>
0
</height>
</size>
</property>
</widget>
</widget>
</item>
</layout>
</widget>
<widget
class=
"QMenuBar"
name=
"menubar"
>
<property
name=
"geometry"
>
...
...
@@ -96,32 +112,42 @@
<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>
<layout
class=
"QHBoxLayout"
name=
"horizontalLayout_2"
>
<item>
<widget
class=
"QPushButton"
name=
"pushbutton_add"
>
<property
name=
"text"
>
<string>
+
</string>
</property>
</widget>
</item>
<item>
<widget
class=
"QPushButton"
name=
"pushbutton_remove"
>
<property
name=
"text"
>
<string>
-
</string>
</property>
</widget>
</item>
<item>
<widget
class=
"QLabel"
name=
"label"
>
<property
name=
"text"
>
<string>
TextLabel
</string>
</property>
</widget>
</item>
<item>
<spacer
name=
"horizontalSpacer"
>
<property
name=
"orientation"
>
<enum>
Qt::Horizontal
</enum>
</property>
<property
name=
"sizeHint"
stdset=
"0"
>
<size>
<width>
40
</width>
<height>
20
</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</widget>
<widget
class=
"QToolBar"
name=
"toolBar"
>
...
...
@@ -136,6 +162,7 @@
</attribute>
<addaction
name=
"menu_load_sfg"
/>
<addaction
name=
"menu_save_schedule"
/>
<addaction
name=
"menu_node_info"
/>
</widget>
<action
name=
"menu_load_sfg"
>
<property
name=
"text"
>
...
...
@@ -163,9 +190,15 @@
<property
name=
"checkable"
>
<bool>
true
</bool>
</property>
<property
name=
"checked"
>
<bool>
true
</bool>
</property>
<property
name=
"text"
>
<string>
&
Node info
</string>
</property>
<property
name=
"toolTip"
>
<string>
Show node information
</string>
</property>
<property
name=
"shortcut"
>
<string>
Ctrl+I
</string>
</property>
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment