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
3b707314
Commit
3b707314
authored
5 years ago
by
morkolai
Browse files
Options
Downloads
Patches
Plain Diff
#52 Fått timer til å fungere, db oppdateres nå på hensiktsmessig tid
parent
d48deb3e
No related branches found
Branches containing commit
No related tags found
1 merge request
!27
#52 Automatisk oppdatering av kodebok basert på tid
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
soitool/database.py
+9
-4
9 additions, 4 deletions
soitool/database.py
soitool/main_window.py
+3
-7
3 additions, 7 deletions
soitool/main_window.py
with
12 additions
and
11 deletions
soitool/database.py
+
9
−
4
View file @
3b707314
...
...
@@ -51,6 +51,11 @@ class Database:
self
.
fill_tables
()
print
(
"
Tables filled with data.
"
)
# Initiates timer that triggers CodeBook update
self
.
timer
=
QTimer
()
self
.
timer
.
setInterval
(
self
.
seconds_to_next_update
())
self
.
timer
.
timeout
.
connect
(
self
.
update_codebook_auto
)
self
.
conn
.
row_factory
=
sqlite3
.
Row
# Enables row['columnName']
def
create_tables
(
self
):
...
...
@@ -234,11 +239,11 @@ class Database:
def
update_codebook_auto
(
self
):
"""
Update Codebook if it is less than 10 sec til next update.
"""
print
(
"
Running update_codebook_auto
"
)
Update Codebook if needed and set new time for timer.
"""
if
self
.
seconds_to_next_update
()
<
10
:
self
.
update_codebook
()
self
.
timer
.
setInterval
(
self
.
seconds_to_next_update
())
def
add_code_to
(
self
,
word
,
mode
=
"
ascii
"
):
"""
...
...
@@ -282,4 +287,4 @@ class Database:
self
.
conn
.
execute
(
stmt
,
(
code
,
word
))
db
=
Database
()
DB
=
Database
()
This diff is collapsed.
Click to expand it.
soitool/main_window.py
+
3
−
7
View file @
3b707314
...
...
@@ -8,9 +8,8 @@ import os
from
enum
import
Enum
from
PySide2.QtWidgets
import
QMainWindow
,
QApplication
,
QTabWidget
,
QAction
from
PySide2.QtGui
import
QIcon
from
PySide2.QtCore
import
QTimer
from
soitool.soi_workspace_widget
import
SOIWorkspaceWidget
from
soitool.database
import
db
from
soitool.database
import
DB
class
ModuleType
(
Enum
):
...
...
@@ -29,11 +28,8 @@ class MainWindow(QMainWindow):
self
.
setWindowTitle
(
"
SOI-tool
"
)
self
.
statusBar
()
# Updateds CodeBook if needed every minute
self
.
timer
=
QTimer
(
self
)
self
.
timer
.
setInterval
(
60000
)
self
.
timer
.
timeout
.
connect
(
db
.
update_codebook_auto
)
self
.
timer
.
start
()
# Start Qtimer that triggers db update
DB
.
timer
.
start
()
# flytt ut til egen funksjon, for setup av menubar
menu
=
self
.
menuBar
()
...
...
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