diff --git a/Advance Youtube Downloader/yt-downloader.py b/Advance Youtube Downloader/yt-downloader.py index a380e2c..3ac99c1 100644 --- a/Advance Youtube Downloader/yt-downloader.py +++ b/Advance Youtube Downloader/yt-downloader.py @@ -1,3 +1,11 @@ +# =================== PASSED =========================== +# Fix Resolution Software Youtube Video Downloader +# Add someone variabel in video downloader +# And pop up show messagebox download started +# ====================================================== + + + # ================= Importing Modules =================== from tkinter import * import tkinter as tk @@ -10,9 +18,9 @@ from pytube import Playlist from tkinter.ttk import Progressbar from tkinter.scrolledtext import ScrolledText - +import os # =========================================================== - +youtubeLogo = os.path.join(os.getcwd(), "Advance Youtube Downloader\youtube.png") class YoutubeDownloader(): # ========== Video Path =================== @@ -45,15 +53,17 @@ def download_video(self): elif self.video_path.get() == "": messagebox.showerror("Error","Please provide Path") else: - try: - + # try: + # Just fix resolution video and add variabel in video downloader + # And create messagebox show info download started. self.url = self.video_url.get() self.path = self.video_path.get() - self.video = YouTube(self.url) - self.stream = self.video.streams.filter(only_audio=False).first() - print("download started",self.video.title) - - print("download completed",self.video.title) + self.video = YouTube(self.url).streams + self.stream = self.video.filter( + file_extension="mp4", res="720p", + only_audio=False + ).first() + messagebox.showinfo("Information Download Video", "Download Started Just Wait Pop Up Show For Done Download Video.") self.root = tk.Tk() self.root.geometry('300x150') @@ -83,7 +93,7 @@ def download_video(self): self.dow_details = ScrolledText(self.root,width=30,height=3,font=('verdana',8,'bold')) self.dow_details.place(x=20,y=70) - self.dow_details.insert(END,f'{self.video_path.get()}\n {self.video.title}') + self.dow_details.insert(END,f'{self.video_path.get()}') self.dow_success = Label(self.root,text="Video downloaded successfully .....",fg="red",font=('verdana',10,'bold'),bg="white") self.dow_success.place(x=10,y=120) @@ -91,9 +101,9 @@ def download_video(self): self.root.mainloop() - except: - time.sleep(10) - messagebox.showerror("Error","Unable to Download Video | Something went wrong !!") + # except: + # time.sleep(10) + # messagebox.showerror("Error","Unable to Download Video | Something went wrong !!") # ========================= End ============================== @@ -193,7 +203,7 @@ def __init__(self): self.design3 = Label(self.root,bg="red",width=3,height=6) self.design3.place(x=242,y=90) - self.yt_icon = ImageTk.PhotoImage(Image.open('youtube.png')) + self.yt_icon = ImageTk.PhotoImage(Image.open(youtubeLogo, mode="r")) self.logo = Label(self.root,image=self.yt_icon,bg="white") self.logo.place(x=220,y=70) diff --git a/Billing System/Bill.PNG b/Billing System/Bill.PNG new file mode 100644 index 0000000..a29663f Binary files /dev/null and b/Billing System/Bill.PNG differ diff --git a/Billing System/billing_system.py b/Billing System/billing_system.py new file mode 100644 index 0000000..69f50e6 --- /dev/null +++ b/Billing System/billing_system.py @@ -0,0 +1,423 @@ +from tkinter import* +import random +import os +from tkinter import messagebox + + +#===============main===================== +class Bill_App: + def __init__(self, root): + self.root = root + self.root.geometry("1350x700+0+0") + self.root.title("Billing Software") + bg_color = "#badc57" + title = Label(self.root, text="Billing Software", font=('times new roman', 30, 'bold'), pady=2, bd=12, bg="#badc57", fg="Black", relief=GROOVE) + title.pack(fill=X) + # ================variables======================= + self.sanitizer = IntVar() + self.mask = IntVar() + self.hand_gloves = IntVar() + self.syrup = IntVar() + self.cream = IntVar() + self.thermal_gun = IntVar() + # ============grocery============================== + self.rice = IntVar() + self.food_oil = IntVar() + self.wheat = IntVar() + self.spices = IntVar() + self.flour = IntVar() + self.maggi = IntVar() + #=============coldDrinks============================= + self.sprite = IntVar() + self.mineral = IntVar() + self.juice = IntVar() + self.coke = IntVar() + self.lassi = IntVar() + self.mountain_duo = IntVar() + # ==============Total product price================ + self.medical_price = StringVar() + self.grocery_price = StringVar() + self.cold_drinks_price = StringVar() + # ==============Customer========================== + self.c_name = StringVar() + self.c_phone = StringVar() + self.bill_no = StringVar() + x = random.randint(1000, 9999) + self.bill_no.set(str(x)) + self.search_bill = StringVar() + # ===============Tax================================ + self.medical_tax = StringVar() + self.grocery_tax = StringVar() + self.cold_drinks_tax = StringVar() + # =============customer retail details====================== + F1 = LabelFrame(self.root, text="Customer Details", font=('times new roman', 15, 'bold'), bd=10, fg="Black", bg="#badc57") + F1.place(x=0, y=80, relwidth=1) + + cname_lbl = Label(F1, text="Customer Name:", bg=bg_color, font=('times new roman', 15, 'bold')) + cname_lbl.grid(row=0, column=0, padx=20, pady=5) + cname_txt = Entry(F1, width=15, textvariable=self.c_name, font='arial 15', bd=7, relief=GROOVE) + cname_txt.grid(row=0, column=1, pady=5, padx=10) + + cphn_lbl = Label(F1, text="Customer Phone:", bg="#badc57", font=('times new roman', 15, 'bold')) + cphn_lbl.grid(row=0, column=2, padx=20, pady=5) + cphn_txt = Entry(F1, width=15, textvariable=self.c_phone, font='arial 15', bd=7, relief=GROOVE) + cphn_txt.grid(row=0, column=3, pady=5, padx=10) + + c_bill_lbl = Label(F1, text="Bill Number:", bg="#badc57", font=('times new roman', 15, 'bold')) + c_bill_lbl.grid(row=0, column=4, padx=20, pady=5) + c_bill_txt = Entry(F1, width=15, textvariable=self.search_bill, font='arial 15', bd=7, relief=GROOVE) + c_bill_txt.grid(row=0, column=5, pady=5, padx=10) + + bil_btn = Button(F1, text="Search", command=self.find_bill, width=10, bd=7, font=('arial', 12, 'bold'), relief=GROOVE) + bil_btn.grid(row=0, column=6, pady=5, padx=10) + + # ===================Medical==================================== + F2 = LabelFrame(self.root, text="Medical Purpose", font=('times new roman', 15, 'bold'), bd=10, fg="Black", bg="#badc57") + F2.place(x=5, y=180, width=325, height=380) + + sanitizer_lbl = Label(F2, text="Sanitizer", font=('times new roman', 16, 'bold'), bg="#badc57", fg="black") + sanitizer_lbl.grid(row=0, column=0, padx=10, pady=10, sticky='W') + sanitizer_txt = Entry(F2, width=10, textvariable=self.sanitizer, font=('times new roman', 16, 'bold'), bd=5, relief=GROOVE) + sanitizer_txt.grid(row=0, column=1, padx=10, pady=10) + + mask_lbl = Label(F2, text="Mask", font=('times new roman', 16, 'bold'), bg="#badc57", fg="black") + mask_lbl.grid(row=1, column=0, padx=10, pady=10, sticky='W') + mask_txt = Entry(F2, width=10, textvariable=self.mask, font=('times new roman', 16, 'bold'), bd=5, relief=GROOVE) + mask_txt.grid(row=1, column=1, padx=10, pady=10) + + hand_gloves_lbl = Label(F2, text="Hand Gloves", font=('times new roman', 16, 'bold'), bg="#badc57", fg="black") + hand_gloves_lbl.grid(row=2, column=0, padx=10, pady=10, sticky='W') + hand_gloves_txt = Entry(F2, width=10, textvariable=self.hand_gloves, font=('times new roman', 16, 'bold'), bd=5, relief =GROOVE) + hand_gloves_txt.grid(row=2, column=1, padx=10, pady=10) + + syrup_lbl = Label(F2, text="Syrup", font=('times new roman', 16, 'bold'), bg="#badc57", fg="black") + syrup_lbl.grid(row=3, column=0, padx=10, pady=10, sticky='W') + syrup_txt = Entry(F2, width=10, textvariable=self.syrup, font=('times new roman', 16, 'bold'), bd=5, relief=GROOVE) + syrup_txt.grid(row=3, column=1, padx=10, pady=10) + + cream_lbl = Label(F2, text="Cream", font=('times new roman', 16, 'bold'), bg = "#badc57", fg = "black") + cream_lbl.grid(row=4, column=0, padx=10, pady=10, sticky='W') + cream_txt = Entry(F2, width=10, textvariable=self.cream, font=('times new roman', 16, 'bold'), bd=5, relief=GROOVE) + cream_txt.grid(row=4, column=1, padx=10, pady=10) + + thermal_gun_lbl = Label(F2, text="Thermal Gun", font=('times new roman', 16, 'bold'), bg="#badc57", fg="black") + thermal_gun_lbl.grid(row=5, column=0, padx=10, pady=10, sticky='W') + thermal_gun_txt = Entry(F2, width=10, textvariable=self.thermal_gun, font=('times new roman', 16, 'bold'), bd=5, relief=GROOVE) + thermal_gun_txt.grid(row=5, column=1, padx=10, pady=10) + + # ==========GroceryItems========================= + F3 = LabelFrame(self.root, text="Grocery Items", font=('times new roman', 15, 'bold'), bd=10, fg="Black", bg="#badc57") + F3.place(x=340, y=180, width=325, height=380) + + rice_lbl = Label(F3, text="Rice", font=('times new roman', 16, 'bold'), bg="#badc57", fg="black") + rice_lbl.grid(row=0, column=0, padx=10, pady=10, sticky='W') + rice_txt = Entry(F3, width=10, textvariable=self.rice, font=('times new roman', 16, 'bold'), bd=5, relief=GROOVE) + rice_txt.grid(row=0, column=1, padx=10, pady=10) + + food_oil_lbl = Label(F3, text="Food Oil", font=('times new roman', 16, 'bold'), bg="#badc57", fg="black") + food_oil_lbl.grid(row=1, column=0, padx=10, pady=10, sticky='W') + food_oil_txt = Entry(F3, width=10, textvariable=self.food_oil, font=('times new roman', 16, 'bold'), bd=5, relief=GROOVE) + food_oil_txt.grid(row=1, column=1, padx=10, pady=10) + + wheat_lbl = Label(F3, text="Wheat", font=('times new roman', 16, 'bold'), bg="#badc57", fg="black") + wheat_lbl.grid(row=2, column=0, padx=10, pady=10, sticky='W') + wheat_txt = Entry(F3, width=10, textvariable=self.wheat, font=('times new roman', 16, 'bold'), bd=5, relief=GROOVE) + wheat_txt.grid(row=2, column=1, padx=10, pady=10) + + spices_lbl = Label(F3, text="Spices", font=('times new roman', 16, 'bold'), bg="#badc57", fg="black") + spices_lbl.grid(row=3, column=0, padx=10, pady=10, sticky='W') + spices_txt = Entry(F3, width=10, textvariable=self.spices, font=('times new roman', 16, 'bold'), bd=5, relief=GROOVE) + spices_txt.grid(row=3, column=1, padx=10, pady=10) + + flour_lbl = Label(F3, text="Flour", font=('times new roman', 16, 'bold'), bg="#badc57", fg="black") + flour_lbl.grid(row=4, column=0, padx=10, pady=10, sticky='W') + flour_txt = Entry(F3, width=10, textvariable=self.flour, font=('times new roman', 16, 'bold'), bd=5, relief=GROOVE) + flour_txt.grid(row=4, column=1, padx=10, pady=10) + + maggi_lbl = Label(F3, text="Maggi", font=('times new roman', 16, 'bold'), bg="#badc57", fg="black") + maggi_lbl.grid(row=5, column=0, padx=10, pady=10, sticky='W') + maggi_txt = Entry(F3, width=10, textvariable=self.maggi, font=('times new roman', 16, 'bold'), bd=5, relief=GROOVE) + maggi_txt.grid(row=5, column=1, padx=10, pady=10) + + # ===========ColdDrinks================================ + F4 = LabelFrame(self.root, text="Cold Drinks", font=('times new roman', 15, 'bold'), bd=10, fg="Black", bg="#badc57") + F4.place(x=670, y=180, width=325, height=380) + + sprite_lbl = Label(F4, text="Sprite", font=('times new roman', 16, 'bold'), bg="#badc57", fg="black") + sprite_lbl.grid(row=0, column=0, padx=10, pady=10, sticky='W') + sprite_txt = Entry(F4, width=10, textvariable=self.sprite, font=('times new roman', 16, 'bold'), bd=5, relief=GROOVE) + sprite_txt.grid(row=0, column=1, padx=10, pady=10) + + mineral_lbl = Label(F4, text="Mineral Water", font=('times new roman', 16, 'bold'), bg="#badc57", fg="black") + mineral_lbl.grid(row=1, column=0, padx=10, pady=10, sticky='W') + mineral_txt = Entry(F4, width=10, textvariable=self.mineral, font=('times new roman', 16, 'bold'), bd=5, relief=GROOVE) + mineral_txt.grid(row=1, column=1, padx=10, pady=10) + + juice_lbl = Label(F4, text="Juice", font=('times new roman', 16, 'bold'), bg="#badc57", fg="black") + juice_lbl.grid(row=2, column=0, padx=10, pady=10, sticky='W') + juice_txt = Entry(F4, width=10, textvariable=self.juice, font=('times new roman', 16, 'bold'), bd=5, relief=GROOVE) + juice_txt.grid(row=2, column=1, padx=10, pady=10) + + coke_lbl = Label(F4, text="Coke", font=('times new roman', 16, 'bold'), bg="#badc57", fg="black") + coke_lbl.grid(row=3, column=0, padx=10, pady=10, sticky='W') + coke_txt = Entry(F4, width=10, textvariable=self.coke, font=('times new roman', 16, 'bold'), bd=5, relief=GROOVE) + coke_txt.grid(row=3, column=1, padx=10, pady=10) + + lassi_lbl = Label(F4, text="Lassi", font=('times new roman', 16, 'bold'), bg="#badc57", fg="black") + lassi_lbl.grid(row=4, column=0, padx=10, pady=10, sticky='W') + lassi_txt = Entry(F4, width=10, textvariable=self.lassi, font=('times new roman', 16, 'bold'), bd=5, relief=GROOVE) + lassi_txt.grid(row=4, column=1, padx=10, pady=10) + + mountain_duo_lbl = Label(F4, text="Mountain Duo", font=('times new roman', 16, 'bold'), bg="#badc57", fg="black") + mountain_duo_lbl.grid(row=5, column=0, padx=10, pady=10, sticky='W') + mountain_duo_txt = Entry(F4, width=10, textvariable=self.mountain_duo, font=('times new roman', 16, 'bold'), bd=5, relief=GROOVE) + mountain_duo_txt.grid(row=5, column=1, padx=10, pady=10) + + # =================BillArea====================== + F5 = Frame(self.root, bd=10, relief=GROOVE) + F5.place(x=1010, y=180, width=350, height=380) + + bill_title = Label(F5, text="Bill Area", font='arial 15 bold', bd=7, relief=GROOVE) + bill_title.pack(fill=X) + scroll_y = Scrollbar(F5, orient=VERTICAL) + self.txtarea = Text(F5, yscrollcommand=scroll_y.set) + scroll_y.pack(side=RIGHT, fill=Y) + scroll_y.config(command=self.txtarea.yview) + self.txtarea.pack(fill=BOTH, expand=1) + + # =======================ButtonFrame============= + F6 = LabelFrame(self.root, text="Bill Area", font=('times new roman', 14, 'bold'), bd=10, fg="Black", bg="#badc57") + F6.place(x=0, y=560, relwidth=1, height=140) + + m1_lbl = Label(F6, text="Total Medical Price", font=('times new roman', 14, 'bold'), bg="#badc57", fg="black") + m1_lbl.grid(row=0, column=0, padx=20, pady=1, sticky='W') + m1_txt = Entry(F6, width=18, textvariable=self.medical_price, font='arial 10 bold', bd=7, relief=GROOVE) + m1_txt.grid(row=0, column=1, padx=18, pady=1) + + m2_lbl = Label(F6, text="Total Grocery Price", font=('times new roman', 14, 'bold'), bg="#badc57", fg="black") + m2_lbl.grid(row=1, column=0, padx=20, pady=1, sticky='W') + m2_txt = Entry(F6, width=18, textvariable=self.grocery_price, font='arial 10 bold', bd=7, relief=GROOVE) + m2_txt.grid(row=1, column=1, padx=18, pady=1) + + m3_lbl = Label(F6, text="Total Cold Drinks Price", font=('times new roman', 14, 'bold'), bg="#badc57", fg="black") + m3_lbl.grid(row=2, column=0, padx=20, pady=1, sticky='W') + m3_txt = Entry(F6, width=18, textvariable=self.cold_drinks_price, font='arial 10 bold', bd=7, relief=GROOVE) + m3_txt.grid(row=2, column=1, padx=18, pady=1) + + m4_lbl = Label(F6, text="Medical Tax", font=('times new roman', 14, 'bold'), bg="#badc57", fg="black") + m4_lbl.grid(row=0, column=2, padx=20, pady=1, sticky='W') + m4_txt = Entry(F6, width=18, textvariable=self.medical_tax, font='arial 10 bold', bd=7, relief=GROOVE) + m4_txt.grid(row=0, column=3, padx=18, pady=1) + + m5_lbl = Label(F6, text="Grocery Tax", font=('times new roman', 14, 'bold'), bg="#badc57", fg="black") + m5_lbl.grid(row=1, column=2, padx=20, pady=1, sticky='W') + m5_txt = Entry(F6, width=18, textvariable=self.grocery_tax, font='arial 10 bold', bd=7, relief=GROOVE) + m5_txt.grid(row=1, column=3, padx=18, pady=1) + + m6_lbl = Label(F6, text="Cold Drinks Tax", font=('times new roman', 14, 'bold'), bg="#badc57", fg="black") + m6_lbl.grid(row=2, column=2, padx=20, pady=1, sticky='W') + m6_txt = Entry(F6, width=18, textvariable=self.cold_drinks_tax, font='arial 10 bold', bd=7, relief=GROOVE) + m6_txt.grid(row=2, column=3, padx=18, pady=1) + + # =======Buttons-====================================== + btn_f = Frame(F6, bd=7, relief=GROOVE) + btn_f.place(x=760, width=580, height=105) + + total_btn = Button(btn_f, command=self.total, text="Total", bg="#535C68", bd=2, fg="white", pady=15, width=12, font='arial 13 bold') + total_btn.grid(row=0, column=0, padx=5, pady=5) + + generateBill_btn = Button(btn_f, command=self.bill_area, text="Generate Bill", bd=2, bg="#535C68", fg="white", pady=12, width=12, font='arial 13 bold') + generateBill_btn.grid(row=0, column=1, padx=5, pady=5) + + clear_btn = Button(btn_f, command=self.clear_data, text="Clear", bg="#535C68", bd=2, fg="white", pady=15, width=12, font='arial 13 bold') + clear_btn.grid(row=0, column=2, padx=5, pady=5) + + exit_btn = Button(btn_f, command=self.exit_app, text="Exit", bd=2, bg="#535C68", fg="white", pady=15, width=12, font='arial 13 bold') + exit_btn.grid(row=0, column=3, padx=5, pady=5) + self.welcome_bill() + + + def total(self): + self.m_h_g_p = self.hand_gloves.get()*12 + self.m_s_p = self.sanitizer.get()*2 + self.m_m_p = self.mask.get()*5 + self.m_s_p = self.syrup.get()*30 + self.m_c_p = self.cream.get()*5 + self.m_t_g_p = self.thermal_gun.get()*15 + self.total_medical_price = float(self.m_m_p+self.m_h_g_p+self.m_s_p+self.m_c_p+self.m_t_g_p+self.m_s_p) + + self.medical_price.set("Rs. "+str(self.total_medical_price)) + self.c_tax = round((self.total_medical_price*0.05), 2) + self.medical_tax.set("Rs. "+str(self.c_tax)) + + self.g_r_p = self.rice.get()*10 + self.g_f_o_p = self.food_oil.get()*10 + self.g_w_p = self.wheat.get()*10 + self.g_s_p = self.spices.get()*6 + self.g_f_p = self.flour.get()*8 + self.g_m_p = self.maggi.get()*5 + self.total_grocery_price = float(self.g_r_p+self.g_f_o_p+self.g_w_p+self.g_s_p+self.g_f_p+self.g_m_p) + + self.grocery_price.set("Rs. " + str(self.total_grocery_price)) + self.g_tax = round((self.total_grocery_price*5), 2) + self.grocery_tax.set("Rs. " + str(self.g_tax)) + + self.c_d_s_p = self.sprite.get()*10 + self.c_d_w_p = self.mineral.get()*10 + self.c_d_j_p = self.juice.get()*10 + self.c_d_c_p = self.coke.get()*10 + self.c_d_l_p = self.lassi.get()*10 + self.c_m_d = self.mountain_duo.get()*10 + self.total_cold_drinks_price = float(self.c_d_s_p+self.c_d_w_p+self.c_d_j_p+self.c_d_c_p+self.c_d_l_p+self.c_m_d) + + self.cold_drinks_price.set("Rs. "+str(self.total_cold_drinks_price)) + self.c_d_tax = round((self.total_cold_drinks_price * 0.1), 2) + self.cold_drinks_tax.set("Rs. "+str(self.c_d_tax)) + + self.total_bill = float(self.total_medical_price+self.total_grocery_price+self.total_cold_drinks_price+self.c_tax+self.g_tax+self.c_d_tax) + + def welcome_bill(self): + self.txtarea.delete('1.0', END) + self.txtarea.insert(END, "\tWelcome Grocery Retail") + self.txtarea.insert(END, f"\nBill Number:{self.bill_no.get()}") + self.txtarea.insert(END, f"\nCustomer Name:{self.c_name.get()}") + self.txtarea.insert(END, f"\nPhone Number{self.c_phone.get()}") + self.txtarea.insert(END, f"\n================================") + self.txtarea.insert(END, f"\nProducts\t\tQTY\t\tPrice") + + def bill_area(self): + if self.c_name.get() == " " or self.c_phone.get() == " ": + messagebox.showerror("Error", "Customer Details Are Must") + elif self.medical_price.get() == "Rs. 0.0" and self.grocery_price.get() == "Rs. 0.0" and self.cold_drinks_price.get()=="Rs. 0.0": + messagebox.showerror("Error", "No Product Purchased") + else: + self.welcome_bill() + # ============medical=========================== + if self.sanitizer.get() != 0: + self.txtarea.insert(END, f"\n Sanitizer\t\t{self.sanitizer.get()}\t\t{self.m_s_p}") + if self.mask.get() != 0: + self.txtarea.insert(END, f"\n Mask\t\t{self.mask.get()}\t\t{self.m_m_p}") + if self.hand_gloves.get() != 0: + self.txtarea.insert(END, f"\n Hand Gloves\t\t{self.hand_gloves.get()}\t\t{self.m_h_g_p}") + if self.syrup.get() != 0: + self.txtarea.insert(END, f"\n Syrup\t\t{self.syrup.get()}\t\t{self.m_s_p}") + if self.cream.get() != 0: + self.txtarea.insert(END, f"\n Cream\t\t{self.cream.get()}\t\t{self.m_c_p}") + if self.thermal_gun.get() != 0: + self.txtarea.insert(END, f"\n Thermal Gun\t\t{self.sanitizer.get()}\t\t{self.m_t_g_p}") + # ==============Grocery============================ + if self.rice.get() != 0: + self.txtarea.insert(END, f"\n Rice\t\t{self.rice.get()}\t\t{self.g_r_p}") + if self.food_oil.get() != 0: + self.txtarea.insert(END, f"\n Food Oil\t\t{self.food_oil.get()}\t\t{self.g_f_o_p}") + if self.wheat.get() != 0: + self.txtarea.insert(END, f"\n Wheat\t\t{self.wheat.get()}\t\t{self.g_w_p}") + if self.spices.get() != 0: + self.txtarea.insert(END, f"\n Spices\t\t{self.spices.get()}\t\t{self.g_s_p}") + if self.flour.get() != 0: + self.txtarea.insert(END, f"\n Flour\t\t{self.flour.get()}\t\t{self.g_f_p}") + if self.maggi.get() != 0: + self.txtarea.insert(END, f"\n Maggi\t\t{self.maggi.get()}\t\t{self.g_m_p}") + #================ColdDrinks========================== + if self.sprite.get() != 0: + self.txtarea.insert(END, f"\n Sprite\t\t{self.sprite.get()}\t\t{self.c_d_s_p}") + if self.mineral.get() != 0: + self.txtarea.insert(END, f"\n Mineral\t\t{self.mineral.get()}\t\t{self.c_d_w_p}") + if self.juice.get() != 0: + self.txtarea.insert(END, f"\n Juice\t\t{self.juice.get()}\t\t{self.c_d_j_p}") + if self.coke.get() != 0: + self.txtarea.insert(END, f"\n Coke\t\t{self.coke.get()}\t\t{self.c_d_c_p}") + if self.lassi.get() != 0: + self.txtarea.insert(END, f"\n Lassi\t\t{self.cream.get()}\t\t{self.c_d_l_p}") + if self.mountain_duo.get() != 0: + self.txtarea.insert(END, f"\n Mountain Duo\t\t{self.sanitizer.get()}\t\t{self.c_m_d}") + self.txtarea.insert(END, f"\n--------------------------------") + # ===============taxes============================== + if self.medical_tax.get() != '0.0': + self.txtarea.insert(END, f"\n Medical Tax\t\t\t{self.medical_tax.get()}") + if self.grocery_tax.get() != '0.0': + self.txtarea.insert(END, f"\n Grocery Tax\t\t\t{self.grocery_tax.get()}") + if self.cold_drinks_tax.get() != '0.0': + self.txtarea.insert(END, f"\n Cold Drinks Tax\t\t\t{self.cold_drinks_tax.get()}") + + self.txtarea.insert(END, f"\n Total Bil:\t\t\t Rs.{self.total_bill}") + self.txtarea.insert(END, f"\n--------------------------------") + self.save_bill() + + def save_bill(self): + op = messagebox.askyesno("Save Bill", "Do you want to save the bill?") + if op > 0: + self.bill_data = self.txtarea.get('1.0', END) + f1 = open("bills/"+str(self.bill_no.get())+".txt", "w") + f1.write(self.bill_data) + f1.close() + messagebox.showinfo("Saved", f"Bill no:{self.bill_no.get()} Saved Successfully") + else: + return + + def find_bill(self): + present = "no" + for i in os.listdir("bills/"): + if i.split('.')[0] == self.search_bill.get(): + f1 = open(f"bills/{i}", "r") + self.txtarea.delete("1.0", END) + for d in f1: + self.txtarea.insert(END, d) + f1.close() + present = "yes" + if present == "no": + messagebox.showerror("Error", "Invalid Bill No") + + def clear_data(self): + op = messagebox.askyesno("Clear", "Do you really want to Clear?") + if op > 0: + self.sanitizer.set(0) + self.mask.set(0) + self.hand_gloves.set(0) + self.syrup.set(0) + self.cream.set(0) + self.thermal_gun.set(0) + # ============grocery============================== + self.rice.set(0) + self.food_oil.set(0) + self.wheat.set(0) + self.spices.set(0) + self.flour.set(0) + self.maggi.set(0) + # =============coldDrinks============================= + self.sprite.set(0) + self.mineral.set(0) + self.juice.set(0) + self.coke.set(0) + self.lassi.set(0) + self.mountain_duo.set(0) + # ====================taxes================================ + self.medical_price.set("") + self.grocery_price.set("") + self.cold_drinks_price.set("") + + self.medical_tax.set("") + self.grocery_tax.set("") + self.cold_drinks_tax.set("") + + self.c_name.set("") + self.c_phone.set("") + + self.bill_no.set("") + x = random.randint(1000, 9999) + self.bill_no.set(str(x)) + + self.search_bill.set("") + self.welcome_bill() + + def exit_app(self): + op = messagebox.askyesno("Exit", "Do you really want to exit?") + if op > 0: + self.root.destroy() + + +root = Tk() +obj = Bill_App(root) +root.mainloop() + + diff --git a/Calculator with Images/300x430_background.png b/Calculator with Images/300x430_background.png new file mode 100644 index 0000000..79142b4 Binary files /dev/null and b/Calculator with Images/300x430_background.png differ diff --git a/Calculator with Images/Calc-icon.ico b/Calculator with Images/Calc-icon.ico new file mode 100644 index 0000000..2ea99bb Binary files /dev/null and b/Calculator with Images/Calc-icon.ico differ diff --git a/Calculator with Images/calculator_buttons_50x50/1.png b/Calculator with Images/calculator_buttons_50x50/1.png new file mode 100644 index 0000000..6db9a2d Binary files /dev/null and b/Calculator with Images/calculator_buttons_50x50/1.png differ diff --git a/Calculator with Images/calculator_buttons_50x50/10.png b/Calculator with Images/calculator_buttons_50x50/10.png new file mode 100644 index 0000000..9c75bef Binary files /dev/null and b/Calculator with Images/calculator_buttons_50x50/10.png differ diff --git a/Calculator with Images/calculator_buttons_50x50/11.png b/Calculator with Images/calculator_buttons_50x50/11.png new file mode 100644 index 0000000..f7e6c2b Binary files /dev/null and b/Calculator with Images/calculator_buttons_50x50/11.png differ diff --git a/Calculator with Images/calculator_buttons_50x50/12.png b/Calculator with Images/calculator_buttons_50x50/12.png new file mode 100644 index 0000000..fd29ec7 Binary files /dev/null and b/Calculator with Images/calculator_buttons_50x50/12.png differ diff --git a/Calculator with Images/calculator_buttons_50x50/13.png b/Calculator with Images/calculator_buttons_50x50/13.png new file mode 100644 index 0000000..2b207d2 Binary files /dev/null and b/Calculator with Images/calculator_buttons_50x50/13.png differ diff --git a/Calculator with Images/calculator_buttons_50x50/14.png b/Calculator with Images/calculator_buttons_50x50/14.png new file mode 100644 index 0000000..07bdbec Binary files /dev/null and b/Calculator with Images/calculator_buttons_50x50/14.png differ diff --git a/Calculator with Images/calculator_buttons_50x50/15.png b/Calculator with Images/calculator_buttons_50x50/15.png new file mode 100644 index 0000000..8e1666c Binary files /dev/null and b/Calculator with Images/calculator_buttons_50x50/15.png differ diff --git a/Calculator with Images/calculator_buttons_50x50/16.png b/Calculator with Images/calculator_buttons_50x50/16.png new file mode 100644 index 0000000..37c4227 Binary files /dev/null and b/Calculator with Images/calculator_buttons_50x50/16.png differ diff --git a/Calculator with Images/calculator_buttons_50x50/2.png b/Calculator with Images/calculator_buttons_50x50/2.png new file mode 100644 index 0000000..0eb3d90 Binary files /dev/null and b/Calculator with Images/calculator_buttons_50x50/2.png differ diff --git a/Calculator with Images/calculator_buttons_50x50/3.png b/Calculator with Images/calculator_buttons_50x50/3.png new file mode 100644 index 0000000..9e79b9b Binary files /dev/null and b/Calculator with Images/calculator_buttons_50x50/3.png differ diff --git a/Calculator with Images/calculator_buttons_50x50/4.png b/Calculator with Images/calculator_buttons_50x50/4.png new file mode 100644 index 0000000..7a08de7 Binary files /dev/null and b/Calculator with Images/calculator_buttons_50x50/4.png differ diff --git a/Calculator with Images/calculator_buttons_50x50/5.png b/Calculator with Images/calculator_buttons_50x50/5.png new file mode 100644 index 0000000..b98dc18 Binary files /dev/null and b/Calculator with Images/calculator_buttons_50x50/5.png differ diff --git a/Calculator with Images/calculator_buttons_50x50/6.png b/Calculator with Images/calculator_buttons_50x50/6.png new file mode 100644 index 0000000..11dcb2c Binary files /dev/null and b/Calculator with Images/calculator_buttons_50x50/6.png differ diff --git a/Calculator with Images/calculator_buttons_50x50/7.png b/Calculator with Images/calculator_buttons_50x50/7.png new file mode 100644 index 0000000..3aee27a Binary files /dev/null and b/Calculator with Images/calculator_buttons_50x50/7.png differ diff --git a/Calculator with Images/calculator_buttons_50x50/8.png b/Calculator with Images/calculator_buttons_50x50/8.png new file mode 100644 index 0000000..0a7c06a Binary files /dev/null and b/Calculator with Images/calculator_buttons_50x50/8.png differ diff --git a/Calculator with Images/calculator_buttons_50x50/9.png b/Calculator with Images/calculator_buttons_50x50/9.png new file mode 100644 index 0000000..514d75c Binary files /dev/null and b/Calculator with Images/calculator_buttons_50x50/9.png differ diff --git a/Calculator with Images/calculator_with_images.py b/Calculator with Images/calculator_with_images.py new file mode 100644 index 0000000..d6f3ef1 --- /dev/null +++ b/Calculator with Images/calculator_with_images.py @@ -0,0 +1,117 @@ +# Image resources are provided in the file +# Make sure you change the paths in the code + +from tkinter import * +from PIL import ImageTk , Image + +rt = Tk() +rt.title("Basic Calculator") +#Change path of ico file here +rt.iconbitmap('C:/imgs/icons/calc512px.ico') #CHANGE PATH INSIDE '' +rt.geometry("300x430") +#change path of Background file here +bg = ImageTk.PhotoImage(file="C:/imgs/300x430_bg.png") #CHANGE PATH INSIDE " " +bg_label = Label(rt, image=bg).place(x=0,y=0) + +# Entry Widget + +e = Entry(rt,width=35,borderwidth=10,font=("Times",10)) +e.grid(row=0,column=0,pady=20,padx=30,columnspan=3) + +# CHANGE YOUR PATHS HERE..!!!!! +# Example Img1 = ImageTk.PhotoImage(file="YOUR PATH HERE") + +Img1 = ImageTk.PhotoImage(file="C:/Users/irfan/OneDrive/Desktop/MO TECH/pngs50x50/1.png") +Img2 = ImageTk.PhotoImage(file="C:/Users/irfan/OneDrive/Desktop/MO TECH/pngs50x50/2.png") +Img3 = ImageTk.PhotoImage(file="C:/Users/irfan/OneDrive/Desktop/MO TECH/pngs50x50/3.png") +Img4 = ImageTk.PhotoImage(file="C:/Users/irfan/OneDrive/Desktop/MO TECH/pngs50x50/4.png") +Img5 = ImageTk.PhotoImage(file="C:/Users/irfan/OneDrive/Desktop/MO TECH/pngs50x50/5.png") +Img6 = ImageTk.PhotoImage(file="C:/Users/irfan/OneDrive/Desktop/MO TECH/pngs50x50/6.png") +Img7 = ImageTk.PhotoImage(file="C:/Users/irfan/OneDrive/Desktop/MO TECH/pngs50x50/7.png") +Img8 = ImageTk.PhotoImage(file="C:/Users/irfan/OneDrive/Desktop/MO TECH/pngs50x50/8.png") +Img9 = ImageTk.PhotoImage(file="C:/Users/irfan/OneDrive/Desktop/MO TECH/pngs50x50/9.png") +Img0 = ImageTk.PhotoImage(file="C:/Users/irfan/OneDrive/Desktop/MO TECH/pngs50x50/10.png") +ImgA = ImageTk.PhotoImage(file="C:/Users/irfan/OneDrive/Desktop/MO TECH/pngs50x50/11.png") +ImgS = ImageTk.PhotoImage(file="C:/Users/irfan/OneDrive/Desktop/MO TECH/pngs50x50/12.png") +ImgM = ImageTk.PhotoImage(file="C:/Users/irfan/OneDrive/Desktop/MO TECH/pngs50x50/13.png") +ImgD = ImageTk.PhotoImage(file="C:/Users/irfan/OneDrive/Desktop/MO TECH/pngs50x50/14.png") +ImgE = ImageTk.PhotoImage(file="C:/Users/irfan/OneDrive/Desktop/MO TECH/pngs50x50/15.png") +ImgCLR = ImageTk.PhotoImage(file="C:/Users/irfan/OneDrive/Desktop/MO TECH/pngs50x50/16.png") + + + +def button_click(number): + current = e.get() + e.delete(0, END) + e.insert(0, str(current) + str(number)) + + +def button_add(): + first_number = e.get() + global f_num + global maths + maths = "addition" + f_num = int(first_number) + e.delete(0, END) + + +def button_sub(): + first_number = e.get() + global f_num + global maths + maths = "subtraction" + f_num = int(first_number) + e.delete(0, END) + +def button_div(): + first_number = e.get() + global f_num + global maths + maths = "division" + f_num = int(first_number) + e.delete(0, END) + +def button_mult(): + first_number = e.get() + global f_num + global maths + maths = "multiplication" + f_num = int(first_number) + e.delete(0, END) + +def button_equals(): + second_number = e.get() + e.delete(0, END) + + if maths == "addition": + e.insert(0, f_num+int(second_number)) + if maths == "subtraction": + e.insert(0, f_num-int(second_number)) + if maths == "multiplication": + e.insert(0, f_num*int(second_number)) + if maths == "division": + e.insert(0, f_num/int(second_number)) + + +def button_clear(): + e.delete(0,END) + + # Defining Buttons +button1 = Button(rt,border="3",image=Img1,command= lambda:button_click(1)).grid(row= 1,column=0) +button2 = Button(rt,border="3",image=Img2,command= lambda:button_click(2)).grid(row= 1,column=1) +button3 = Button(rt,border="3",image=Img3,command= lambda:button_click(3)).grid(row= 1,column=2) +button4 = Button(rt,border="3",image=Img4,command= lambda:button_click(4)).grid(row= 2,column=0) +button5 = Button(rt,border="3",image=Img5,command= lambda:button_click(5)).grid(row= 2,column=1) +button6 = Button(rt,border="3",image=Img6,command= lambda:button_click(6)).grid(row= 2,column=2) +button7 = Button(rt,border="3",image=Img7,command= lambda:button_click(7)).grid(row= 3,column=0) +button8 = Button(rt,border="3",image=Img8,command= lambda:button_click(8)).grid(row= 3,column=1) +button9 = Button(rt,border="3",image=Img9,command= lambda:button_click(9)).grid(row= 3,column=2) +button0 = Button(rt,border="3",image=Img0,command= lambda:button_click(0)).grid(row= 4,column=1) +buttonA = Button(rt,border="3",image=ImgA,command= button_add).grid(row= 4,column=2) +buttonS = Button(rt,border="3",image=ImgS,command= button_sub).grid(row= 4,column=0) +buttonM = Button(rt,border="3",image=ImgM,command= button_mult).grid(row= 5,column=1) +buttonD = Button(rt,border="3",image=ImgD,command= button_div).grid(row= 5,column=0) +buttonE = Button(rt,border="3",image=ImgE,command= button_equals).grid(row= 5,column=2) +buttonCLR=Button(rt,border="3",image=ImgCLR,command=button_clear).grid(row= 6,column=1) + +rt.mainloop() diff --git a/Email Sender/send_email.py b/Email Sender/send_email.py index 4272c73..6db3573 100644 --- a/Email Sender/send_email.py +++ b/Email Sender/send_email.py @@ -1,150 +1,135 @@ from tkinter import * +from tkinter import ttk import tkinter as tk from PIL import ImageTk, Image from tkinter import messagebox import smtplib from tkinter.scrolledtext import ScrolledText - root = tk.Tk() +# Custom styles for hover effects +style = ttk.Style() +style.theme_use('clam') # You can choose a different theme if needed +style.map("C.TButton", + foreground=[('pressed', 'black'), ('active', 'blue')], + background=[('pressed', '!disabled', 'gray'), ('active', 'white')] +) +style.map("L.TButton", + foreground=[('pressed', 'black'), ('active', 'blue')], + background=[('pressed', '!disabled', 'gray'), ('active', 'orange')] +) -def Login(): - e = email.get() - p = password.get() - - if '@gmail.com' not in e or e == "" : - messagebox.showerror('Login error',"PLease Write the Valid Email") - elif p == "": - messagebox.showerror('Login error'," Password Shouldn't be Empty") - - else: - try: - - s = smtplib.SMTP('smtp.gmail.com', 587) - s.starttls() - s.login(e,p) #attempt to log into smtp server - messagebox.showinfo("Login Success","You have Logged to Gmail Successfully") - - - - - root = tk.Tk() - root.geometry('500x400') - - def Logout(): - s.quit() - root.destroy() - - - - header1 = Label(root,bg="orange",width=300,height=2) - header1.place(x=0,y=0) - - h2 = Label(root,text="Email Sender",bg="orange",fg="black",font= ('verdana',13,'bold')) - h2.place(x=175,y=5) - - logout = Button(root,text="Logout",padx=20,bg="orange",relief=RIDGE,borderwidth=1,font= ('verdana',10,'bold'),cursor="hand2",command=Logout) - logout.place(x=390,y=38) - - - - r = Label(root,text="Recipetent Email Address",font= ('verdana',10,'bold')) - r.place(x=130,y=130) - recipetent = Entry(root,width=30,relief=RIDGE,borderwidth=3) - recipetent.place(x=130,y=150) - - - - st = Label(root,text="Subject",font= ('verdana',10,'bold')) - st.place(x=130,y=190) - subject = Entry(root,width=30,relief=RIDGE,borderwidth=3) - subject.place(x=130,y=210) - - m = Label(root,text="Message",font= ('verdana',10,'bold')) - m.place(x=130,y=250) - - message = ScrolledText(root,width=40,height=5,relief=RIDGE,borderwidth=3) - message.place(x=130,y=270) - - - - def Send(): - r = recipetent.get() - st = subject.get() - m = message.get('1.0',END) - - if '@gmail.com' not in r or r == "": - messagebox.showerror('Sending Mail error',"Please Write the Valid Email") - elif m == "": - messagebox.showerror('Sending Mail error',"Message shouldn't be Empty") - - else: - s.sendmail(r,e,f'Subject :{st}\n\n {m}') - messagebox.showinfo("Success","Your Message has been send successfully") - - - - send = Button(root,text="Send",padx=30,relief=RIDGE,borderwidth=1,bg="orange",font= ('verdana',10,'bold'),cursor="hand2",command=Send) - send.place(x=350,y=360) - root.mainloop() - - - - - - - - - - except: - messagebox.showerror('Login error',"Failed to Login, Either Your Email or Password is Wrong nor You did Enable less secure Apps in gmail Setting") - - - - - +def on_enter(event): + event.widget.config(bg="orange") +def on_leave(event): + event.widget.config(bg="white") +def Login(): + e = email.get() + p = password.get() + + if '@gmail.com' not in e or e == "": + messagebox.showerror('Login error',"Please write a valid email") + elif p == "": + messagebox.showerror('Login error',"Password shouldn't be empty") + else: + try: + s = smtplib.SMTP('smtp.gmail.com', 587) + s.starttls() + s.login(e,p) + messagebox.showinfo("Login Success","You have logged into Gmail successfully") + root.withdraw() # Hide login window + + # Create the main window + main_window = tk.Toplevel() + main_window.geometry('500x400') + main_window.title('Email Sender') + + def Logout(): + s.quit() + main_window.destroy() + + header1 = Label(main_window, bg="orange", width=300, height=2) + header1.place(x=0, y=0) + + h2 = Label(main_window, text="Email Sender", bg="orange", fg="black", font=('verdana', 13, 'bold')) + h2.place(x=175, y=5) + + logout = ttk.Button(main_window, text="Logout", style="C.TButton", width=10, command=Logout) + logout.place(x=390, y=38) + + r = Label(main_window, text="Recipient Email Address", font=('verdana', 10, 'bold')) + r.place(x=130, y=130) + recipient = Entry(main_window, width=30, relief=RIDGE, borderwidth=3) + recipient.place(x=130, y=150) + + st = Label(main_window, text="Subject", font=('verdana', 10, 'bold')) + st.place(x=130, y=190) + subject = Entry(main_window, width=30, relief=RIDGE, borderwidth=3) + subject.place(x=130, y=210) + + m = Label(main_window, text="Message", font=('verdana', 10, 'bold')) + m.place(x=130, y=250) + + message = ScrolledText(main_window, width=40, height=5, relief=RIDGE, borderwidth=3) + message.place(x=130, y=270) + + def Send(): + r = recipient.get() + st = subject.get() + m = message.get('1.0', END) + + if '@gmail.com' not in r or r == "": + messagebox.showerror('Sending Mail error', "Please write a valid email") + elif m == "": + messagebox.showerror('Sending Mail error', "Message shouldn't be empty") + else: + s.sendmail(r, e, f'Subject :{st}\n\n {m}') + messagebox.showinfo("Success", "Your message has been sent successfully") + + send = ttk.Button(main_window, text="Send", style="C.TButton", width=10, command=Send) + send.place(x=350, y=360) + + main_window.mainloop() + + except: + messagebox.showerror('Login error', "Failed to login. Check your email or password.") root.title('Email Sender') root.geometry('400x300') root.maxsize(400,300) root.minsize(400,300) -header = Label(root,bg="orange",width=300,height=2) -header.place(x=0,y=0) +header = Label(root, bg="orange", width=300, height=2) +header.place(x=0, y=0) -h1 = Label(root,text="Email Sender",bg="orange",fg="black",font= ('verdana',13,'bold')) -h1.place(x=135,y=5) +h1 = Label(root, text="Email Sender", bg="orange", fg="black", font=('verdana', 13, 'bold')) +h1.place(x=135, y=5) img = ImageTk.PhotoImage(Image.open('gmail.png')) -logo = Label(root,image=img,borderwidth=0) -logo.place(x=150,y=38) - - -e = Label(root,text="Email Address",font= ('verdana',10,'bold')) -e.place(x=100,y=130) -email = Entry(root,width=30,relief=RIDGE,borderwidth=3) -email.place(x=100,y=150) - - - -p = Label(root,text="Password",font= ('verdana',10,'bold')) -p.place(x=100,y=190) -password = Entry(root,width=30,relief=RIDGE,borderwidth=3) -password.place(x=100,y=210) - - -login = Button(root,text="Login",padx=30,bg="orange",relief=RIDGE,borderwidth=1,font= ('verdana',10,'bold'),cursor="hand2",command=Login) -login.place(x=135,y=240) - - +logo = Label(root, image=img, borderwidth=0) +logo.place(x=150, y=38) +e = Label(root, text="Email Address", font=('verdana', 10, 'bold')) +e.place(x=100, y=130) +email = Entry(root, width=30, relief=RIDGE, borderwidth=3, font=('Arial', 10)) # Changed font here +email.place(x=100, y=150) +email.bind("", on_enter) +email.bind("", on_leave) +p = Label(root, text="Password", font=('verdana', 10, 'bold')) +p.place(x=100, y=190) +password = Entry(root, width=30, relief=RIDGE, borderwidth=3, font=('Arial', 10)) # Changed font here +password.place(x=100, y=210) +password.bind("", on_enter) +password.bind("", on_leave) +login = ttk.Button(root, text="Login", style="L.TButton", width=10, command=Login) # Changed style here +login.place(x=145, y=240) -root.mainloop() \ No newline at end of file +root.mainloop() diff --git a/Google Engine/google-search-engine.py b/Google Engine/google-search-engine.py index 6723440..59887b8 100644 --- a/Google Engine/google-search-engine.py +++ b/Google Engine/google-search-engine.py @@ -6,7 +6,7 @@ import googlesearch # ================== .............. End..........============================ -# ================== .......... Window Components........ ============================ +# ================== .......... Window Components........ =================== #creating main window root = tk.Tk() @@ -134,4 +134,4 @@ def search_query(): #===================== Load the Window ============================= root.mainloop() -#======================= End Code ===================================== \ No newline at end of file +#======================= End Code ===================================== diff --git a/Insta User Details/insta-user-details.py b/Insta User Details/insta-user-details.py index 29585ae..8cf4fcb 100644 --- a/Insta User Details/insta-user-details.py +++ b/Insta User Details/insta-user-details.py @@ -27,22 +27,8 @@ def pic(): details.delete(1.0,END) details.insert(1.0,f"\t username : {data['graphql']['user']['username']} \n followers : {data['graphql']['user']['edge_followed_by']['count']} following : {data['graphql']['user']['edge_follow']['count']} \n full name : {data['graphql']['user']['full_name']} \n Total post : {data['graphql']['user']['edge_owner_to_timeline_media']['count']} category : {data['graphql']['user']['category_enum']} \n Email : {data['graphql']['user']['business_email']} \nbio-link:{data['graphql']['user']['external_url']}private account:{data['graphql']['user']['is_private']} || verified account:{data['graphql']['user']['is_verified']} bussiness account:{data['graphql']['user']['is_business_account']} \n \n see profile picture" ) - - Button(innerframe1,text="click to see",relief=RAISED,borderwidth=2,font=('verdana',8,'bold'),bg='#248aa2',fg="white",command=pic).place(x=180,y=145) - - - - - - - - - - - - - + frame = Frame(root,width=400,height=300,relief=RIDGE,borderwidth=5,bg='#248aa2') frame.place(x=0,y=0) @@ -68,4 +54,4 @@ def pic(): details = Text(innerframe1,height=12,width=47,relief=RIDGE,borderwidth=5,highlightbackground="white", highlightcolor="white",font=('courier',9,'')) details.place(x=5,y=5) -root.mainloop() \ No newline at end of file +root.mainloop() diff --git a/Instant News Headlines (Tkinter + NewsApi)/.idea/.gitignore b/Instant News Headlines (Tkinter + NewsApi)/.idea/.gitignore new file mode 100644 index 0000000..26d3352 --- /dev/null +++ b/Instant News Headlines (Tkinter + NewsApi)/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/Instant News Headlines (Tkinter + NewsApi)/.idea/.name b/Instant News Headlines (Tkinter + NewsApi)/.idea/.name new file mode 100644 index 0000000..11a5d8e --- /dev/null +++ b/Instant News Headlines (Tkinter + NewsApi)/.idea/.name @@ -0,0 +1 @@ +main.py \ No newline at end of file diff --git a/Instant News Headlines (Tkinter + NewsApi)/.idea/News Headlines Sender.iml b/Instant News Headlines (Tkinter + NewsApi)/.idea/News Headlines Sender.iml new file mode 100644 index 0000000..d0876a7 --- /dev/null +++ b/Instant News Headlines (Tkinter + NewsApi)/.idea/News Headlines Sender.iml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/Instant News Headlines (Tkinter + NewsApi)/.idea/inspectionProfiles/profiles_settings.xml b/Instant News Headlines (Tkinter + NewsApi)/.idea/inspectionProfiles/profiles_settings.xml new file mode 100644 index 0000000..105ce2d --- /dev/null +++ b/Instant News Headlines (Tkinter + NewsApi)/.idea/inspectionProfiles/profiles_settings.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/Instant News Headlines (Tkinter + NewsApi)/.idea/misc.xml b/Instant News Headlines (Tkinter + NewsApi)/.idea/misc.xml new file mode 100644 index 0000000..dc9ea49 --- /dev/null +++ b/Instant News Headlines (Tkinter + NewsApi)/.idea/misc.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/Instant News Headlines (Tkinter + NewsApi)/.idea/modules.xml b/Instant News Headlines (Tkinter + NewsApi)/.idea/modules.xml new file mode 100644 index 0000000..e584c4b --- /dev/null +++ b/Instant News Headlines (Tkinter + NewsApi)/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/Instant News Headlines (Tkinter + NewsApi)/.idea/vcs.xml b/Instant News Headlines (Tkinter + NewsApi)/.idea/vcs.xml new file mode 100644 index 0000000..b2bdec2 --- /dev/null +++ b/Instant News Headlines (Tkinter + NewsApi)/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Instant News Headlines (Tkinter + NewsApi)/ReadMe b/Instant News Headlines (Tkinter + NewsApi)/ReadMe new file mode 100644 index 0000000..a85c7bc --- /dev/null +++ b/Instant News Headlines (Tkinter + NewsApi)/ReadMe @@ -0,0 +1,7 @@ +This is Simple News Headline Application made in Python with NewsAPi and Gui using TKinter + +Here are the TWo options : +1. Get headlines of your choice= in which we give different parameters given by user and get news from around the world. +2. This end give and generate random headlines. + + diff --git a/Instant News Headlines (Tkinter + NewsApi)/apitesting.py b/Instant News Headlines (Tkinter + NewsApi)/apitesting.py new file mode 100644 index 0000000..4cdaae0 --- /dev/null +++ b/Instant News Headlines (Tkinter + NewsApi)/apitesting.py @@ -0,0 +1,32 @@ +import requests +import tkinter as tk +def getnews(): + api_key="a8ab6d9bd5684d27bab671e76c15eb91" + url = "https://newsapi.org/v2/top-headlines?country=US&category=business&apiKey="+api_key + news=requests.get(url).json() + articles = news["articles"] + my_articles =[] + my_news="" + + for article in articles: + my_articles.append(article["title"]) + + for i in range(10): + my_news = my_news + my_articles[i] + "\n" + + label.config(text=my_news) + +canvas = tk.Tk() +canvas.geometry("1000x400") +canvas.title("News App") + + +button=tk.Button(canvas,font =24,text="GetHeadLines",command=getnews) +button.pack(pady = 20) + +label=tk.Label(canvas,font = 18,justify = "left") +label.pack(pady =20) + +canvas.mainloop() + + diff --git a/Instant News Headlines (Tkinter + NewsApi)/download.png b/Instant News Headlines (Tkinter + NewsApi)/download.png new file mode 100644 index 0000000..32280e6 Binary files /dev/null and b/Instant News Headlines (Tkinter + NewsApi)/download.png differ diff --git a/Instant News Headlines (Tkinter + NewsApi)/hackerrank.py b/Instant News Headlines (Tkinter + NewsApi)/hackerrank.py new file mode 100644 index 0000000..28ddc68 --- /dev/null +++ b/Instant News Headlines (Tkinter + NewsApi)/hackerrank.py @@ -0,0 +1,11 @@ +n=int(input()) + +if(n%2!=0): + print("Weird") +else: + if n>=2 & n<=5: + print("Not Weird") + elif n>=6 & n<=20: + print("Weird") + elif n>20: + print("Not Weird") \ No newline at end of file diff --git a/Instant News Headlines (Tkinter + NewsApi)/main.py b/Instant News Headlines (Tkinter + NewsApi)/main.py new file mode 100644 index 0000000..1391f14 --- /dev/null +++ b/Instant News Headlines (Tkinter + NewsApi)/main.py @@ -0,0 +1,146 @@ + +#tkinter module +from tkinter import * + +#image module +from PIL import Image, ImageTk + +#font from tkinter +from tkinter import font + +#requests module +import requests + +#random module +import random + +#main welcome window code +welcome = Tk() +welcome.title("Sami News ") +welcome.geometry('500x500') + +background = Image.open('—Pngtree—vector creative hot news tag_4265321.png') +resized_image = background.resize((500, 500), Image.ANTIALIAS) + + +#function to open second window +def openSecondWindow(): + selected_optioncountry = "" + selected_optioncategory="" + secondwindow = Toplevel() + secondwindow.title("Select Your Headlines Types") + secondwindow.geometry("1000x400") + bold_font = font.Font(family="Helvetica", size=12, weight="bold") + langlabel=Label(secondwindow,text="Select Country---US for United States of America",font=bold_font) + langlabel.pack() + + #saving options select from toggle menu + def save_option(): + nonlocal selected_optioncountry + selected_optioncountry= (var.get())[:2] + + #saving options from toggle menu + def save_option2(): + nonlocal selected_optioncategory + selected_optioncategory= var2.get() + + + #get news api from newsapi + def getnews(): + api_key = "a8ab6d9bd5684d27bab671e76c15eb91" + country = selected_optioncountry + cat= selected_optioncategory + url = f"https://newsapi.org/v2/top-headlines?country={country}&category={cat}&apiKey="+api_key + news = requests.get(url).json() + articles = news["articles"] + my_articles = [] + my_news = "" + + for article in articles: + my_articles.append(article["title"]) + + for i in range(10): + my_news += f"{i + 1}. {my_articles[i]}\n" + + button_gethealines.config(text=my_news) + #toggle menu code 1 + var = (StringVar()) + var.set("US-United States of America") + options = ["GB-Great Britian", "AU-Australia", "FR-France","DE-Germany","RU-Russia","TR-turkey","UA-Ukraine"] + drop_down = OptionMenu(secondwindow, var, *options) + drop_down.pack() + save_button = Button(secondwindow, text="Save Country", command=save_option,width=10,height=1,bg="red",fg="white") + save_button.place(x=100,y=20) + save_button.pack() + bold_font = font.Font(family="Helvetica", size=12, weight="bold") + categorylabel=Label(secondwindow,text="Select Category of News",font=bold_font) + categorylabel.pack() + + #toggle menu code 2 + var2 = (StringVar()) + var2.set("business") + options = ["sports", "health", "science","technology","general"] + drop_down2 = OptionMenu(secondwindow, var2, *options) + drop_down2.pack() + save_button2 = Button(secondwindow, text="Save Category", command=save_option2,width=10,height=1,bg="red",fg="white") + save_button2.pack() + button_gethealines = Button(secondwindow, text="Fetch News",command=getnews) + button_gethealines.pack() + + + secondwindow.mainloop() + + + +#second window of random news generator +def randomwindow(): + randomwindowtab=Toplevel() + randomwindowtab.title("Random News") + randomwindowtab.geometry("300x300") + + #get random news by random number generator and countries/categories generated from list + def randomnews(): + api_key = "a8ab6d9bd5684d27bab671e76c15eb91" + countries = ['uS','gb', 'au', 'fr', 'de', 'ru', 'tr', 'ua'] + categories = ['science', 'health', 'sports', 'technology', 'general'] + cot = random.randint(0, 7) + cat = random.randint(0, 4) + + url = f"https://newsapi.org/v2/top-headlines?country={(countries[cot])}&category={(categories[cat])}&apiKey=" + api_key + news = requests.get(url).json() + articles = news["articles"] + my_articles = [] + my_news = "" + + for article in articles: + my_articles.append(article["title"]) + for i in range(10): + my_news += f"{i + 1}. {my_articles[i]}\n" + b3.config(text=my_news) + + + #button in this window + b3 = Button(randomwindowtab,command=randomnews,text="Get Random News Now",activeforeground="red", pady=10, width=20, height=1) + b3.pack() + randomwindowtab.mainloop() + +#background image +tk_image = ImageTk.PhotoImage(resized_image) +label = Label(welcome, image=tk_image) +label.place(x=0, y=0, relwidth=1, relheight=1) +#button 1 +b1 = Button(welcome, command=openSecondWindow, text="Get News Headlines Of Your Choice", activeforeground="red", pady=10, width=30, height=1) +b1.place(x=100,y=90) +#button 2 +b2 = Button(welcome, command=randomwindow,text="Get Top10 Random News", activeforeground="red", pady=10, width=20, height=1) +b2.pack(side=BOTTOM) +b1.pack(side=BOTTOM) +bold_font = font.Font(family="Helvetica", size=12, weight="bold") +Welcometext = Label(welcome, text="Get Top Headlines Through News Api", font=bold_font) +Welcometext.pack() + + +welcome.mainloop() + + + diff --git a/Instant News Headlines (Tkinter + NewsApi)/newsicon.png b/Instant News Headlines (Tkinter + NewsApi)/newsicon.png new file mode 100644 index 0000000..dde497d Binary files /dev/null and b/Instant News Headlines (Tkinter + NewsApi)/newsicon.png differ diff --git "a/Instant News Headlines (Tkinter + NewsApi)/\342\200\224Pngtree\342\200\224vector creative hot news tag_4265321.png" "b/Instant News Headlines (Tkinter + NewsApi)/\342\200\224Pngtree\342\200\224vector creative hot news tag_4265321.png" new file mode 100644 index 0000000..6085f9e Binary files /dev/null and "b/Instant News Headlines (Tkinter + NewsApi)/\342\200\224Pngtree\342\200\224vector creative hot news tag_4265321.png" differ diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..5e60199 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2021 Aashishkumar123 + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/Pomodrone/pomodrone.py b/Pomodrone/pomodrone.py new file mode 100644 index 0000000..470d7fe --- /dev/null +++ b/Pomodrone/pomodrone.py @@ -0,0 +1,94 @@ +import tkinter as tk +from tkinter import messagebox +from PIL import Image, ImageTk +from playsound import playsound +import time + +class Pomodoro: + def __init__(self, root): + self.root = root + + def work_break(self, timer): + + # common block to display minutes + # and seconds on GUI + minutes, seconds = divmod(timer, 60) + self.min.set(f"{minutes:02d}") + self.sec.set(f"{seconds:02d}") + self.root.update() + time.sleep(1) + + def work(self): + timer = 25*60 + while timer >= 0: + pomo.work_break(timer) + if timer == 0: + + # once work is done play + # a sound and switch for break + playsound("sound.ogg") + messagebox.showinfo( + "Good Job", "Take A Break, \ + nClick Break Button") + timer -= 1 + + def break_(self): + timer = 5*60 + while timer >= 0: + pomo.work_break(timer) + if timer == 0: + + # once break is done, + # switch back to work + playsound("sound.ogg") + messagebox.showinfo( + "Times Up", "Get Back To Work, \ + nClick Work Button") + timer -= 1 + + def main(self): + + # GUI window configuration + self.root.geometry("450x455") + self.root.resizable(False, False) + self.root.title("Pomodoro Timer") + + # label + self.min = tk.StringVar(self.root) + self.min.set("25") + self.sec = tk.StringVar(self.root) + self.sec.set("00") + + self.min_label = tk.Label(self.root, + textvariable=self.min, font=( + "arial", 22, "bold"), bg="red", fg='black') + self.min_label.pack() + + self.sec_label = tk.Label(self.root, + textvariable=self.sec, font=( + "arial", 22, "bold"), bg="black", fg='white') + self.sec_label.pack() + + # add background image for GUI using Canvas widget + canvas = tk.Canvas(self.root) + canvas.pack(expand=True, fill="both") + img = Image.open('pomodoro.jpg') + bg = ImageTk.PhotoImage(img) + canvas.create_image(90, 10, image=bg, anchor="nw") + + # create three buttons with countdown function command + btn_work = tk.Button(self.root, text="Start", + bd=5, command=self.work, + bg="red", font=( + "arial", 15, "bold")).place(x=140, y=380) + btn_break = tk.Button(self.root, text="Break", + bd=5, command=self.break_, + bg="red", font=( + "arial", 15, "bold")).place(x=240, y=380) + + self.root.mainloop() + + +if __name__ == '__main__': + pomo = Pomodoro(tk.Tk()) + pomo.main() diff --git a/README.md b/README.md index 362ffff..6fa1303 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,39 @@ -

