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
93bf62c2
Commit
93bf62c2
authored
2 years ago
by
Andreas Bolin
Browse files
Options
Downloads
Patches
Plain Diff
better autocompile and more version debug msg
parent
f0c6ca92
No related branches found
No related tags found
1 merge request
!78
Add scheduler GUI
Pipeline
#72665
passed
2 years ago
Stage: test
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
b_asic/scheduler-gui/main_window.py
+48
-52
48 additions, 52 deletions
b_asic/scheduler-gui/main_window.py
with
48 additions
and
52 deletions
b_asic/scheduler-gui/main_window.py
+
48
−
52
View file @
93bf62c2
# This Python file uses the following encoding: utf-8
"""
B-ASIC Scheduler-gui Module.
Contains the scheduler-gui class for scheduling operations in an SFG.
"""
# This Python file uses the following encoding: utf-8
import
os
,
sys
from
pathlib
import
Path
...
...
@@ -11,6 +13,7 @@ from typing import Any
#from diagram import *
from
qtpy
import
uic
,
QtCore
,
QtGui
,
QtWidgets
import
qtpy
from
qtpy.QtCore
import
Qt
,
Slot
,
QSettings
from
qtpy.QtGui
import
QCloseEvent
from
qtpy.QtWidgets
import
QApplication
,
QMainWindow
,
QMessageBox
...
...
@@ -21,55 +24,47 @@ from qtpy.QtGui import (
QPaintEvent
,
QPainter
,
QPainterPath
,
QColor
,
QBrush
,
QPen
,
QFont
,
QPolygon
,
QLinearGradient
)
# Debug stuff
QT_API
=
os
.
environ
.
get
(
'
QT_API
'
)
print
(
"
QT_API:
"
+
QT_API
)
print
(
"
QT_VERSION:
"
+
str
(
QtCore
.
qVersion
()))
if
QT_API
.
lower
().
startswith
(
'
pyqt
'
):
print
(
"
PYQT_VERSION:
"
+
str
(
Qt
.
PYQT_VERSION_STR
))
# Debug struff
if
__debug__
:
# Print some system version information
QT_API
=
os
.
environ
.
get
(
'
QT_API
'
)
print
(
'
Qt version (runtime):
'
,
str
(
QtCore
.
qVersion
()))
print
(
'
Qt version (compiletime):
'
,
QtCore
.
__version__
)
print
(
'
QT_API:
'
,
QT_API
)
if
QT_API
.
lower
().
startswith
(
'
pyside
'
):
import
PySide2
print
(
'
PySide version:
'
,
PySide2
.
__version__
)
if
QT_API
.
lower
().
startswith
(
'
pyqt
'
):
print
(
'
PyQt version:
'
,
str
(
Qt
.
PYQT_VERSION_STR
))
print
(
'
QtPy version:
'
,
qtpy
.
__version__
)
# Compile the .ui form to a python file.
try
:
if
QT_API
.
lower
()
==
'
pyqt5
'
:
def
_map_func
(
dir
:
str
,
file
:
str
)
->
tuple
[
str
,
str
]:
file_base
,
_
=
os
.
path
.
splitext
(
file
)
print
(
'
DEBUG: Compile
\'
'
+
file_base
+
'
.ui
\'
to
\'
'
+
os
.
getcwd
()
+
'
/ui/
'
+
file_base
+
'
_ui.py
\'
...
'
)
return
(
dir
+
'
/ui/
'
,
file_base
+
'
_ui.py
'
)
uic
.
compileUiDir
(
'
.
'
,
False
,
_map_func
)
# Autocompile the .ui form to a python file.
try
:
# PyQt5, try autocompile
from
qtpy.uic
import
compileUiDir
def
_map_func
(
dir
:
str
,
file
:
str
)
->
tuple
[
str
,
str
]:
file_base
,
_
=
os
.
path
.
splitext
(
file
)
return
(
dir
+
'
/ui/
'
,
file_base
+
'
_ui.py
'
)
uic
.
compileUiDir
(
'
.
'
,
False
,
_map_func
)
except
:
try
:
# PySide2, try manual compile
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
:
subprocess
.
call
(
cmd
.
split
())
else
:
#TODO: Implement (startswith) 'win32', 'darwin' (MacOs)
raise
SystemExit
except
:
# Compile failed, look for pre-compiled file
try
:
from
ui.main_window_ui
import
Ui_MainWindow
except
ImportError
:
raise
elif
QT_API
.
lower
()
==
'
pyside2
'
:
# 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
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
'"
)
os
.
_exit
(
1
)
# Tell the user we are in debug mode.
argv
=
sys
.
orig_argv
argv
.
insert
(
1
,
'
-O
'
)
argv
=
'
'
.
join
(
argv
)
print
(
"
DEBUG: Running in debug mode. To disable, start program with:
'"
+
argv
+
"'"
)
except
:
# Everything failed, exit
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
'"
)
os
.
_exit
(
1
)
# Only availible when the form is compiled
from
ui.main_window_ui
import
Ui_MainWindow
...
...
@@ -192,13 +187,13 @@ class MainWindow(QMainWindow, Ui_MainWindow):
################
#### 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 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
#################################
...
...
@@ -218,6 +213,7 @@ class MainWindow(QMainWindow, Ui_MainWindow):
self
.
statusbar
.
showMessage
(
msg
)
def
start_gui
():
app
=
QApplication
(
sys
.
argv
)
window
=
MainWindow
()
...
...
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