-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathConvertUI.py
More file actions
35 lines (31 loc) · 1.16 KB
/
Copy pathConvertUI.py
File metadata and controls
35 lines (31 loc) · 1.16 KB
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
import tkinter as tk
from PIL import Image
root = tk.Tk()
img = None
font = ('helvetica',12,'bold')
bg = 'blue'
fg = 'white'
width = 15
def getPNG():
global img
import_file_path = tk.filedialog.askopenfilename(filetypes=[("PNG File",'.png')])
img = Image.open(import_file_path)
def convertToICO():
global img
if img is None:
tk.messagebox.showerror("Error","No File selected")
else:
export_file_path=tk.filedialog.asksaveasfilename(defaultextension='.ico')
img.save(export_file_path)
tk.messagebox.showinfo("Success","File converted and saved")
root.title('PNG to ICO Converter')
canvas1 = tk.Canvas(root,width=500,height=350,bg='lgihtblue')
canvas1.pack()
label1 = tk.Label(root,text='PNG to ICO Converter',bg='lightblue')
label1.config(font=('helvetica',20))
canvas1.create_window(250,100,window=label1)
browseButton = tk.Button(text="Import PNG File",command=getPNG,bg=bg,fg=fg,font=font,width=width)
canvas1.create_window(250,150,window=browseButton)
saveAsButton = tk.Button(text='Convert PNG to ICO',command=convertToICO,bg=bg,fg=fg,font=font,width=width)
canvas1.create_window(250,200,window=saveAsButton)
root.mainloop()