forked from Cleanpakin/Project
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Setting.py
233 lines (206 loc) · 5.57 KB
/
Setting.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
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
from tkinter import messagebox
from tkinter import *
from PIL import Image, ImageTk
from Graph import currency_chart
# Color code
color1 = '#2e2c75'
color2 = '#11114f'
color3 = '#ffffff'
color4 = '#888dc9'
color5 = '#7efdd2'
def setting_UI(currency):
# Create setting UI
chart_option = Toplevel()
chart_option.geometry('300x320')
chart_option.title('Chart Setting')
chart_option.resizable(height = False, width = False)
# Add frame and background
chart_main = Frame(chart_option, width = 300, height = 320, bg=color2)
chart_main.grid(row=0, column=0)
# Add title
setting_icon = Image.open('image/Setting.png')
setting_icon = setting_icon.resize((25,25))
setting_icon = ImageTk.PhotoImage(setting_icon)
setting_title = Label(
chart_main,
image=setting_icon,
compound=RIGHT,
text = 'Chart Setting',
height=5,
padx=9,
pady=15,
anchor=CENTER,
font=('root 16 bold'),
bg=color2,
fg=color3
)
setting_title.place(x=60, y=7)
# Add chart type button
chart_text = Label(
chart_main,
text = 'Choose Chart Type',
width=20,
height=1,
padx=0,
pady=0,
relief='flat',
anchor='w',
font=('root 12 bold'),
bg=color2,
fg=color3
)
chart_text.place(x=45, y=50)
chart_type = [
('Line','line'),
('Candles','candle'),
('Bars','ohlc'),
('Area','area')
]
chart = StringVar()
chart.set('a')
num = 75
for text, type in chart_type:
chart_button = Radiobutton(
chart_main,
text = text,
variable=chart,
value=type,
anchor='w',
width=10,
font=('root 10 bold'),
bg=color2,
fg=color3,
activebackground=color2,
activeforeground=color3,
cursor='cross',
selectcolor='#0B0B45'
)
chart_button.place(x=40, y=num)
num+=23
# Add indicator text
indicator_text = Label(
chart_main,
text = 'Indicator Setting',
width=20,
height=1,
padx=0,
pady=0,
relief='flat',
anchor='w',
font=('root 12 bold'),
bg=color2,
fg=color3
)
indicator_text.place(x=45, y=175)
on_icon = Image.open('image/Switch-on.png')
on_icon = on_icon.resize((35,35))
on_icon = ImageTk.PhotoImage(on_icon)
off_icon = Image.open('image/Switch-off.png')
off_icon = off_icon.resize((35,35))
off_icon = ImageTk.PhotoImage(off_icon)
# Add moving average button
global ma_is_on
ma_is_on = False
def ma_switch():
global ma_is_on
if ma_is_on:
ma_button.config(image=off_icon)
ma_is_on = False
else:
ma_button.config(image=on_icon)
ma_is_on = True
ma_button = Button(
chart_main,
image=off_icon,
bg=color2,
activebackground=color2,
bd=0,
cursor='cross',
command=ma_switch
)
ma_button.place(x=45, y=200)
ma_text = Label(
chart_main,
text = 'Moving Average',
width=15,
height=1,
padx=0,
pady=13,
relief='flat',
anchor='w',
font=('root 10 bold'),
bg=color2,
fg=color3
)
ma_text.place(x=88, y=195)
ma_number = Entry(chart_main, width=8, justify=CENTER, font=('root 10'), relief=SOLID)
ma_number.place(x=200, y=208)
# Add volume button
global v_is_on
v_is_on = False
def v_switch():
global v_is_on
if v_is_on:
v_button.config(image=off_icon)
v_is_on = False
else:
v_button.config(image=on_icon)
v_is_on = True
v_button = Button(
chart_main,
image=off_icon,
bg=color2,
activebackground=color2,
bd=0,
cursor='cross',
command=v_switch
)
v_button.place(x=45, y=232)
v_text = Label(
chart_main,
text = 'Volume',
width=10,
height=1,
padx=0,
pady=13,
relief='flat',
anchor='w',
font=('root 10 bold'),
bg=color2,
fg=color3
)
v_text.place(x=88, y=227)
# Add setting button
def clicked_item():
if chart.get() == 'a':
messagebox.showinfo(message='Please select the chart type.')
else:
if ma_is_on and ma_number.get() == '':
messagebox.showinfo(message='Please enter the moving average number.')
else:
item = chart.get()
number = ma_number.get()
chart_option.destroy()
currency_chart(
item=item,
ma=ma_is_on,
v=v_is_on,
number=number,
currency=currency
)
finish = Button(
chart_main,
text='Create Chart',
width=18,
padx=5,
height=1,
bg=color1,
fg=color3,
activebackground=color1,
activeforeground=color3,
font=('root 12 bold'),
cursor='cross',
command=clicked_item
)
finish.place(x=50, y=270)
chart_option.mainloop()