Python-Tkinter-Series

+# Python-GUI-Projects +

+ +## Description + +All the GUI projects that is built in Python. + +## Library Used +`import tkinter` + +## How to run +Running the script is really simple! Just open a terminal in the folder where your script is located and run the following command: + +## Projects List +`1. Advance Gui Youtube Downloader`
+`2. Dictionary Gui Application`
+`3. Email Sender Gui Application`
+`4. Instagram User detail Gui Application`
+`5. Name Generator Gui Application`
+`6. Notepad Gui Application`
+`7. Paint Gui Application`
+`8. Piano Gui Application`
+`9. Restruant Management System Gui Application`
+`10. Google Translator Gui Application`
+`11. Cafe Management System Gui Application`
+`12. Calculator Gui Application`
+`13. Calculator with Images Gui Application`
+`14. Calender Gui Application`
+`15. Currency Converter Gui Application`
+`16. SMS Sender Gui Application`
+`17. Url Shortener Gui Application`
+`18. Weather Gui Application`
+`19. Basic Gui Youtube Downloader`
+`20. Tic Tac Toe`
+`21. News Headlines Application` + + + -Python Tkinter GUI Projects diff --git a/Restruant Management System/readme.txt b/Restruant Management System/readme.txt index 2069242..d7d535a 100644 --- a/Restruant Management System/readme.txt +++ b/Restruant Management System/readme.txt @@ -1,6 +1,3 @@ -======================================================= - Project Created by Aashish Admin of @__pythonworld__ -======================================================= ========== Small Description about the project ============== @@ -35,12 +32,4 @@ copy the api and paste in api variable in a send() function code.. ===================================================== -Note ** - -If you face any issuse realted to the project like getting error in anywhere or you need to know something about this project , you can feel free to DM me on instagram @__pythonworld__ - -------------------------------------------------------------------------------------------------------------- - -============= Thank Your PYTHONWORLD ============== - -------------------------------------------------------------------------------------------------------------- diff --git a/Tic Tac Toe Game/README.md b/Tic Tac Toe Game/README.md new file mode 100644 index 0000000..012b85f --- /dev/null +++ b/Tic Tac Toe Game/README.md @@ -0,0 +1,21 @@ + +# Tic Tac Toe +

