-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathShortcut_Launcher.py
234 lines (177 loc) · 8.92 KB
/
Shortcut_Launcher.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
234
import tkinter
import tkinter.ttk
import os
main_window = tkinter.Tk()
# variable area
main_window_width = 800
main_window_height = 200
info_text = '''
Shortcut Launcher
-step 3-
C111032 KJW (AshCircle)
'''
button_column : int = 4
button_row : int = 2
button = [[0 for y in range(button_row)] for x in range(button_column)]
rex = 1/button_column #ratio
rey = 1/button_row #ratio
bgcolor = 'SystemButtonFace'
fgcolor = '#000000'
# function area
def WinResize(onoff):
main_window.resizable(onoff, onoff)
def TopMostScreen(onoff):
main_window.wm_attributes("-topmost", onoff)
def ColorChange(posit,r,g,b):
hex_R = format(r,'X')
hex_G = format(g,'X')
hex_B = format(b,'X')
colorcode = '#'+hex_R.zfill(2)+hex_G.zfill(2)+hex_B.zfill(2)
if posit == "bg":
global bgcolor
bgcolor = colorcode
ButtonCompose()
if posit == "fg":
global fgcolor
fgcolor = colorcode
ButtonCompose()
def ButtonCompose():
index = 0
for y in range(button_row):
for x in range(button_column):
if index == 0 : button[x][y] = tkinter.Button(main_window, text="notepad", command=Notepad, bg=bgcolor, fg=fgcolor, activebackground=bgcolor, activeforeground=fgcolor)
elif index == 1 : button[x][y] = tkinter.Button(main_window, text="calc", command=Calc, bg=bgcolor, fg=fgcolor, activebackground=bgcolor, activeforeground=fgcolor)
elif index == 2 : button[x][y] = tkinter.Button(main_window, text="c:", command=OpenFolder_C, bg=bgcolor, fg=fgcolor, activebackground=bgcolor, activeforeground=fgcolor)
elif index == 3 : button[x][y] = tkinter.Button(main_window, text="http://google.com", command=OpenWebsite_Google, bg=bgcolor, fg=fgcolor, activebackground=bgcolor, activeforeground=fgcolor)
else : button[x][y] = tkinter.Button(main_window, text="blank", bg=bgcolor, fg=fgcolor, activebackground=bgcolor, activeforeground=fgcolor)
button[x][y].place(relx=rex*x, rely=rey*y, relwidth = rex, relheight = rey)
index += 1
def Notepad():
os.startfile('notepad')
def Calc():
os.startfile('calc')
def OpenFolder_C():
os.startfile('c:')
def OpenWebsite_Google():
os.system("explorer http://google.com")
def ButtonChange(x,y):
global button_column
global button_row
global button
global rex
global rey
button_column = x
button_row = y
button = [[0 for y in range(button_row)] for x in range(button_column)]
rex = 1/button_column #ratio
rey = 1/button_row #ratio
ButtonCompose()
# Menu area
def SettingMenu():
setting_window=tkinter.Toplevel(main_window)
setting_window.title("프로그램 설정")
setting_window.geometry("300x200+100+100")
setting_window.resizable(False, False)
notebook=tkinter.ttk.Notebook(setting_window)
notebook.place(relx=0, rely=0, relwidth = 1, relheight = 1)
# frame no.1 area
frame1=tkinter.Frame(setting_window)
notebook.add(frame1, text="창 옵션")
# frame 1 - winresize
lbframe_winresize=tkinter.LabelFrame(frame1, text="창 크기 조정 옵션")
lbframe_winresize.place(relx=0, rely=0, relwidth = 1, relheight = 1/2)
winresize_onoff=tkinter.IntVar()
winresize_on = tkinter.Radiobutton(lbframe_winresize, text="켜기", value=1, variable=winresize_onoff, command=lambda: WinResize(1))
winresize_on.place(relx=0, rely=0, relwidth = 1, relheight = 1/2)
winresize_off = tkinter.Radiobutton(lbframe_winresize, text="끄기", value=2, variable=winresize_onoff, command=lambda: WinResize(0))
winresize_off.place(relx=0, rely=1/2, relwidth = 1, relheight = 1/2)
# frame 1 - topmost
lbframe_topmost=tkinter.LabelFrame(frame1, text="항상 위 옵션")
lbframe_topmost.place(relx=0, rely=1/2, relwidth = 1, relheight = 1/2)
topmost_onoff=tkinter.IntVar()
topmost_on = tkinter.Radiobutton(lbframe_topmost, text="켜기", value=1, variable=topmost_onoff, command=lambda: TopMostScreen(1))
topmost_on.place(relx=0, rely=0, relwidth = 1, relheight = 1/2)
topmost_off = tkinter.Radiobutton(lbframe_topmost, text="끄기", value=2, variable=topmost_onoff, command=lambda: TopMostScreen(0))
topmost_off.place(relx=0, rely=1/2, relwidth = 1, relheight = 1/2)
# frame no.2 area - colorchange
frame2=tkinter.Frame(setting_window)
notebook.add(frame2, text="프로그램 색상")
color_intro = tkinter.Label(frame2, text="R,G,B 값을 각각 0~255 범위 내로 입력해 주세요.", width=10, height=5)
color_intro.place(relx=0, rely=0, relwidth = 1, relheight = 1/6)
def ValueCheck_Color(self):
color_intro.config(text="R,G,B 값을 각각 0~255 범위 내로 입력해 주세요.")
valid = False
if self.isdigit():
if (int(self) <= 255 and int(self) >= 0):
valid = True
elif self == '':
valid = True
return valid
def ValueError_Color(self):
color_intro.config(text=str(self) + "은 범위에 속하지 않습니다.")
validate_command_color=(frame2.register(ValueCheck_Color), '%P')
invalid_command_color=(frame2.register(ValueError_Color), '%P')
spinbox_r=tkinter.Spinbox(frame2, fg="red", from_ = 0, to = 255, validate = 'all', validatecommand = validate_command_color, invalidcommand=invalid_command_color)
spinbox_r.place(anchor='n', relx=1/4, rely=1/4, relwidth = 1/3)
spinbox_g=tkinter.Spinbox(frame2, fg="green", from_ = 0, to = 255, validate = 'all', validatecommand = validate_command_color, invalidcommand=invalid_command_color)
spinbox_g.place(anchor='n', relx=1/4, rely=2/4, relwidth = 1/3)
spinbox_b=tkinter.Spinbox(frame2, fg="blue", from_ = 0, to = 255, validate = 'all', validatecommand = validate_command_color, invalidcommand=invalid_command_color)
spinbox_b.place(anchor='n', relx=1/4, rely=3/4, relwidth = 1/3)
apply_bgcolor = tkinter.Button(frame2, text = "배경 색에 적용", command=lambda :ColorChange('bg', int(spinbox_r.get()), int(spinbox_g.get()), int(spinbox_b.get())))
apply_bgcolor.place(anchor='n', relx = 3/4, rely=1/3)
apply_fgcolor = tkinter.Button(frame2, text = "폰트 색에 적용", command=lambda :ColorChange('fg', int(spinbox_r.get()), int(spinbox_g.get()), int(spinbox_b.get())))
apply_fgcolor.place(anchor='n', relx = 3/4, rely=2/3)
# frame no.3 area - buttonchange
frame3=tkinter.Frame(setting_window)
notebook.add(frame3, text="버튼 개수 조정")
buttonchange_intro = tkinter.Label(frame3, text="버튼 수를 각각 2~10 범위 내로 입력해 주세요.", width=10, height=5)
buttonchange_intro.place(relx=0, rely=0, relwidth = 1, relheight = 1/6)
def ValueCheck_Button(self):
buttonchange_intro.config(text="버튼 수를 각각 2~10 범위 내로 입력해 주세요.")
valid = False
if self.isdigit():
if (int(self) <= 10 and int(self) >= 2):
valid = True
elif self == '':
valid = True
return valid
def ValueError_Button(self):
buttonchange_intro.config(text=str(self) + "은 범위에 속하지 않습니다.")
validate_command_button=(frame3.register(ValueCheck_Button), '%P')
invalid_command_button=(frame3.register(ValueError_Button), '%P')
values=[i for i in range(2, 11)]
combobox_x = tkinter.ttk.Combobox(frame3, height=9, values=values, validate = 'key', validatecommand = validate_command_button, invalidcommand=invalid_command_button)
combobox_x.place(anchor='n', relx=1/4, rely=1/5, relwidth = 1/3)
combobox_x.set("가로 버튼수")
combobox_y = tkinter.ttk.Combobox(frame3, height=9, values=values, validate = 'key', validatecommand = validate_command_button, invalidcommand=invalid_command_button)
combobox_y.place(anchor='n', relx=3/4, rely=1/5, relwidth = 1/3)
combobox_y.set("세로 버튼수")
apply_button = tkinter.Button(frame3, text = "적용", command=lambda :ButtonChange(int(combobox_x.get()),int(combobox_y.get())))
apply_button.place(anchor='n', relx=1/2, rely=3/5)
setting_window.mainloop()
def InfoMenu():
info_window = tkinter.Tk()
info_window.title("프로그램 정보")
info_window.geometry("300x100+200+200")
info_window.resizable(False, False)
info=tkinter.Label(info_window, text=info_text)
info.pack()
info_window.mainloop()
def CloseMenu():
main_window.quit()
main_window.destroy()
# window setting
main_window.title("Shortcut Launcher")
main_window.geometry(str(main_window_width)+"x"+str(main_window_height)+"+100+100")
WinResize(0)
TopMostScreen(0)
# menubar
menubar = tkinter.Menu(main_window)
menu_1 = tkinter.Menu(menubar, tearoff=0)
menu_1.add_command(label="프로그램 설정", command=SettingMenu)
menu_1.add_command(label="프로그램 정보", command=InfoMenu)
menu_1.add_command(label="프로그램 종료", command=CloseMenu)
menubar.add_cascade(label="메뉴", menu=menu_1)
main_window.config(menu=menubar)
ButtonCompose()
main_window.mainloop()