#بسم الله الرحمن الرحیم #یا صاحب الزمان(عج) from tkinter import * from tkinter import ttk from pyautogui import size from PIL import Image from pymsgbox import alert,confirm from tkinter import filedialog import sys def easy_convertor(): argvs = sys.argv[1:] try: path = argvs[0] format = argvs[1] img = Image.open(path) path2 = path.split(".") del path2[-1] path2.append(format) path3 = '.'.join(path2) img.save(path3) print("yesssssssssssssssss") sys.exit() except: return False def browse_image(): img = filedialog.askopenfilename(title="انتخاب تصویر") en1.delete(0,"end") en1.insert(0,img) def convert(): str1 = en1.get() img = Image.open(str1) str2 = str1.rpartition(".")[0] strd = f"{str2}.{comb1.get()}" img.save(strd) alert(title="نتیجه",text=".با موفقیت تبدیل شد") selected = confirm(title="باز کردن",text="بازش کنیم؟") if selected.lower() == "ok": Image.open(strd).show() en1.delete(0,"end") #easy_convertor() width_scr , height_scr = size() win = Tk() win.title("تغییر قالب عکس") win.geometry("%sx%s+%s+%s"%(width_scr//2,height_scr//2+100,width_scr//5,height_scr//5-50)) win.resizable(0,0) lbl1 = Label(win,text = "بسم الله الرحمن الرحیم",relief="solid",width=0) lbl1.place(height=50,x=width_scr//4-60,y=0) win['bg'] = "green" enstr = StringVar() combstr = StringVar() en1 = Entry(win,textvariable=enstr) en1.place(height=20,width=250,x=width_scr//4+40,y=150) en1.focus() msg1 = Message(win,text=":مسیر",bg="green") msg1.place(x=width_scr//4+300,y=148) btn1 = ttk.Button(win,text="انتخاب",command=browse_image) btn1.place(x=width_scr//4-100,y=148) comb1 = ttk.Combobox(win,textvariable=combstr) vals = ["png","jpg","jpeg"] comb1['values'] = vals comb1.current(0) comb1.place(x=width_scr//4+40,y=200) btn2 = ttk.Button(win,text = "تبدیل") btn2['command'] = lambda :convert() btn2.place(x=width_scr//4-100,y=198) mainmenu_v = Menu(win) win.configure(menu=mainmenu_v) mainmenu = Menu(mainmenu_v,tearoff=0) mainmenu_v.add_cascade(label = "برنامه",menu=mainmenu) mainmenu.add_command(label="سلام کردن", command=lambda :alert(title="!سلام",text="سلام بر شما کاربر گرامی!")) mainmenu.add_separator() mainmenu.add_command(label="خروج",command=win.destroy) helpmenu = Menu(mainmenu_v,tearoff=0) mainmenu_v.add_cascade(label = "راهنما",menu=helpmenu) helpmenu.add_command(label="توضیحات", command=lambda :alert(title="توضیحات", text=".برنامه حاضر،برای تبدیل قالب های مختلف عکس به یکدیگر کاربرد دارد") ) win.mainloop()