-
Notifications
You must be signed in to change notification settings - Fork 0
/
settings.py
175 lines (132 loc) · 5.36 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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
from tkinter import *
from DataSets import Settings
from DataSets import loadSettings
from tkinter import messagebox
import os
import dataPath as dp
DTP = dp.dataPath.dataPath
def ToggleHTML():
if Settings.html:
Settings.html = False
else:
Settings.html = True
def ToggleIntegratedHTML():
if Settings.integratedHTML:
Settings.integratedHTML = False
else:
Settings.integratedHTML = True
def ToggleEnterSend():
if Settings.enterSend:
Settings.enterSend = False
else:
Settings.enterSend = True
def VoiceOp():
Settings.Voice=True
Settings.Text=False
def TextOp():
Settings.Voice=False
Settings.Text=True
class BP_Var():
BrwPth = None
def close(root):
if os.path.exists(DTP+"\\Assets\\settings.cfg"):
os.remove(DTP+"\\Assets\\settings.cfg")
with open(DTP+"\\Assets\\settings.cfg", 'w+') as h:
set=""
if Settings.Voice:
set+="voice\n"
else:
set+="text\n"
if Settings.html:
set+="htmlON\n"
else:
set+="htmlOFF\n"
if Settings.integratedHTML:
set+="integratedHTMLON\n"
else:
set+="integratedHTMLOFF\n"
if Settings.enterSend:
set+="EnterSendON\n"
else:
set+="EnterSendOFF\n"
set+=BP_Var.BrwPth.get()+'\n'
Settings.browserPath = BP_Var.BrwPth.get()
h.write(set)
root.destroy()
class Theme():
fg = None
bg = None
def start(*args):
try:
loadSettings()
root = Tk()
try:
root.iconphoto(False, args[0])
except:
pass
Theme.fg = 'black'
Theme.bg = 'white'
if Settings.theme == 'dark':
Theme.fg = '#aed9e6'
Theme.bg = '#212121'
root.minsize(300, 400)
root.resizable(0, 0)
root.title("Assistant on Windows - Settings")
canvas = Canvas(root, bg = Theme.bg)
canvas.pack()
C1 = Checkbutton(canvas, text = "Web Response", command = lambda: ToggleHTML(), \
onvalue = 1, offvalue = 0, height=2, \
width = 20, font=(dp.font, 18), cursor = 'dot', bg =Theme.bg, fg = Theme.fg, activebackground = Theme.bg, activeforeground = Theme.fg, selectcolor=Theme.bg)
C2 = Checkbutton(canvas, text = "Integrated Web Response\n(Experimental-TextOnly)", command = lambda: ToggleIntegratedHTML(), \
onvalue = 1, offvalue = 0, height=2, \
width = 20, font=(dp.font, 18), cursor = 'dot', bg =Theme.bg, fg = Theme.fg, activebackground = Theme.bg, activeforeground = Theme.fg, selectcolor=Theme.bg)
C3 = Checkbutton(canvas, text = "Enter To ASK", command = lambda: ToggleEnterSend(), \
onvalue = 1, offvalue = 0, height=2, \
width = 20, font=(dp.font, 18), cursor = 'dot', bg =Theme.bg, fg = Theme.fg, activebackground = Theme.bg, activeforeground = Theme.fg, selectcolor=Theme.bg)
if Settings.html:
C1.select()
if Settings.integratedHTML:
C2.select()
if Settings.enterSend:
C3.select()
C1.pack(padx=5, pady=5)
C2.pack(padx=5, pady=5)
C3.pack(padx=5, pady=5)
BP_Var.BrwPth = Entry(canvas, font=(dp.font, 15), width = 60, bg = Theme.bg, fg=Theme.fg)
LP = Label(canvas, text="Browser Path: (should end with \' %s\')", font=(dp.font, 15), bg = Theme.bg, fg =Theme.fg)
LP.pack()
BP_Var.BrwPth.insert(0, Settings.browserPath)
BP_Var.BrwPth.pack(pady=5)
V = Radiobutton(canvas, borderwidth=10, text="Voice Input", value=1,\
font=(dp.font, 24), cursor = 'dot', command=lambda:VoiceOp(), bg =Theme.bg, fg = Theme.fg, activebackground = Theme.bg, activeforeground = Theme.fg, selectcolor=Theme.bg)
T = Radiobutton(canvas, borderwidth=10, text="Text Input (WebResponse Recommended)", value=0,\
font=(dp.font, 24), cursor = 'dot', command=lambda:TextOp(), bg =Theme.bg, fg = Theme.fg, activebackground = Theme.bg, activeforeground = Theme.fg, selectcolor=Theme.bg)
V.pack(pady=5, padx=10, anchor=W)
T.pack(pady=5, padx=10, anchor=W)
if Settings.Voice:
V.select()
else:
T.select()
WLabel = Label(canvas, font=(dp.font, 20), text="Restart App To Apply Changes", bg = Theme.bg, fg =Theme.fg)
WLabel.pack(padx=5, pady=5)
root.protocol("WM_DELETE_WINDOW", lambda:close(root))
root.mainloop()
except:
import traceback, sys
# Get current system exception
ex_type, ex_value, ex_traceback = sys.exc_info()
# Extract unformatter stack traces as tuples
trace_back = traceback.extract_tb(ex_traceback)
# Format stacktrace
stack_trace = list()
for trace in trace_back:
stack_trace.append("File : %s , Line : %d, Func.Name : %s, Message : %s" % (trace[0], trace[1], trace[2], trace[3]))
print("Exception type : %s " % ex_type.__name__)
print("Exception message : %s" %ex_value)
print("Stack trace : %s" %stack_trace)
messagebox.showerror('Google Assistant On Windows - ERROR', 'The Application couldn\'t be run properly!')
try:
h = open(DTP+'\\start.start', 'w+')
h.close()
except:
pass