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/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/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 3e24711..6fa1303 100644 --- a/README.md +++ b/README.md @@ -1,26 +1,39 @@ -

Python-Tkinter-Projects

- +# 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` + + + 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/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