-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsettings.py
114 lines (91 loc) · 2.84 KB
/
settings.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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
import os
import sys
import configparser
import settings_dialog
import PyQt5
from PyQt5 import QtGui
from PyQt5.QtGui import QFont
"""
Settings with global variables
"""
pathsOfDocuments = []
listPaths = []
selectedRecipe = ""
loadedRecipe = ""
defaultRecipe = ""
zipsFolder = ""
tempFolder = ""
localPath = ""
sets = ""
font = ""
def getValue(form_field):
value = form_field
print("GET defalut Value: ", value)
return value
def getDefaultRecipe(form_field): # settings_dialog.settings_ui.combo_box_1.currentText()
defaultRecipe = form_field
print(defaultRecipe)
return defaultRecipe
"""
def getDefaultFontName():
return defaultFontName
def getDefaultFontSize():
return defaultFontSize
def getDefaultOutputName():
return defaultOutputName
"""
"""
def buildConfiguration():
confWriter = configparser.ConfigParser()
recipe = str(getValue(settings_dialog.settings_ui.combo_box_1.currentText()))
size = int(getValue(settings_dialog.settings_ui.spin_box_1.currentText()))
recipe = str(getValue(settings_dialog.settings_ui.combo_box_1.currentText()))
size = int(getValue(settings_dialog.settings_ui.spin_box_1.value()))
font = size = int(getValue(settings_dialog.settings_ui.spin_box_1.currentText()))
size = getDefaultValue()
font = getDefaultFontName()
outputName = getDefaultOutputName()
confWriter['user'] = {
'default-recipe': recipe,
'font-name': font,
'font-size': size,
'default-book-name': outputName
}
return confWriter
"""
def saveConfiguration(defaultRecipe, fontName, fontSize, bookName):
config = configparser.ConfigParser()
config['user'] = {'default-recipe': str(defaultRecipe),
'font-name': str(fontName),
'font-size': int(fontSize),
'default-book-name': str(bookName)}
with open('configuration.ini', 'w') as configfile:
config.write(configfile)
def loadConfiguration(configfile='configuration.ini'):
confReader = configparser.ConfigParser()
confReader.read(configfile)
return confReader
def prepareGlobalVariables():
global localPath
localPath = os.path.dirname(__file__)
global sets
sets = loadConfiguration()
global pathsOfDocuments
pathsOfDocuments = []
global zipsFolder
zipsFolder = "/zips/"
global tempFolder
tempFolder = "/temp/"
global listPaths
listPaths = []
global selectedRecipe
selectedRecipe = str(localPath + zipsFolder
+ sets['user']['default-recipe'])
global defaultRecipe
defaultRecipe = str(sets['user']['default-recipe'])
global font
font = QFont(sets['user']['font-name'],
int(sets['user']['font-size']))
prepareGlobalVariables()
sets = configparser.ConfigParser()
sets = loadConfiguration()