-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
48 lines (40 loc) · 1.48 KB
/
main.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
import json
from PyQt5 import QtWidgets, QtGui
from logic import mywindow
def createSettingsFile():
with open("settings.json", "w") as write_file:
data = {'user_name': '', 'dimensions': [{'width': 1320, 'height': 565}]}
json.dump(data, write_file, indent=4)
def checkSettingsFile():
try:
read_write_file = open("settings.json", "r+")
if read_write_file:
data = json.load(read_write_file)
if 'user_name' not in data.keys():
data['user_name'] = ''
if 'dimensions' not in data.keys():
data['dimensions'] = [{'width': 1320, 'height': 565}]
read_write_file.seek(0)
json.dump(data, read_write_file, indent=4)
read_write_file.truncate()
else:
createSettingsFile()
except (FileNotFoundError, KeyError, json.decoder.JSONDecodeError):
createSettingsFile()
if __name__ == "__main__":
checkSettingsFile()
app = QtWidgets.QApplication([])
application = mywindow()
app.setQuitOnLastWindowClosed(True)
icon = QtGui.QIcon()
icon.addPixmap(QtGui.QPixmap("images/main_icon.ico"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
app.setWindowIcon(icon)
application.setWindowIcon(icon)
if 'Oxygen' in QtWidgets.QStyleFactory.keys():
app.setStyle('Oxygen')
elif 'Breeze' in QtWidgets.QStyleFactory.keys():
app.setStyle('Breeze')
else:
app.setStyle('Fusion')
application.show()
app.exec_()