+ +## Description + +A Tic Tac Toe game built in Python. + +## Library Used +`import tkinter` + +## How to run +Running the script is really simple! Just open a terminal in the folder where your script is located and run the following command: + +```sh +python tic_tac_toe.py +``` + +## Author +[Anokh1](https://github.com/Anokh1) + diff --git a/Tic Tac Toe Game/tic_tac_toe.py b/Tic Tac Toe Game/tic_tac_toe.py new file mode 100644 index 0000000..0e5e3ab --- /dev/null +++ b/Tic Tac Toe Game/tic_tac_toe.py @@ -0,0 +1,247 @@ +from tkinter import * +from tkinter import messagebox + +root = Tk() +root.title('Tic Tac Toe Game') + +# Player 1 [X] starts first, Player 2 [O] continues +clicked = True +count = 0 + +# To disable all the buttons when someone has won the game +def disableButtons(): + button1.config(state=DISABLED) + button2.config(state=DISABLED) + button3.config(state=DISABLED) + + button4.config(state=DISABLED) + button5.config(state=DISABLED) + button6.config(state=DISABLED) + + button7.config(state=DISABLED) + button8.config(state=DISABLED) + button9.config(state=DISABLED) + +# To check whether did anyone won the game and restart the game when someone won the game +def checkWinner(): + global winner + winner = False + + # Player 1 [X] winning patterns + if button1["text"] == "X" and button2["text"] == "X" and button3["text"] == "X": + button1.config(bg="#80ffaa") #[X][X][X] + button2.config(bg="#80ffaa") #[O][O][ ] + button3.config(bg="#80ffaa") #[ ][ ][ ] + winner = True + messagebox.showinfo("Tic Tac Toe", "Player 1 is the Winner!") + disableButtons + start() + + elif button4["text"] == "X" and button5["text"] == "X" and button6["text"] == "X": + button4.config(bg="#80ffaa") #[O][O][ ] + button5.config(bg="#80ffaa") #[X][X][X] + button6.config(bg="#80ffaa") #[ ][ ][ ] + winner = True + messagebox.showinfo("Tic Tac Toe", "Player 1 is the Winner!") + disableButtons + start() + + elif button7["text"] == "X" and button8["text"] == "X" and button9["text"] == "X": + button7.config(bg="#80ffaa") #[ ][ ][ ] + button8.config(bg="#80ffaa") #[O][O][ ] + button9.config(bg="#80ffaa") #[X][X][X] + winner = True + messagebox.showinfo("Tic Tac Toe", "Player 1 is the Winner!") + disableButtons + start() + + elif button1["text"] == "X" and button4["text"] == "X" and button7["text"] == "X": + button1.config(bg="#80ffaa") #[X][O][ ] + button4.config(bg="#80ffaa") #[X][O][ ] + button7.config(bg="#80ffaa") #[X][ ][ ] + winner = True + messagebox.showinfo("Tic Tac Toe", "Player 1 is the Winner!") + disableButtons + start() + + elif button2["text"] == "X" and button5["text"] == "X" and button8["text"] == "X": + button2.config(bg="#80ffaa") #[O][X][ ] + button5.config(bg="#80ffaa") #[O][X][ ] + button8.config(bg="#80ffaa") #[ ][X][ ] + winner = True + messagebox.showinfo("Tic Tac Toe", "Player 1 is the Winner!") + disableButtons + start() + + elif button3["text"] == "X" and button6["text"] == "X" and button9["text"] == "X": + button3.config(bg="#80ffaa") #[ ][O][X] + button6.config(bg="#80ffaa") #[ ][O][X] + button9.config(bg="#80ffaa") #[ ][ ][X] + winner = True + messagebox.showinfo("Tic Tac Toe", "Player 1 is the Winner!") + disableButtons + start() + + elif button1["text"] == "X" and button5["text"] == "X" and button9["text"] == "X": + button1.config(bg="#80ffaa") #[X][O][ ] + button5.config(bg="#80ffaa") #[ ][X][ ] + button9.config(bg="#80ffaa") #[ ][O][X] + winner = True + messagebox.showinfo("Tic Tac Toe", "Player 1 is the Winner!") + disableButtons + start() + + elif button3["text"] == "X" and button5["text"] == "X" and button7["text"] == "X": + button3.config(bg="#80ffaa") #[ ][O][X] + button5.config(bg="#80ffaa") #[ ][X][ ] + button7.config(bg="#80ffaa") #[X][O][ ] + winner = True + messagebox.showinfo("Tic Tac Toe", "Player 1 is the Winner!") + disableButtons + start() + + # Player 2 [O] winning patterns + elif button1["text"] == "O" and button2["text"] == "O" and button3["text"] == "O": + button1.config(bg="#80ffaa") #[O][O][O] + button2.config(bg="#80ffaa") #[X][X][ ] + button3.config(bg="#80ffaa") #[X][ ][ ] + winner = True + messagebox.showinfo("Tic Tac Toe", "Player 2 is the Winner!") + disableButtons + start() + + elif button4["text"] == "O" and button5["text"] == "O" and button6["text"] == "O": + button4.config(bg="#80ffaa") #[X][X][ ] + button5.config(bg="#80ffaa") #[O][O][O] + button6.config(bg="#80ffaa") #[X][ ][ ] + winner = True + messagebox.showinfo("Tic Tac Toe", "Player 2 is the Winner!") + disableButtons + start() + + elif button7["text"] == "O" and button8["text"] == "O" and button9["text"] == "O": + button7.config(bg="#80ffaa") #[X][ ][ ] + button8.config(bg="#80ffaa") #[X][X][ ] + button9.config(bg="#80ffaa") #[O][O][O] + winner = True + messagebox.showinfo("Tic Tac Toe", "Player 2 is the Winner!") + disableButtons + start() + + elif button1["text"] == "O" and button4["text"] == "O" and button7["text"] == "O": + button1.config(bg="#80ffaa") #[O][X][X] + button4.config(bg="#80ffaa") #[O][X][ ] + button7.config(bg="#80ffaa") #[O][ ][ ] + winner = True + messagebox.showinfo("Tic Tac Toe", "Player 2 is the Winner!") + disableButtons + start() + + elif button2["text"] == "O" and button5["text"] == "O" and button8["text"] == "O": + button2.config(bg="#80ffaa") #[X][O][X] + button5.config(bg="#80ffaa") #[X][O][ ] + button8.config(bg="#80ffaa") #[ ][O][ ] + winner = True + messagebox.showinfo("Tic Tac Toe", "Player 2 is the Winner!") + disableButtons + start() + + elif button3["text"] == "O" and button6["text"] == "O" and button9["text"] == "O": + button3.config(bg="#80ffaa") #[X][X][O] + button6.config(bg="#80ffaa") #[ ][X][O] + button9.config(bg="#80ffaa") #[ ][ ][O] + winner = True + messagebox.showinfo("Tic Tac Toe", "Player 2 is the Winner!") + disableButtons + start() + + elif button1["text"] == "O" and button5["text"] == "O" and button9["text"] == "O": + button1.config(bg="#80ffaa") #[O][X][X] + button5.config(bg="#80ffaa") #[ ][O][ ] + button9.config(bg="#80ffaa") #[ ][X][O] + winner = True + messagebox.showinfo("Tic Tac Toe", "Player 2 is the Winner!") + disableButtons + start() + + elif button3["text"] == "O" and button5["text"] == "O" and button7["text"] == "O": + button3.config(bg="#80ffaa") #[X][X][O] + button5.config(bg="#80ffaa") #[ ][O][ ] + button7.config(bg="#80ffaa") #[O][X][ ] + winner = True + messagebox.showinfo("Tic Tac Toe", "Player 2 is the Winner!") + disableButtons + start() + +# To check whether the game is a draw +def checkDraw(): + global count, winner + + if count == 9 and winner == False: + messagebox.showerror("Tic Tac Toe", "Draw, play again!") + start() + +# To determine the buttons that Player 1 or Player 2 has clicked on +def buttonClicked(button): + global clicked, count + + if button["text"] == " " and clicked == True: + button["text"] = "X" + clicked = False + count += 1 + checkWinner() + checkDraw() + elif button["text"] == " " and clicked == False: + button["text"] = "O" + clicked = True + count += 1 + checkWinner() + checkDraw() + else: + messagebox.showerror("Tic Tac Toe", "Please select another box.") + +# To start or restart the game +def start(): + global button1, button2, button3, button4, button5, button6, button7, button8, button9 + global clicked, count + clicked = True + count = 0 + + # Building the buttons for the game + button1 = Button(root, text=" ", font=("Helvetica, 20"), height=3, width=7, bg="SystemButtonFace", command=lambda: buttonClicked(button1)) + button2 = Button(root, text=" ", font=("Helvetica, 20"), height=3, width=7, bg="SystemButtonFace", command=lambda: buttonClicked(button2)) + button3 = Button(root, text=" ", font=("Helvetica, 20"), height=3, width=7, bg="SystemButtonFace", command=lambda: buttonClicked(button3)) + + button4 = Button(root, text=" ", font=("Helvetica, 20"), height=3, width=7, bg="SystemButtonFace", command=lambda: buttonClicked(button4)) + button5 = Button(root, text=" ", font=("Helvetica, 20"), height=3, width=7, bg="SystemButtonFace", command=lambda: buttonClicked(button5)) + button6 = Button(root, text=" ", font=("Helvetica, 20"), height=3, width=7, bg="SystemButtonFace", command=lambda: buttonClicked(button6)) + + button7 = Button(root, text=" ", font=("Helvetica, 20"), height=3, width=7, bg="SystemButtonFace", command=lambda: buttonClicked(button7)) + button8 = Button(root, text=" ", font=("Helvetica, 20"), height=3, width=7, bg="SystemButtonFace", command=lambda: buttonClicked(button8)) + button9 = Button(root, text=" ", font=("Helvetica, 20"), height=3, width=7, bg="SystemButtonFace", command=lambda: buttonClicked(button9)) + + # Arranging the buttons on the screen for the game + button1.grid(row=0, column=0) + button2.grid(row=0, column=1) + button3.grid(row=0, column=2) + + button4.grid(row=1, column=0) + button5.grid(row=1, column=1) + button6.grid(row=1, column=2) + + button7.grid(row=2, column=0) + button8.grid(row=2, column=1) + button9.grid(row=2, column=2) + +# Create game menu +gameMenu = Menu(root) +root.config(menu = gameMenu) + +# Create game options menu +optionMenu = Menu(gameMenu, tearoff=False) +gameMenu.add_cascade(label="Options", menu=optionMenu) +optionMenu.add_command(label="Restart Game", command=start) + + +start() +root.mainloop() \ No newline at end of file diff --git a/calculator/calculator2.py b/calculator/calculator2.py new file mode 100644 index 0000000..93678c4 --- /dev/null +++ b/calculator/calculator2.py @@ -0,0 +1,55 @@ +# Inspirado no programa 'clac1.py' do livro "Python and Tkinter Programming" de John E.Grayson +from tkinter import * + +def frame(root, side): + w = Frame(master=root) + w.pack(side=side, expand=True, fill=BOTH, padx=(5, 0)) + return w + +def button(root, text, side, command=None, **kw): + w = Button(master=root, text=text, + command=command, relief=RIDGE, **kw) + w.pack(side=side, expand=True, fill=BOTH) + return w + +root = Frame() +display = StringVar() +frame_top = Frame(root,) +frame_top.pack(side=TOP, fill=BOTH, expand=YES) +Entry(master=frame_top, relief=SUNKEN, + textvariable=display, state=DISABLED).pack(side=LEFT, expand=YES, fill=BOTH, padx=5, pady=2) +Button(frame_top, text="C", + command=lambda w=display: w.set(''), + bg="red", fg="white", relief=RIDGE).pack(side=RIGHT, expand=False, padx=2) + + +for i in "987+ 654- 321* 0d./".split(): + frame2buttons = frame(root, TOP) + for char in i: + if char == "d": + button(frame2buttons, "00", LEFT, + lambda w=display: w.set(w.get()+"00")) + else: + + button(frame2buttons,char,LEFT, + lambda w=display, c='%s' % char: w.set(w.get()+c)) + + +def result(w, e=None): + s = w.get() + if '%' in s: + index = list(s).index('%') + list_s = list(s) + list_s.insert(0, '(') + list_s.insert(index+1, ')/100') + list_s[index+2] = '*' + s = ''.join(list_s) + + w.set(eval(s)) + +frame_bottom = frame(root, BOTTOM) +button(frame_bottom, "=", LEFT, command=lambda w=display: result(w), bg="red", fg="white") +Button(master=frame_bottom, text="%", relief=RIDGE, command=lambda w=display: w.set(w.get()+"%")).pack(side=LEFT, expand=False) + +root.pack(side=TOP, fill=BOTH, expand=True) +root.mainloop() diff --git a/calculator/tk-calculator.py b/calculator/tk-calculator.py index 9df29f0..7655640 100644 --- a/calculator/tk-calculator.py +++ b/calculator/tk-calculator.py @@ -1,5 +1,7 @@ +#importing modules import tkinter as tk from tkinter import * +#defining attributes of main window root = tk.Tk() root.geometry("170x230") root.title("Calculator") @@ -12,144 +14,92 @@ # <==================== Button Operation code starts here.. ==============> -def nine(): - inp.insert("end","9") -def eight(): - inp.insert("end","8") - -def seven(): - inp.insert("end","7") - -def six(): - inp.insert("end","6") - -def five(): - inp.insert("end","5") - -def four(): - inp.insert("end","4") - -def three(): - inp.insert("end","3") - -def two(): - inp.insert("end","2") - -def one(): - inp.insert("end","1") - -def zero(): - inp.insert("end","0") - -def double_zero(): - inp.insert("end","00") - -def dot(): - inp.insert("end",".") - -def plus(): - inp.insert("end","+") - -def minus(): - inp.insert("end","-") - -def mul(): - inp.insert("end","*") - -def divide(): - inp.insert("end","/") - -def modulus(): - inp.insert("end","%") def result(): - - - if inp.get() == "": - inp.insert("end","error") - elif inp.get()[0] == "0": - inp.delete(0,"end") - inp.insert("end","error") - - else: + try: + + if inp.get() == "": + inp.insert("end","error") + elif inp.get()[0] == "0": + inp.delete(0,"end") + inp.insert("end","error") + + else: res = inp.get() res = eval(res) inp.insert("end"," = ") inp.insert("end",res) - -def clear(): - inp.delete(0,"end") - - + except SyntaxError: + inp.insert("end","invalid input") # <============ end code ================> # <============= Button Design Code starts here.. ==================> - -clear = Button(root,text="C",width=2,command=clear,bg="red",fg="white",relief=RIDGE) +# using lambda instead of functions to make the use of buttons more clear +clear = Button(root,text="C",width=2,command=lambda:inp.delete(0,"end"),bg="red",fg="white",relief=RIDGE) clear.grid(row=0,sticky="w",padx=125) -nine = Button(text="9",width=2,command=nine,borderwidth=3,relief=RIDGE) +nine = Button(text="9",width=2,command=lambda:inp.insert("end","9"),borderwidth=3,relief=RIDGE) nine.grid(row=1,sticky="w",padx=15) -eight = Button(text="8",width=2,command=eight,borderwidth=3,relief=RIDGE) +eight = Button(text="8",width=2,command=lambda:inp.insert("end","8"),borderwidth=3,relief=RIDGE) eight.grid(row=1,sticky="w",padx=45) -seven = Button(root,text="7",width=2,command=seven,borderwidth=3,relief=RIDGE) +seven = Button(root,text="7",width=2,command=lambda:inp.insert("end","7"),borderwidth=3,relief=RIDGE) seven.grid(row=1,sticky="w",padx=75) -plus = Button(root,text="+",width=2,command=plus,borderwidth=3,relief=RIDGE) +plus = Button(root,text="+",width=2,command=lambda:inp.insert("end","+"),borderwidth=3,relief=RIDGE) plus.grid(row=1,sticky="e",padx=125) -six = Button(text="6",width=2,command=six,borderwidth=3,relief=RIDGE) +six = Button(text="6",width=2,command=lambda:inp.insert("end","6"),borderwidth=3,relief=RIDGE) six.grid(row=2,sticky="w",padx=15,pady=5) -five = Button(text="5",width=2,command=five,borderwidth=3,relief=RIDGE) +five = Button(text="5",width=2,command=lambda:inp.insert("end","5"),borderwidth=3,relief=RIDGE) five.grid(row=2,sticky="w",padx=45,pady=5) -four = Button(root,text="4",width=2,command=four,borderwidth=3,relief=RIDGE) +four = Button(root,text="4",width=2,command=lambda:inp.insert("end","4"),borderwidth=3,relief=RIDGE) four.grid(row=2,sticky="w",padx=75,pady=5) -minus = Button(root,text="-",width=2,command=minus,borderwidth=3,relief=RIDGE) +minus = Button(root,text="-",width=2,command=lambda:inp.insert("end","-"),borderwidth=3,relief=RIDGE) minus.grid(row=2,sticky="e",padx=125,pady=5) -three = Button(text="3",width=2,command=three,borderwidth=3,relief=RIDGE) +three = Button(text="3",width=2,command=lambda:inp.insert("end","3"),borderwidth=3,relief=RIDGE) three.grid(row=3,sticky="w",padx=15,pady=5) -two = Button(text="2",width=2,command=two,borderwidth=3,relief=RIDGE) +two = Button(text="2",width=2,command=lambda:inp.insert("end","2"),borderwidth=3,relief=RIDGE) two.grid(row=3,sticky="w",padx=45,pady=5) -one = Button(root,text="1",width=2,command=one,borderwidth=3,relief=RIDGE) +one = Button(root,text="1",width=2,command=lambda:inp.insert("end","1"),borderwidth=3,relief=RIDGE) one.grid(row=3,sticky="w",padx=75,pady=5) -multiply = Button(root,text="*",width=2,command=mul,borderwidth=3,relief=RIDGE) +multiply = Button(root,text="*",width=2,command=lambda:inp.insert("end","*"),borderwidth=3,relief=RIDGE) multiply.grid(row=3,sticky="e",padx=125,pady=5) -zero = Button(text="0",width=2,command=zero,borderwidth=3,relief=RIDGE) +zero = Button(text="0",width=2,command=lambda:inp.insert("end","0"),borderwidth=3,relief=RIDGE) zero.grid(row=4,sticky="w",padx=15,pady=5) -double_zero = Button(text="00",width=2,command=double_zero,borderwidth=3,relief=RIDGE) +double_zero = Button(text="00",width=2,command=lambda:inp.insert("end","00"),borderwidth=3,relief=RIDGE) double_zero.grid(row=4,sticky="w",padx=45,pady=5) -dot = Button(root,text=".",width=2,command=dot,borderwidth=3,relief=RIDGE) +dot = Button(root,text=".",width=2,command=lambda:inp.insert("end","."),borderwidth=3,relief=RIDGE) dot.grid(row=4,sticky="w",padx=75,pady=5) -divide = Button(root,text="/",width=2,command=divide,borderwidth=3,relief=RIDGE) +divide = Button(root,text="/",width=2,command=lambda:inp.insert("end","/"),borderwidth=3,relief=RIDGE) divide.grid(row=4,sticky="e",padx=125,pady=5) result = Button(root,text="=",width=10,command=result,bg="red",fg="white",borderwidth=3,relief=RIDGE) result.grid(row=5,sticky="w",padx=15,pady=5) -modulus = Button(root,text="%",width=2,command=modulus,borderwidth=3,relief=RIDGE) +modulus = Button(root,text="%",width=2,command=lambda:inp.insert("end","%"),borderwidth=3,relief=RIDGE) modulus.grid(row=5,sticky="e",padx=125,pady=5) root.mainloop() -# <============ end code ==============> \ No newline at end of file +# <============ end code ==============> diff --git a/compound_Interest.py/compundinterest.py b/compound_Interest.py/compundinterest.py new file mode 100644 index 0000000..cfe1757 --- /dev/null +++ b/compound_Interest.py/compundinterest.py @@ -0,0 +1,112 @@ +# import all classes / functions from the tkinter +from tkinter import * + +# Function for clearing the +# contents of all entry boxes +def clear_all() : + + # whole content of entry boxes is deleted + principal_field.delete(0, END) + rate_field.delete(0, END) + time_field.delete(0, END) + compound_field.delete(0, END) + + # set focus on the principal_field entry box + principal_field.focus_set() + + +# Function to find compound interest +def calculate_ci(): + + # get a content from entry box + principal = int(principal_field.get()) + + rate = float(rate_field.get()) + + time = int(time_field.get()) + + # Calculates compound interest + CI = principal * (pow((1 + rate / 100), time)) + + # insert method inserting the + # value in the text entry box. + compound_field.insert(10, CI) + + + +# Driver code +if __name__ == "__main__" : + + # Create a GUI window + root = Tk() + + # Set the background colour of GUI window + root.configure(background = 'dark blue') + + # Set the configuration of GUI window + root.geometry("400x250") + + # set the name of tkinter GUI window + root.title("Compound Interest Calculator") + + # Create a Principal Amount : label + label1 = Label(root, text = "Principal Amount(Rs) : ", + fg = 'white', bg = 'red') + + # Create a Rate : label + label2 = Label(root, text = "Rate(%) : ", + fg = 'white', bg = 'red') + + # Create a Time : label + label3 = Label(root, text = "Time(years) : ", + fg = 'white', bg = 'red') + + # Create a Compound Interest : label + label4 = Label(root, text = "Compound Interest : ", + fg = 'white', bg = 'red') + + # grid method is used for placing + # the widgets at respective positions + # in table like structure . + + # padx keyword argument used to set padding along x-axis . + # pady keyword argument used to set padding along y-axis . + label1.grid(row = 1, column = 0, padx = 10, pady = 10) + label2.grid(row = 2, column = 0, padx = 10, pady = 10) + label3.grid(row = 3, column = 0, padx = 10, pady = 10) + label4.grid(row = 5, column = 0, padx = 10, pady = 10) + + # Create a entry box + # for filling or typing the information. + principal_field = Entry(root) + rate_field = Entry(root) + time_field = Entry(root) + compound_field = Entry(root) + + # grid method is used for placing + # the widgets at respective positions + # in table like structure . + + # padx keyword argument used to set padding along x-axis . + # pady keyword argument used to set padding along y-axis . + principal_field.grid(row = 1, column = 1, padx = 10, pady = 10) + rate_field.grid(row = 2, column = 1, padx = 10, pady = 10) + time_field.grid(row = 3, column = 1, padx = 10, pady = 10) + compound_field.grid(row = 5, column = 1, padx = 10, pady = 10) + + # Create a Submit Button and attached + # to calculate_ci function + button1 = Button(root, text = "Submit", bg = "red", + fg = "black", command = calculate_ci) + + # Create a Clear Button and attached + # to clear_all function + button2 = Button(root, text = "Clear", bg = "red", + fg = "black", command = clear_all) + + button1.grid(row = 4, column = 1, pady = 10) + button2.grid(row = 6, column = 1, pady = 10) + + # Start the GUI + root.mainloop() + \ No newline at end of file diff --git a/tkinter-1.py b/tkinter-1.py index b61d94f..04bc05f 100644 --- a/tkinter-1.py +++ b/tkinter-1.py @@ -3,7 +3,8 @@ import tkinter as tk #calling Tk() method -root = tk.Tk() +root = tk.Tk() +#its used for creating gui window #title() method is used to change the title root.title("My GUI")