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
f87dfe46
Commit
f87dfe46
authored
4 years ago
by
Jacob Wahlman
Browse files
Options
Downloads
Plain Diff
merged w/ latest develop
parents
1733040e
a99172b8
No related branches found
Branches containing commit
No related tags found
1 merge request
!46
Resolve "Resize GUI Window"
Pipeline
#14953
passed
4 years ago
Stage: test
Changes
3
Pipelines
1
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
b_asic/GUI/drag_button.py
+26
-7
26 additions, 7 deletions
b_asic/GUI/drag_button.py
b_asic/GUI/main_window.py
+187
-386
187 additions, 386 deletions
b_asic/GUI/main_window.py
b_asic/GUI/properties_window.py
+62
-0
62 additions, 0 deletions
b_asic/GUI/properties_window.py
with
275 additions
and
393 deletions
b_asic/GUI/drag_button.py
+
26
−
7
View file @
f87dfe46
...
...
@@ -5,8 +5,10 @@ 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
properties_window
import
PropertiesWindow
from
PyQt5.QtWidgets
import
QPushButton
,
QMenu
,
QAction
from
PyQt5.QtCore
import
Qt
,
QSize
,
pyqtSignal
from
PyQt5.QtGui
import
QIcon
from
utils
import
decorate_class
,
handle_error
...
...
@@ -14,8 +16,11 @@ 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
):
connectionRequested
=
pyqtSignal
(
QPushButton
)
moved
=
pyqtSignal
()
def
__init__
(
self
,
name
,
operation
,
operation_path_name
,
is_show_name
,
window
,
parent
=
None
):
self
.
name
=
name
self
.
is_show_name
=
is_show_name
self
.
_window
=
window
self
.
operation
=
operation
self
.
operation_path_name
=
operation_path_name
...
...
@@ -25,6 +30,20 @@ class DragButton(QPushButton):
self
.
_mouse_move_pos
=
None
super
(
DragButton
,
self
).
__init__
(
self
.
_window
)
def
contextMenuEvent
(
self
,
event
):
menu
=
QMenu
()
properties
=
QAction
(
"
Properties
"
)
menu
.
addAction
(
properties
)
properties
.
triggered
.
connect
(
self
.
show_properties_window
)
menu
.
exec_
(
self
.
cursor
().
pos
())
def
show_properties_window
(
self
,
event
):
self
.
properties_window
=
PropertiesWindow
(
self
,
self
.
_window
)
self
.
properties_window
.
show
()
def
add_label
(
self
,
label
):
self
.
label
=
label
def
mousePressEvent
(
self
,
event
):
if
event
.
button
()
==
Qt
.
LeftButton
:
...
...
@@ -38,20 +57,20 @@ class DragButton(QPushButton):
if
self
.
clicked
==
1
:
self
.
pressed
=
True
self
.
setStyleSheet
(
"
background-color: grey; border-style: solid;
\
border-color: black; border-width: 2px
; border-radius: 10px
"
)
border-color: black; border-width: 2px
"
)
path_to_image
=
os
.
path
.
join
(
'
operation_icons
'
,
self
.
operation_path_name
+
'
_grey.png
'
)
self
.
setIcon
(
QIcon
(
path_to_image
))
self
.
setIconSize
(
QSize
(
5
0
,
5
0
))
self
.
setIconSize
(
QSize
(
5
5
,
5
5
))
self
.
_window
.
pressed_button
.
append
(
self
)
elif
self
.
clicked
==
2
:
self
.
clicked
=
0
self
.
pressed
=
False
self
.
setStyleSheet
(
"
background-color: white; border-style: solid;
\
border-color: black; border-width: 2px
; border-radius: 10px
"
)
border-color: black; border-width: 2px
"
)
path_to_image
=
os
.
path
.
join
(
'
operation_icons
'
,
self
.
operation_path_name
+
'
.png
'
)
self
.
setIcon
(
QIcon
(
path_to_image
))
self
.
setIconSize
(
QSize
(
5
0
,
5
0
))
self
.
setIconSize
(
QSize
(
5
5
,
5
5
))
self
.
_window
.
pressed_button
.
remove
(
self
)
super
(
DragButton
,
self
).
mousePressEvent
(
event
)
...
...
This diff is collapsed.
Click to expand it.
b_asic/GUI/main_window.py
+
187
−
386
View file @
f87dfe46
This diff is collapsed.
Click to expand it.
b_asic/GUI/properties_window.py
0 → 100644
+
62
−
0
View file @
f87dfe46
from
PyQt5.QtWidgets
import
QDialog
,
QLineEdit
,
QPushButton
,
QVBoxLayout
,
QHBoxLayout
,
\
QLabel
,
QCheckBox
from
PyQt5.QtCore
import
Qt
from
PyQt5.QtGui
import
QIntValidator
class
PropertiesWindow
(
QDialog
):
def
__init__
(
self
,
operation
,
main_window
):
super
(
PropertiesWindow
,
self
).
__init__
()
self
.
operation
=
operation
self
.
main_window
=
main_window
self
.
setWindowFlags
(
Qt
.
WindowTitleHint
|
Qt
.
WindowCloseButtonHint
)
self
.
setWindowTitle
(
"
Properties
"
)
self
.
name_layout
=
QHBoxLayout
()
self
.
name_layout
.
setSpacing
(
50
)
self
.
name_label
=
QLabel
(
"
Name:
"
)
self
.
edit_name
=
QLineEdit
(
self
.
operation
.
operation_path_name
)
self
.
name_layout
.
addWidget
(
self
.
name_label
)
self
.
name_layout
.
addWidget
(
self
.
edit_name
)
self
.
vertical_layout
=
QVBoxLayout
()
self
.
vertical_layout
.
addLayout
(
self
.
name_layout
)
if
self
.
operation
.
operation_path_name
==
"
c
"
:
self
.
constant_layout
=
QHBoxLayout
()
self
.
constant_layout
.
setSpacing
(
50
)
self
.
constant_value
=
QLabel
(
"
Constant:
"
)
self
.
edit_constant
=
QLineEdit
(
str
(
self
.
operation
.
operation
.
value
))
self
.
only_accept_int
=
QIntValidator
()
self
.
edit_constant
.
setValidator
(
self
.
only_accept_int
)
self
.
constant_layout
.
addWidget
(
self
.
constant_value
)
self
.
constant_layout
.
addWidget
(
self
.
edit_constant
)
self
.
vertical_layout
.
addLayout
(
self
.
constant_layout
)
self
.
show_name_layout
=
QHBoxLayout
()
self
.
check_show_name
=
QCheckBox
(
"
Show name?
"
)
if
self
.
operation
.
is_show_name
:
self
.
check_show_name
.
setChecked
(
1
)
else
:
self
.
check_show_name
.
setChecked
(
0
)
self
.
check_show_name
.
setLayoutDirection
(
Qt
.
RightToLeft
)
self
.
check_show_name
.
setStyleSheet
(
"
spacing: 170px
"
)
self
.
show_name_layout
.
addWidget
(
self
.
check_show_name
)
self
.
vertical_layout
.
addLayout
(
self
.
show_name_layout
)
self
.
ok
=
QPushButton
(
"
OK
"
)
self
.
ok
.
clicked
.
connect
(
self
.
save_properties
)
self
.
vertical_layout
.
addWidget
(
self
.
ok
)
self
.
setLayout
(
self
.
vertical_layout
)
def
save_properties
(
self
):
self
.
operation
.
name
=
self
.
edit_name
.
text
()
self
.
operation
.
label
.
setPlainText
(
self
.
operation
.
name
)
if
self
.
operation
.
operation_path_name
==
"
c
"
:
self
.
operation
.
operation
.
value
=
self
.
edit_constant
.
text
()
if
self
.
check_show_name
.
isChecked
():
self
.
operation
.
label
.
setOpacity
(
1
)
self
.
operation
.
is_show_name
=
True
else
:
self
.
operation
.
label
.
setOpacity
(
0
)
self
.
operation
.
is_show_name
=
False
self
.
reject
()
\ 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