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
72029bbe
Commit
72029bbe
authored
4 years ago
by
Jacob Wahlman
Browse files
Options
Downloads
Patches
Plain Diff
added initial solution to error messages
parent
85db5737
No related branches found
Branches containing commit
No related tags found
3 merge requests
!67
WIP: B-ASIC version 1.0.0 hotfix
,
!65
B-ASIC version 1.0.0
,
!43
Error handling in GUI
Pipeline
#14741
passed
4 years ago
Stage: test
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
b_asic/GUI/drag_button.py
+10
-8
10 additions, 8 deletions
b_asic/GUI/drag_button.py
b_asic/GUI/improved_main_window.py
+3
-1
3 additions, 1 deletion
b_asic/GUI/improved_main_window.py
b_asic/GUI/utils.py
+19
-0
19 additions, 0 deletions
b_asic/GUI/utils.py
with
32 additions
and
9 deletions
b_asic/GUI/drag_button.py
+
10
−
8
View file @
72029bbe
...
...
@@ -3,23 +3,25 @@ Drag button class.
This class creates a dragbutton which can be clicked, dragged and dropped.
"""
import
os.path
from
PyQt5.QtWidgets
import
QPushButton
from
PyQt5.QtCore
import
Qt
,
QSize
from
PyQt5.QtGui
import
QIcon
from
utils
import
decorate_class
,
handle_error
@decorate_class
(
handle_error
)
class
DragButton
(
QPushButton
):
def
__init__
(
self
,
name
,
operation
,
operation_path_name
,
window
,
parent
=
None
):
self
.
name
=
name
self
.
_
_
window
=
window
self
.
_window
=
window
self
.
operation
=
operation
self
.
operation_path_name
=
operation_path_name
self
.
clicked
=
0
self
.
pressed
=
False
super
(
DragButton
,
self
).
__init__
(
self
.
_
_
window
)
super
(
DragButton
,
self
).
__init__
(
self
.
_window
)
def
mousePressEvent
(
self
,
event
):
self
.
_mouse_press_pos
=
None
...
...
@@ -29,7 +31,7 @@ class DragButton(QPushButton):
self
.
_mouse_press_pos
=
event
.
globalPos
()
self
.
_mouse_move_pos
=
event
.
globalPos
()
for
signal
in
self
.
_
_
window
.
signalList
:
for
signal
in
self
.
_window
.
signalList
:
signal
.
update
()
self
.
clicked
+=
1
...
...
@@ -40,7 +42,7 @@ class DragButton(QPushButton):
path_to_image
=
os
.
path
.
join
(
'
operation_icons
'
,
self
.
operation_path_name
+
'
_grey.png
'
)
self
.
setIcon
(
QIcon
(
path_to_image
))
self
.
setIconSize
(
QSize
(
50
,
50
))
self
.
_
_
window
.
pressed_button
.
append
(
self
)
self
.
_window
.
pressed_button
.
append
(
self
)
elif
self
.
clicked
==
2
:
self
.
clicked
=
0
...
...
@@ -50,7 +52,7 @@ class DragButton(QPushButton):
path_to_image
=
os
.
path
.
join
(
'
operation_icons
'
,
self
.
operation_path_name
+
'
.png
'
)
self
.
setIcon
(
QIcon
(
path_to_image
))
self
.
setIconSize
(
QSize
(
50
,
50
))
self
.
_
_
window
.
pressed_button
.
remove
(
self
)
self
.
_window
.
pressed_button
.
remove
(
self
)
super
(
DragButton
,
self
).
mousePressEvent
(
event
)
...
...
@@ -63,8 +65,8 @@ class DragButton(QPushButton):
self
.
move
(
new_pos
)
self
.
_mouse_move_pos
=
global_pos
self
.
_
_
window
.
update
()
self
.
_window
.
update
()
super
(
DragButton
,
self
).
mouseMoveEvent
(
event
)
def
mouseReleaseEvent
(
self
,
event
):
...
...
This diff is collapsed.
Click to expand it.
b_asic/GUI/improved_main_window.py
+
3
−
1
View file @
72029bbe
...
...
@@ -14,6 +14,7 @@ from port_button import PortButton
from
b_asic
import
Operation
import
b_asic.core_operations
as
c_oper
import
b_asic.special_operations
as
s_oper
from
utils
import
decorate_class
,
handle_error
from
numpy
import
linspace
...
...
@@ -25,6 +26,7 @@ from PyQt5.QtCore import Qt, QSize
from
PyQt5.QtGui
import
QIcon
,
QFont
,
QPainter
,
QPen
,
QBrush
,
QKeySequence
@decorate_class
(
handle_error
)
class
MainWindow
(
QMainWindow
):
def
__init__
(
self
):
super
(
MainWindow
,
self
).
__init__
()
...
...
@@ -41,6 +43,7 @@ class MainWindow(QMainWindow):
self
.
portList
=
[]
self
.
pressed_ports
=
[]
self
.
source
=
None
self
.
_window
=
self
self
.
init_ui
()
self
.
add_operations_from_namespace
(
c_oper
,
self
.
ui
.
core_operations_list
)
...
...
@@ -141,7 +144,6 @@ class MainWindow(QMainWindow):
self
.
add_operations_from_namespace
(
c_oper
,
self
.
ui
.
core_operations_list
)
self
.
add_operations_from_namespace
(
s_oper
,
self
.
ui
.
special_operations_list
)
def
print_input_port_1
(
self
):
print
(
"
Input port 1
"
)
...
...
This diff is collapsed.
Click to expand it.
b_asic/GUI/utils.py
0 → 100644
+
19
−
0
View file @
72029bbe
from
PyQt5.QtWidgets
import
QErrorMessage
from
traceback
import
format_exc
def
handle_error
(
fn
):
def
wrapper
(
self
,
*
args
,
**
kwargs
):
try
:
return
fn
(
self
,
*
args
,
**
kwargs
)
except
Exception
as
e
:
QErrorMessage
(
self
.
_window
).
showMessage
(
f
"
Unexpected error:
{
format_exc
()
}
"
)
return
wrapper
def
decorate_class
(
decorator
):
def
decorate
(
cls
):
for
attr
in
cls
.
__dict__
:
if
callable
(
getattr
(
cls
,
attr
)):
setattr
(
cls
,
attr
,
decorator
(
getattr
(
cls
,
attr
)))
return
cls
return
decorate
\ No newline at end of file
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