Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
soitool
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
bachelor-paa-bittet
soitool
Commits
cda6dcce
Commit
cda6dcce
authored
5 years ago
by
Anders H. Rebner
Browse files
Options
Downloads
Patches
Plain Diff
#42 #43 black formattering på nye filer
parent
b70b6863
No related branches found
Branches containing commit
No related tags found
1 merge request
!31
#42 og #43 Kodebok-GUI
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
scripts/.pylintrc
+11
-1
11 additions, 1 deletion
scripts/.pylintrc
soitool/codebook.py
+8
-8
8 additions, 8 deletions
soitool/codebook.py
soitool/codebook_row_adder.py
+30
-15
30 additions, 15 deletions
soitool/codebook_row_adder.py
soitool/style.py
+4
-3
4 additions, 3 deletions
soitool/style.py
with
53 additions
and
27 deletions
scripts/.pylintrc
+
11
−
1
View file @
cda6dcce
...
...
@@ -60,6 +60,15 @@ confidence=
# --enable=similarities". If you want to run only the classes checker, but have
# no Warning level messages displayed, use "--disable=all --enable=classes
# --disable=W".
#
# NOTE about C0330:
# Ignoring pylint's C0330 "Wrong hanging indentation before block" error
# here because it erronously reports indentation issues, and conflicts with
# the black tool. See this issue on the black gitHub
# page: https://github.com/psf/black/issues/48, and this issue on pylints
# GitHub page referenced by the first issue:
# https://github.com/PyCQA/pylint/issues/289
disable=print-statement,
parameter-unpacking,
unpacking-in-except,
...
...
@@ -142,7 +151,8 @@ disable=print-statement,
E0611,
I1101,
E1101,
R0901
R0901,
C0330
# Enable the message, report, category or checker with the given id(s). You can
# either give multiple identifier separated by comma (,) or put this option
...
...
This diff is collapsed.
Click to expand it.
soitool/codebook.py
+
8
−
8
View file @
cda6dcce
...
...
@@ -10,8 +10,8 @@ from soitool.database import DBPATH # , Database
from
soitool.style
import
CODEBOOK_HEADER_FONT
,
CODEBOOK_HEADER_BACKGROUND_CSS
# Name and type of database
CONNAME
=
'
SOIDB
'
DBTYPE
=
'
QSQLITE
'
CONNAME
=
"
SOIDB
"
DBTYPE
=
"
QSQLITE
"
class
CodeBookTableView
(
QTableView
):
...
...
@@ -30,7 +30,7 @@ class CodeBookTableView(QTableView):
db
.
setDatabaseName
(
DBPATH
)
if
not
db
.
open
():
raise
RuntimeError
(
'
Could not open database.
'
)
raise
RuntimeError
(
"
Could not open database.
"
)
# Enable sorting and sort by column 'Word'
self
.
setSortingEnabled
(
True
)
...
...
@@ -101,7 +101,7 @@ class CodeBookTableModel(QSqlTableModel):
def
__init__
(
self
):
super
().
__init__
(
None
,
QSqlDatabase
.
database
(
CONNAME
))
self
.
setEditStrategy
(
QSqlTableModel
.
OnFieldChange
)
self
.
setTable
(
'
CodeBook
'
)
self
.
setTable
(
"
CodeBook
"
)
self
.
setSort
(
0
,
Qt
.
AscendingOrder
)
self
.
select
()
...
...
@@ -142,10 +142,10 @@ class CodeBookTableModel(QSqlTableModel):
# If a change is made to column 'Type'
if
index
.
column
()
==
2
:
# If correct string, replace with correctly cased str
if
value
.
lower
()
==
'
liten
'
:
value
=
'
Liten
'
elif
value
.
lower
()
==
'
stor
'
:
value
=
'
Stor
'
if
value
.
lower
()
==
"
liten
"
:
value
=
"
Liten
"
elif
value
.
lower
()
==
"
stor
"
:
value
=
"
Stor
"
else
:
return
False
...
...
This diff is collapsed.
Click to expand it.
soitool/codebook_row_adder.py
+
30
−
15
View file @
cda6dcce
"""
Includes functionality for inserting rows into database-table CodeBook.
"""
from
sqlite3
import
IntegrityError
from
PySide2.QtWidgets
import
QHBoxLayout
,
QVBoxLayout
,
QLabel
,
\
QLineEdit
,
QComboBox
,
QPushButton
,
QWidget
from
PySide2.QtWidgets
import
(
QHBoxLayout
,
QVBoxLayout
,
QLabel
,
QLineEdit
,
QComboBox
,
QPushButton
,
QWidget
,
)
from
PySide2.QtCore
import
Qt
from
soitool.database
import
Database
from
soitool.codebook
import
CodeBookTableView
,
CodeBookTableModel
...
...
@@ -34,10 +41,13 @@ class CodebookRowAdder(QWidget):
super
().
__init__
()
# Raise error if argument is invalid
if
codebook_view
is
not
None
and
\
not
isinstance
(
codebook_view
,
CodeBookTableView
):
raise
ValueError
(
"
Invalid value for argument
'
codebook_view
'
:
"
+
"'
{}
'"
.
format
(
codebook_view
))
if
codebook_view
is
not
None
and
not
isinstance
(
codebook_view
,
CodeBookTableView
):
raise
ValueError
(
"
Invalid value for argument
'
codebook_view
'
:
"
+
"'
{}
'"
.
format
(
codebook_view
)
)
self
.
codebook_view
=
codebook_view
...
...
@@ -71,13 +81,15 @@ class CodebookRowAdder(QWidget):
# Match width of widgets to columnwidths of the view if it is used
if
self
.
codebook_view
is
not
None
:
self
.
text_field_word
.
setFixedWidth
(
self
.
codebook_view
.
columnWidth
(
0
)
-
12
)
self
.
codebook_view
.
columnWidth
(
0
)
-
12
)
self
.
text_field_category
.
setFixedWidth
(
self
.
codebook_view
.
columnWidth
(
1
)
-
10
)
self
.
codebook_view
.
columnWidth
(
1
)
-
10
)
self
.
combo_type
.
setFixedWidth
(
self
.
codebook_view
.
columnWidth
(
2
)
-
5
)
self
.
button
.
setFixedWidth
(
self
.
codebook_view
.
columnWidth
(
3
)
-
5
)
self
.
codebook_view
.
columnWidth
(
2
)
-
5
)
self
.
button
.
setFixedWidth
(
self
.
codebook_view
.
columnWidth
(
3
)
-
5
)
# Set standard witdh of widgets if a view is not used
else
:
self
.
text_field_word
.
setFixedWidth
(
140
)
...
...
@@ -162,10 +174,13 @@ class CodebookRowAdder(QWidget):
self
.
codebook_view
.
setModel
(
None
)
# Try to add row to database
stmt
=
"
INSERT INTO CodeBook(Word, Category, Type)
"
\
+
"
VALUES(?, ?, ?)
"
db
.
conn
.
execute
(
stmt
,
(
word_input
,
category_input
,
type_input
,))
stmt
=
(
"
INSERT INTO CodeBook(Word, Category, Type)
"
+
"
VALUES(?, ?, ?)
"
)
db
.
conn
.
execute
(
stmt
,
(
word_input
,
category_input
,
type_input
,)
)
# Add unique code to row and commit changes
db
.
add_code_to
(
word_input
)
...
...
This diff is collapsed.
Click to expand it.
soitool/style.py
+
4
−
3
View file @
cda6dcce
...
...
@@ -4,8 +4,9 @@ from PySide2.QtGui import QFont
# Font and background-color for horizontal header in codebook-view.
CODEBOOK_HEADER_FONT
=
QFont
()
CODEBOOK_HEADER_FONT
.
setFamily
(
'
Arial
'
)
CODEBOOK_HEADER_FONT
.
setFamily
(
"
Arial
"
)
CODEBOOK_HEADER_FONT
.
setPointSize
(
14
)
CODEBOOK_HEADER_FONT
.
setWeight
(
50
)
CODEBOOK_HEADER_BACKGROUND_CSS
=
"
QHeaderView::section
"
\
"
{background-color:rgb(240, 240, 240)}
"
CODEBOOK_HEADER_BACKGROUND_CSS
=
(
"
QHeaderView::section
"
"
{background-color:rgb(240, 240, 240)}
"
)
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