This repository has been archived by the owner on May 23, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pref_win.py
96 lines (87 loc) · 4.39 KB
/
pref_win.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'pref_win.ui'
#
# Created by: PyQt5 UI code generator 5.15.0
#
# WARNING: Any manual changes made to this file will be lost when pyuic5 is
# run again. Do not edit this file unless you know what you are doing.
from PyQt5 import QtCore, QtGui, QtWidgets
import json
from PyQt5.QtGui import QIcon
class Ui_pref_win(object):
def __init__(self, window):
self.window = window
with open ("settings.json", "r") as settings:
self.data = json.load(settings)
settings.close()
self.main_time = self.data["main_time"]
self.big_time = self.data["long_break"]
self.small_time = self.data["short_break"]
def setupUi(self, pref_win):
pref_win.setObjectName("pref_win")
pref_win.resize(390, 251)
pref_win.setContextMenuPolicy(QtCore.Qt.NoContextMenu)
pref_win.setWindowIcon(QIcon("material/images/tomato.png"))
self.centralwidget = QtWidgets.QWidget(pref_win)
self.centralwidget.setObjectName("centralwidget")
self.label = QtWidgets.QLabel(self.centralwidget)
self.label.setGeometry(QtCore.QRect(10, 30, 81, 17))
self.label.setObjectName("label")
self.spinBox = QtWidgets.QSpinBox(self.centralwidget)
self.spinBox.setGeometry(QtCore.QRect(150, 30, 48, 26))
self.spinBox.setProperty("value", self.main_time)
self.spinBox.setObjectName("spinBox")
self.label_2 = QtWidgets.QLabel(self.centralwidget)
self.label_2.setGeometry(QtCore.QRect(10, 80, 121, 17))
self.label_2.setObjectName("label_2")
self.label_3 = QtWidgets.QLabel(self.centralwidget)
self.label_3.setGeometry(QtCore.QRect(10, 130, 121, 17))
self.label_3.setObjectName("label_3")
self.spinBox_2 = QtWidgets.QSpinBox(self.centralwidget)
self.spinBox_2.setGeometry(QtCore.QRect(150, 130, 48, 26))
self.spinBox_2.setProperty("value", self.big_time)
self.spinBox_2.setObjectName("spinBox_2")
self.spinBox_3 = QtWidgets.QSpinBox(self.centralwidget)
self.spinBox_3.setGeometry(QtCore.QRect(150, 80, 48, 26))
self.spinBox_3.setProperty("value", self.small_time)
self.spinBox_3.setObjectName("spinBox_3")
self.pushButton = QtWidgets.QPushButton(self.centralwidget)
self.pushButton.setGeometry(QtCore.QRect(50, 190, 89, 25))
self.pushButton.setObjectName("pushButton")
self.pushButton.pressed.connect(self.window.close)
self.pushButton_2 = QtWidgets.QPushButton(self.centralwidget)
self.pushButton_2.setGeometry(QtCore.QRect(240, 190, 89, 25))
self.pushButton_2.setObjectName("pushButton_2")
self.pushButton_2.pressed.connect(self.changeTime)
pref_win.setCentralWidget(self.centralwidget)
self.menubar = QtWidgets.QMenuBar(pref_win)
self.menubar.setGeometry(QtCore.QRect(0, 0, 390, 22))
self.menubar.setObjectName("menubar")
pref_win.setMenuBar(self.menubar)
self.statusbar = QtWidgets.QStatusBar(pref_win)
self.statusbar.setObjectName("statusbar")
pref_win.setStatusBar(self.statusbar)
self.retranslateUi(pref_win)
QtCore.QMetaObject.connectSlotsByName(pref_win)
def retranslateUi(self, pref_win):
_translate = QtCore.QCoreApplication.translate
pref_win.setWindowTitle(_translate("pref_win", "Tomatimer - Preferences"))
self.label.setText(_translate("pref_win", "Focus time"))
self.label_2.setText(_translate("pref_win", "Short break time"))
self.label_3.setText(_translate("pref_win", "Long break time"))
self.pushButton.setText(_translate("pref_win", "Cancel"))
self.pushButton_2.setText(_translate("pref_win", "Apply"))
def changeTime(self):
self.small_time = self.spinBox_3.value()
self.big_time = self.spinBox_2.value()
self.main_time = self.spinBox.value()
print("main time value changed to", self.main_time)
print("small time value changed to", self.small_time)
print("big time value changed to", self.big_time)
self.data["main_time"] = self.main_time
self.data["short_break"] = self.small_time
self.data["long_break"] = self.big_time
self.data["subject"] = self.data["subject"]
jsonFile = open("settings.json", "w+")
jsonFile.write(json.dumps(self.data))
jsonFile.close()