├── Application for comparing excel sheets with Tkinter └── application_for_comparing_excel_sheets.py ├── Calculator with Tkinter └── calculator.py ├── Currency convertor with Tkinter └── currency_convertor.py ├── LICENSE ├── Login application with Tkinter ├── download.png ├── id-profile-user-icon--icon-search-engine-17.png └── login_app.py ├── Lyrics application with Tkinter ├── lyrics_app.py ├── musical note.ico └── piano.png ├── Password generator with Tkinter └── password_generator.py ├── Pictures converter application with Tkinter └── pictures_converter.py ├── Ping Pong game with Turtle └── ping_pong_game.py ├── Qr codes generator with Tkinter └── qr_codes_generator.py ├── Quick search with Tkinter └── quick_search.py ├── README.md ├── Rock Paper Scissors with Tkinter ├── game over.png ├── no winner.png ├── paper.png ├── rock-paper-scissors.ico ├── rock.png ├── rock_paper_scissors_tkinter.py └── scissors.png ├── Rock Scissors Paper └── rock_paper_scissors.py ├── Text to speech app with Tkinter ├── background.png ├── sound.ico └── text_to_speech.py ├── Tic Tac Toe with Tkinter └── game_tic_tac_toe.py └── Weather application for Europe with Tkinter └── weather_app_for_Europe.py /Application for comparing excel sheets with Tkinter/application_for_comparing_excel_sheets.py: -------------------------------------------------------------------------------- 1 | from tkinter import * 2 | from openpyxl.workbook import Workbook 3 | from openpyxl import load_workbook 4 | 5 | root = Tk() 6 | root.title("Excell compare.app") 7 | root.geometry("1000x500") 8 | root.config(bg="#EEEEEE") 9 | root.resizable(False, False) 10 | 11 | file_one_dict = {} 12 | file_two_dict = {} 13 | 14 | 15 | def check(): 16 | name_one = entry_file_first.get() 17 | name_two = entry_file_second.get() 18 | first_column = entry_column_one.get() 19 | second_column = entry_column_two.get() 20 | 21 | wb = Workbook() 22 | wb = load_workbook(name_one + '.xlsx') 23 | ws = wb.active 24 | column_a = ws[first_column.upper()] 25 | column_b = ws[second_column.upper()] 26 | list_column_a = [] 27 | list_column_b = [] 28 | for cell in column_a: 29 | list_column_a.append(cell.value) 30 | for cell in column_b: 31 | list_column_b.append(cell.value) 32 | for i in range(len(list_column_a)): 33 | file_one_dict[list_column_a[i]] = list_column_b[i] 34 | 35 | wb = Workbook() 36 | wb = load_workbook(name_two + '.xlsx') 37 | ws = wb.active 38 | column_a = ws[first_column.upper()] 39 | column_b = ws[second_column.upper()] 40 | list_column_a = [] 41 | list_column_b = [] 42 | for cell in column_a: 43 | list_column_a.append(cell.value) 44 | for cell in column_b: 45 | list_column_b.append(cell.value) 46 | for i in range(len(list_column_a)): 47 | file_two_dict[list_column_a[i]] = list_column_b[i] 48 | 49 | missing_documents_first_file = {} 50 | wrong_invoice_amount = {} 51 | missing_documents_second_file = {} 52 | for ch in file_one_dict: 53 | if ch not in file_two_dict: 54 | missing_documents_second_file[ch] = file_one_dict[ch] 55 | else: 56 | for item in file_two_dict: 57 | if ch == item: 58 | if file_two_dict[item] == file_one_dict[item]: 59 | continue 60 | else: 61 | wrong_invoice_amount[ch] = file_one_dict[ch] 62 | 63 | for ch in file_two_dict: 64 | if ch not in file_one_dict: 65 | missing_documents_first_file[ch] = file_two_dict[ch] 66 | 67 | result_window = Toplevel(root) 68 | result_window.title("Result") 69 | result_text = Text(result_window) 70 | result_text.insert(END, f"First file missing invoices:{missing_documents_first_file}\n" 71 | f"Second file missing invoices:{missing_documents_second_file}\n" 72 | f"Wrong invoice amount:{wrong_invoice_amount}") 73 | result_text.pack() 74 | 75 | 76 | file_one = Label(root, text="First file name", font=4) 77 | file_one.place(y=20) 78 | entry_file_first = Entry(root, font=4) 79 | entry_file_first.place(x=3, y=60) 80 | 81 | file_two = Label(root, text="Second file name", font=4) 82 | file_two.place(y=100) 83 | entry_file_second = Entry(root, font=4) 84 | entry_file_second.place(x=3, y=140) 85 | 86 | column_one = Label(root, text="First column needed", font=4) 87 | column_one.place(y=180) 88 | entry_column_one = Entry(root, font=4) 89 | entry_column_one.place(x=3, y=220) 90 | 91 | column_two = Label(root, text="Second column needed", font=4) 92 | column_two.place(y=260) 93 | entry_column_two = Entry(root, font=4) 94 | entry_column_two.place(x=3, y=300) 95 | 96 | checking_button = Button(root, text="Check for differences", font=3, command=check) 97 | checking_button.place(y=340) 98 | 99 | root.mainloop() 100 | -------------------------------------------------------------------------------- /Calculator with Tkinter/calculator.py: -------------------------------------------------------------------------------- 1 | from tkinter import * 2 | 3 | root = Tk() 4 | root.title("Noob Calculator :D") 5 | 6 | e = Entry(root, width=35, borderwidth=5) 7 | e.grid(row=0, column=0, columnspan=3, padx=20, pady=20) 8 | # box place - (row and column - always starting from zero), columnspan - number of boxes, padx/pady - cordinate system 9 | 10 | def button_for_number(number): 11 | current = e.get() 12 | e.delete(0, END) 13 | e.insert(0, str(current) + str(number)) 14 | 15 | # Function - button for the insert numbers of the bellow buttons, e.insert - concatenate next number 16 | 17 | def button_delete(): 18 | e.delete(0, END) 19 | # Define the function to delete everything in the entry box, then we dont need lambda, 20 | # just command=button_delete on the below 21 | 22 | def button_plus(): 23 | first_number = e.get() # getting the first using number 24 | global f_num # common function for saving the process and finishing with equal 25 | global total # adding in next global file, this will help for if statements and correcting the final results 26 | total = "plus" 27 | f_num = int(first_number) # converting to int 28 | e.delete(0, END) # clearing the text box 29 | 30 | def button_minus(): 31 | first_number = e.get() # getting the first using number 32 | global f_num # common function for saving the process and finishing with equal 33 | global total # adding in next global file 34 | total = "minus" 35 | f_num = int(first_number) # converting to int 36 | e.delete(0, END) 37 | 38 | def button_division(): 39 | first_number = e.get() # getting the first using number 40 | global f_num # common function for saving the process and finishing with equal 41 | global total # adding in next global file 42 | total = "div" 43 | f_num = int(first_number) # converting to int 44 | e.delete(0, END) 45 | 46 | def button_multiplication(): 47 | first_number = e.get() # getting the first using number 48 | global f_num # common function for saving the process and finishing with equal 49 | global total # adding in next global file 50 | total = "multip" 51 | f_num = int(first_number) # converting to int 52 | e.delete(0, END) 53 | 54 | def button_equal(): 55 | second_number = e.get() # same as button_plus, this time is not needed to use global 56 | e.delete(0, END) 57 | if total == "plus": 58 | e.insert(0, f_num + int(second_number)) # using the f_numb(global) then add the new number 59 | elif total == "minus": 60 | e.insert(0, f_num - int(second_number)) 61 | elif total == "div": 62 | e.insert(0, f_num / int(second_number)) 63 | elif total == "multip": 64 | e.insert(0, f_num * int(second_number)) 65 | 66 | 67 | one = Button(root, text="1", padx=40, pady=20, command=lambda: button_for_number(1)) 68 | two = Button(root, text="2", padx=40, pady=20, command=lambda: button_for_number(2)) 69 | three = Button(root, text="3", padx=40, pady=20, command=lambda: button_for_number(3)) 70 | four = Button(root, text="4", padx=40, pady=20, command=lambda: button_for_number(4)) 71 | five = Button(root, text="5", padx=40, pady=20, command=lambda: button_for_number(5)) 72 | six = Button(root, text="6", padx=40, pady=20, command=lambda: button_for_number(6)) 73 | seven = Button(root, text="7", padx=40, pady=20, command=lambda: button_for_number(7)) 74 | eight = Button(root, text="8", padx=40, pady=20, command=lambda: button_for_number(8)) 75 | nine = Button(root, text="9", padx=40, pady=20, command=lambda: button_for_number(9)) 76 | zero = Button(root, text="0", padx=40, pady=20, command=lambda: button_for_number(0)) 77 | 78 | # text(box), padx/pady(cordinate system), lambda add the number onto the entry box (button for number) 79 | 80 | plus = Button(root, text="+", padx=39, pady=20, command=button_plus) 81 | minus = Button(root, text="-", padx=40.4, pady=20, command=button_minus) 82 | division = Button(root, text="/", padx=40.5, pady=20, command=button_division) 83 | multiplication = Button(root, text="*", padx=40, pady=20, command=button_multiplication) 84 | delete = Button(root, text="Delete", padx=27, pady=20, command=button_delete) 85 | equal = Button(root, text="=", padx=39, pady=20, command=button_equal) 86 | for_fun = Button(root,text="Само", padx=30, pady=20, command=lambda: button_for_number("Само")) 87 | for_fun2 = Button(root,text="Локо", padx=30, pady=20, command=lambda: button_for_number(" Локо")) 88 | 89 | # grid defines correct place - it looks like square with small squares inside 90 | 91 | one.grid(row=3, column=0) 92 | two.grid(row=3, column=1) 93 | three.grid(row=3, column=2) 94 | 95 | four.grid(row=2, column=0) 96 | five.grid(row=2, column=1) 97 | six.grid(row=2, column=2) 98 | 99 | seven.grid(row=1, column=0) 100 | eight.grid(row=1, column=1) 101 | nine.grid(row=1, column=2) 102 | 103 | plus.grid(row=4, column=0) 104 | zero.grid(row=4, column=1) 105 | minus.grid(row=4, column=2) 106 | 107 | division.grid(row=5, column=0) 108 | delete.grid(row=5, column=1, columnspan=1) 109 | multiplication.grid(row=5, column=2) 110 | 111 | for_fun.grid(row=6, column=0) 112 | equal.grid(row=6, column=1) 113 | for_fun2.grid(row=6, column=2) 114 | 115 | root.mainloop() 116 | -------------------------------------------------------------------------------- /Currency convertor with Tkinter/currency_convertor.py: -------------------------------------------------------------------------------- 1 | from tkinter import * 2 | from forex_python.converter import CurrencyRates 3 | from tkinter.font import Font 4 | import tkinter.messagebox 5 | 6 | root = Tk() 7 | root.title("Currency convertor") 8 | root.config(bg="#F3E8FF") 9 | root.minsize(200, 100) 10 | my_font_of_text = Font(family="Ariel", size=15) 11 | currency = CurrencyRates() 12 | 13 | 14 | def currency_exchange(): 15 | global currency 16 | from_currency = variable1.get() 17 | to_currency = variable2.get() 18 | if from_currency == "CURRENCY" or to_currency == "CURRENCY" or from_currency == to_currency: 19 | tkinter.messagebox.showinfo("Error!", 20 | "Currency Not Selected or they are equal.\n" 21 | " Please select FROM and TO Currency from the menu.") 22 | 23 | amount = entry_box_from.get() 24 | current_list = [str(ch) for ch in amount] 25 | numbers = True 26 | for i in range(len(current_list)): 27 | if 0 <= ord(current_list[i]) <= 47 or 58 <= ord(current_list[i]) <= 127: 28 | numbers = False 29 | 30 | if numbers: 31 | result = currency.convert(from_currency, to_currency, float(amount)) 32 | entry_box_to.insert(0, result) 33 | else: 34 | tkinter.messagebox.showinfo("Error!", 35 | "You must use only numbers!") 36 | 37 | 38 | CurrenyCode_list = ["USD", "CAD", "CNY", "DKK", "EUR", "BGN", "NOK", "SEK"] 39 | 40 | variable1 = StringVar(root) 41 | variable2 = StringVar(root) 42 | variable1.set("CURRENCY") 43 | variable2.set("CURRENCY") 44 | FromCurrency_option = OptionMenu(root, variable1, *CurrenyCode_list) 45 | ToCurrency_option = OptionMenu(root, variable2, *CurrenyCode_list) 46 | FromCurrency_option.config(bg="#DAF5FF") 47 | ToCurrency_option.config(bg="#DAF5FF") 48 | FromCurrency_option.grid(row=1, column=3, ipadx=45, sticky=E) 49 | ToCurrency_option.grid(row=2, column=3, ipadx=45, sticky=E) 50 | 51 | from_label = Label(text="From", font=my_font_of_text, bg="#DAF5FF") 52 | from_label.grid(row=1, column=1) 53 | to_label = Label(text="To", font=my_font_of_text) 54 | to_label.grid(row=2, column=1) 55 | 56 | entry_box_from = Entry(root, width=15, font=my_font_of_text) 57 | entry_box_from.grid(row=1, column=2) 58 | entry_box_to = Entry(root, width=15, font=my_font_of_text) 59 | entry_box_to.grid(row=2, column=2) 60 | 61 | convert_button = Button(root, width=16, height=1, text="Convert", font=my_font_of_text, bg="#DAF5FF", 62 | command=lambda: currency_exchange()) 63 | convert_button.grid(row=4, column=2, columnspan=2) 64 | 65 | root.mainloop() 66 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023 Alexander Bedrosyan 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Login application with Tkinter/download.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AlexanderBedrosyan/Simple-games-and-applications-with-Python/2425a3baa698e0d749df59573f4b9c72fb0608f5/Login application with Tkinter/download.png -------------------------------------------------------------------------------- /Login application with Tkinter/id-profile-user-icon--icon-search-engine-17.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AlexanderBedrosyan/Simple-games-and-applications-with-Python/2425a3baa698e0d749df59573f4b9c72fb0608f5/Login application with Tkinter/id-profile-user-icon--icon-search-engine-17.png -------------------------------------------------------------------------------- /Login application with Tkinter/login_app.py: -------------------------------------------------------------------------------- 1 | from tkinter import * 2 | from tkinter import messagebox 3 | 4 | root = Tk() 5 | root.title("Login app") 6 | root.geometry("925x500+300+200") 7 | root.config(bg="#fff") 8 | root.resizable(False, False) # stop the maximize button on top right corner 9 | 10 | 11 | def check_the_details(): 12 | username = user.get() 13 | psswrd = password.get() 14 | if username == "Dimityr" and psswrd == "Iliev": 15 | screen = Toplevel(root) 16 | screen.title("Second page") 17 | screen.geometry("925x500+300+200") 18 | screen.config(bg="black") 19 | 20 | Label(screen, text="Welcome to Lokomotiv Plovdiv official page!", fg="white", bg="black", 21 | font=('Arial Black', 28, "bold")).pack(expand=True) 22 | 23 | screen.mainloop() 24 | if username != "Dimityr" or psswrd != "Iliev": 25 | messagebox.showerror("Invalid", "Wrong username or password!") 26 | 27 | 28 | img = PhotoImage(file="download.png") # import picture 29 | Label(root, image=img, bg="white").place(x=50, y=50) 30 | 31 | img2 = PhotoImage(file="id-profile-user-icon--icon-search-engine-17.png") # import picture 32 | Label(root, image=img2, bg="white").place(x=470, y=200) 33 | 34 | signature = Label(text="Created by Alexander Bedrosyan", fg="black", bg="white", font=('Brush Script MT', 23, "bold")) 35 | signature.place(x=15, y=400) 36 | 37 | frame = Frame(root, width=350, height=200, bg="white") 38 | frame.place(x=460, y=50) 39 | 40 | heading = Label(frame, text="Sign in", fg="#57a1f8", bg="white", font=('Microsoft YaHei UI Light', 23, "bold")) 41 | heading.place(x=110, y=5) 42 | 43 | user = Entry(frame, width=25, fg="black", bg="white", font=('Microsoft YaHei UI Light', 11)) 44 | user.place(x=70, y=60) 45 | user.insert(0, "Enter your username") 46 | 47 | password = Entry(frame, width=25, fg="black", bg="white", font=('Microsoft YaHei UI Light', 11)) 48 | password.place(x=70, y=100) 49 | password.insert(0, "Enter your password") 50 | 51 | sign_button = Button(frame, text="Sign in", fg="white", bg="black", font=('Arial Black', 15), command=lambda: 52 | check_the_details()) 53 | sign_button.place(x=120, y=140) 54 | 55 | root.mainloop() 56 | -------------------------------------------------------------------------------- /Lyrics application with Tkinter/lyrics_app.py: -------------------------------------------------------------------------------- 1 | from tkinter import * 2 | from tkinter import Label 3 | import webbrowser 4 | 5 | root = Tk() 6 | root.title("Lyrics app") 7 | root.iconbitmap("D:/PyCharmProjects/PycharmProjects/tkinter_3/musical note.ico") # have to convert every picture in ICO 8 | root.geometry("910x700") 9 | root.resizable(False, False) 10 | 11 | 12 | def text(): 13 | autor_name = autor_box.get() 14 | song_name = song_box.get() 15 | if " " in autor_name: 16 | autor_name = autor_name.replace(" ", "-") 17 | if " " in song_name: 18 | song_name = song_name.replace(" ", "-") 19 | 20 | webbrowser.open("https://textove.com/" + autor_name + "-" + song_name + "-tekst") 21 | 22 | 23 | img = PhotoImage(file="D:/PyCharmProjects/PycharmProjects/tkinter_3/piano.png") 24 | Label(root, image=img, bg="white").place(x=0, y=0) 25 | 26 | autor_box = Entry(width=25, fg="black", bg="white", font=('Calibri', 11)) 27 | autor_box.place(x=200, y=200) 28 | autor_box.insert(0, "Autor") 29 | 30 | song_box = Entry(width=25, fg="black", bg="white", font=('Calibri', 11)) 31 | song_box.place(x=200, y=240) 32 | song_box.insert(0, "Song name") 33 | 34 | sign_button = Button(root, text="Generate text", fg="white", bg="grey", font=('Calibri', 15), command=lambda: 35 | text()) 36 | sign_button.place(x=200, y=280) 37 | 38 | 39 | root.mainloop() 40 | -------------------------------------------------------------------------------- /Lyrics application with Tkinter/musical note.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AlexanderBedrosyan/Simple-games-and-applications-with-Python/2425a3baa698e0d749df59573f4b9c72fb0608f5/Lyrics application with Tkinter/musical note.ico -------------------------------------------------------------------------------- /Lyrics application with Tkinter/piano.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AlexanderBedrosyan/Simple-games-and-applications-with-Python/2425a3baa698e0d749df59573f4b9c72fb0608f5/Lyrics application with Tkinter/piano.png -------------------------------------------------------------------------------- /Password generator with Tkinter/password_generator.py: -------------------------------------------------------------------------------- 1 | from tkinter import * 2 | from tkinter.font import Font 3 | from random import randint 4 | 5 | root = Tk() 6 | root.title("Password generator") 7 | root.minsize(520, 200) 8 | root.config(bg="#FFEBB4") 9 | my_font_of_text = Font( 10 | family="Times", 11 | size=20 12 | ) 13 | 14 | first_key_word_list = [] 15 | second_key_word_list = [] 16 | ascii_numbers = [] 17 | ascii_symbols = [] 18 | 19 | 20 | def MyButtonClick(): 21 | global first_key_word_list, second_key_word_list 22 | first_current = first_key_box.get() 23 | second_current = second_key_box.get() 24 | current_list_one = [str(ch) for ch in first_current] 25 | current_list_two = [str(item) for item in second_current] 26 | for i in range(0, 3): 27 | first_key_word_list.append(current_list_one[i]) 28 | second_key_word_list.append(current_list_two[i]) 29 | 30 | for i in range(0, 4): 31 | if i % 2 == 0: 32 | number = randint(48, 57) 33 | ascii_numbers.append(chr(number)) 34 | else: 35 | number = randint(33, 47) 36 | ascii_symbols.append(chr(number)) 37 | new_password = f"{''.join(first_key_word_list)}{''.join(ascii_symbols)}{''.join(second_key_word_list)}" \ 38 | f"{''.join(ascii_numbers)}" 39 | new_password_box.insert(0, new_password) 40 | 41 | 42 | first_key_word = Label(root, text="First key word", font=my_font_of_text, bg="#FFEBB4") 43 | first_key_word.grid(row=1, column=1, columnspan=1) 44 | first_key_box = Entry(root, width=15, font=my_font_of_text) 45 | first_key_box.grid(row=1, column=2, columnspan=8) 46 | 47 | 48 | second_key_word = Label(root, text="Second key word", font=my_font_of_text, bg="#FFEBB4") 49 | second_key_word.grid(row=2, column=1, columnspan=1) 50 | second_key_box = Entry(root, width=15, font=my_font_of_text) 51 | second_key_box.grid(row=2, column=2, columnspan=8) 52 | 53 | 54 | my_font_new_password = Font( 55 | family="Times", 56 | size=32 57 | ) 58 | myButton = Button(root, width=16, height=1, text="Generate password", font=my_font_of_text, 59 | command=lambda: MyButtonClick()) 60 | myButton.grid(row=3, column=0, columnspan=6) 61 | new_password_box = Entry(root, width=12, font=my_font_new_password) 62 | new_password_box.grid(row=3, column=8, columnspan=8) 63 | 64 | explanation = Label(root, text="The generator will take only", 65 | font=my_font_of_text, bg="#FFEBB4") 66 | explanation.grid(row=4, column=1, columnspan=18) 67 | explanation2 = Label(root, text="first 3 letters of each key word!", 68 | font=my_font_of_text, bg="#FFEBB4") 69 | explanation2.grid(row=5, column=1, columnspan=18) 70 | 71 | root.mainloop() -------------------------------------------------------------------------------- /Pictures converter application with Tkinter/pictures_converter.py: -------------------------------------------------------------------------------- 1 | from PIL import Image 2 | import PIL.Image 3 | from pillow_heif import register_heif_opener 4 | import os 5 | from tkinter import * 6 | from tkinter import filedialog as fd 7 | 8 | root = Tk() 9 | root.geometry("380x380") 10 | root.title("Images converter") 11 | root.resizable(False, False) 12 | icon = PhotoImage(file='convert_imagesplitter.png') 13 | root.iconphoto(False, icon) 14 | 15 | 16 | def convert_png(): 17 | help(register_heif_opener) 18 | register_heif_opener() 19 | filename = fd.askopenfilename() 20 | current_filename = filename.replace("/", "\\") 21 | temp_img = PIL.Image.open(current_filename) 22 | png_photo = current_filename.replace('.HEIC', '.png') 23 | temp_img.save(png_photo) 24 | 25 | 26 | def convert_jpg(): 27 | help(register_heif_opener) 28 | register_heif_opener() 29 | filename = fd.askopenfilename() 30 | current_filename = filename.replace("/", "\\") 31 | temp_img = PIL.Image.open(current_filename) 32 | jpg_photo = current_filename.replace('.HEIC', '.jpg') 33 | temp_img.save(jpg_photo) 34 | 35 | 36 | img = PhotoImage(file="convert_imagesplitter.png") # import picture 37 | Label(root, image=img, bg="white").place(x=7, y=6) 38 | 39 | 40 | browse = Label(text="Choose a picture in HEIC", font="Ariel", bd=1, bg="#FFFFE8") 41 | browse.place(x=75, y=5) 42 | 43 | myButton = Button(text="Convert to png", font="Ariel, 13", bd=4, command=convert_png) 44 | myButton.place(x=15, y=330) 45 | 46 | myButton2 = Button(text="Convert to jpg", font="Ariel, 13", bd=4, command=convert_jpg) 47 | myButton2.place(x=240, y=330) 48 | 49 | 50 | root.mainloop() 51 | -------------------------------------------------------------------------------- /Ping Pong game with Turtle/ping_pong_game.py: -------------------------------------------------------------------------------- 1 | import turtle as t 2 | playerAscore = 0 3 | playerBscore = 0 4 | 5 | window = t.Screen() 6 | window.title("Ping-Pong Game") 7 | window.bgcolor("green") 8 | window.setup(width=800, height=600) 9 | window.tracer(0) 10 | 11 | leftpaddle = t.Turtle() 12 | leftpaddle.speed(0) 13 | leftpaddle.shape("square") 14 | leftpaddle.color("white") 15 | leftpaddle.shapesize(stretch_wid=5, stretch_len=1) 16 | leftpaddle.penup() 17 | leftpaddle.goto(-350, 0) 18 | 19 | rightpaddle = t.Turtle() 20 | rightpaddle.speed(0) 21 | rightpaddle.shape("square") 22 | rightpaddle.color("white") 23 | rightpaddle.shapesize(stretch_wid=5, stretch_len=1) 24 | rightpaddle.penup() 25 | rightpaddle.goto(350, 0) 26 | 27 | ball = t.Turtle() 28 | ball.speed(0) 29 | ball.shape("circle") 30 | ball.color("red") 31 | ball.penup() 32 | ball.goto(5, 5) 33 | ballxdirection = 0.2 34 | ballydirection = 0.2 35 | 36 | pen = t.Turtle() 37 | pen.speed(0) 38 | pen.color("blue") 39 | pen.penup() 40 | pen.hideturtle() 41 | pen.goto(0, 260) 42 | pen.write("score", align="center", font=('Ariel', 24, 'normal')) 43 | 44 | 45 | def leftpaddle_up(): 46 | y = leftpaddle.ycor() 47 | y = y + 90 48 | leftpaddle.sety(y) 49 | 50 | 51 | def leftpaddle_down(): 52 | y = leftpaddle.ycor() 53 | y = y - 90 54 | leftpaddle.sety(y) 55 | 56 | 57 | def rightpaddle_up(): 58 | y = rightpaddle.ycor() 59 | y = y + 90 60 | rightpaddle.sety(y) 61 | 62 | 63 | def rightpaddle_down(): 64 | y = rightpaddle.ycor() 65 | y = y - 90 66 | rightpaddle.sety(y) 67 | 68 | 69 | window.listen() 70 | window.onkeypress(leftpaddle_up, "w") 71 | window.onkeypress(leftpaddle_down, "s") 72 | window.onkeypress(rightpaddle_up, "Up") 73 | window.onkeypress(rightpaddle_down, "Down") 74 | 75 | while True: 76 | window.update() 77 | 78 | ball.setx(ball.xcor() + ballxdirection) 79 | ball.sety(ball.ycor() + ballydirection) 80 | 81 | if ball.ycor() > 290: 82 | ball.sety(290) 83 | ballydirection = ballydirection* - 1 84 | 85 | if ball.ycor() < -290: 86 | ball.sety(-290) 87 | ballydirection = ballydirection* - 1 88 | 89 | if ball.xcor() > 390: 90 | ball.goto(0, 0) 91 | ballxdirection = ballxdirection 92 | playerAscore += 1 93 | pen.clear() 94 | pen.write("Player A: {} Player B: {}". format(playerAscore, playerBscore), align="center", font=("Ariel",24, "normal")) 95 | 96 | if ball.xcor() < -390: 97 | ball.goto(0, 0) 98 | ballxdirection = ballxdirection 99 | playerAscore += 1 100 | pen.clear() 101 | pen.write("Player A: {} Player B: {}". format(playerAscore, playerBscore), align="center", font=("Ariel",24, "normal")) 102 | 103 | 104 | if(ball.xcor() > 340) and (ball.xcor() < 350) and (ball.ycor() < rightpaddle.ycor() + 40 and ball.ycor() > rightpaddle.ycor() - 40): 105 | ball.setx(340) 106 | ballxdirection = ballxdirection * -1 107 | 108 | if(ball.xcor() < -340) and (ball.xcor() > -350) and (ball.ycor() < leftpaddle.ycor() + 40 and ball.ycor() > leftpaddle.ycor() - 40): 109 | ball.setx(-340) 110 | ballxdirection = ballxdirection * -1 111 | 112 | -------------------------------------------------------------------------------- /Qr codes generator with Tkinter/qr_codes_generator.py: -------------------------------------------------------------------------------- 1 | from tkinter import * 2 | import qrcode 3 | 4 | root = Tk() 5 | root.title("QR generator") 6 | root.geometry("1000x500") 7 | root.config(bg="#BDCDD6") 8 | root.resizable(False, False) 9 | 10 | 11 | def generate(): 12 | name = title.get() 13 | needed_link = link.get() 14 | qr = qrcode.make(needed_link) 15 | qr.save("Qrcodes/" + str(name) + ".png") 16 | 17 | global Image 18 | Image = PhotoImage(file="Qrcodes/" + str(name) + ".png") 19 | Image_view.config(image=Image) 20 | 21 | 22 | Image_view=Label(root, bg="#BDCDD6") 23 | Image_view.pack(padx=50, pady=10, side=RIGHT) 24 | 25 | Label(root, text="Title", fg="Black", bg="#BDCDD6", font=15).place(x=50, y=150) 26 | title = Entry(root, font=16) 27 | title.place(x=53, y=180) 28 | 29 | Label(root, text="Import link", bg="#BDCDD6", font=15).place(x=50, y=220) 30 | link = Entry(root, font=16) 31 | link.place(x=53, y=250) 32 | 33 | Button(root, text="Generate", width=20, height=2, bg="black", fg="white", command=generate).place(x=53, y=300) 34 | 35 | root.mainloop() 36 | -------------------------------------------------------------------------------- /Quick search with Tkinter/quick_search.py: -------------------------------------------------------------------------------- 1 | from tkinter import * 2 | from tkinter.font import Font 3 | import webbrowser 4 | 5 | root = Tk() 6 | root.title("Quick search!") 7 | root.config(bg="#C7E8CA") 8 | my_font = Font(family="Times new roman", size=15) 9 | 10 | 11 | def click_google(): 12 | command = search_word_entry.get() 13 | webbrowser.open("https://www.google.com/search?q=" + command) 14 | 15 | 16 | def click_filmi(): 17 | command = search_word_entry.get() 18 | webbrowser.open("https://www.google.com/search?q=" + f"Filmi7 {command}") 19 | 20 | 21 | def click_youtube(): 22 | command = search_word_entry.get() 23 | webbrowser.open("https://www.youtube.com/results?search_query=" + command) 24 | 25 | 26 | def click_linkedin(): 27 | command = search_word_entry.get() 28 | webbrowser.open("https://www.linkedin.com/search/results/all/?keywords=" + command) 29 | 30 | 31 | def click_facebook(): 32 | command = search_word_entry.get() 33 | webbrowser.open("https://www.facebook.com/search/top/?q=" + command) 34 | 35 | 36 | entry_font = Font(family="Arial Black", size=20) 37 | search_word_entry = Entry(font=entry_font) 38 | search_word_entry.grid(row=1, column=1, columnspan=8) 39 | 40 | google_button = Button(text="Google", font=my_font, bg="#62CDFF", command=lambda: click_google()) 41 | google_button.grid(row=2, column=1, columnspan=1) 42 | 43 | filmi7_button = Button(text="Filmi7", font=my_font, bg="#62CDFF", command=lambda: click_filmi()) 44 | filmi7_button.grid(row=2, column=2, columnspan=1) 45 | 46 | youtube_button = Button(text="Youtube", font=my_font, bg="#62CDFF", command=lambda: click_youtube()) 47 | youtube_button.grid(row=2, column=3, columnspan=1) 48 | 49 | linkedin_button = Button(text="LinkedIn", font=my_font, bg="#62CDFF", command=lambda: click_linkedin()) 50 | linkedin_button.grid(row=2, column=4, columnspan=1) 51 | 52 | facebook_button = Button(text="Facebook", font=my_font, bg="#62CDFF", command=lambda: click_facebook()) 53 | facebook_button.grid(row=2, column=5, columnspan=1) 54 | 55 | root.mainloop() 56 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Simple-games-and-applications-with-Python 2 | In this repository there are codes for simple games and applications created with Python. 3 | 4 | ## Lyrics application with Tkinter 5 | 6 | The main view starting with 2 text boxes for "Author" and "Song name". When you typed and pressed button "Generate text", the application will open a website (textove.com) with the lyrics of the needed song. 7 | 8 | Libraries used: webbrowser and tkinter 9 | 10 | ![image](https://github.com/AlexanderBedrosyan/Simple-games-and-applications-with-Python/assets/126572116/89b7bbcb-96d5-4c2f-b8e4-f64521496673) 11 | 12 | An example with the result 13 | 14 | ![image](https://github.com/AlexanderBedrosyan/Simple-games-and-applications-with-Python/assets/126572116/3dda9013-a345-4d1f-90c7-fc1676401956) 15 | 16 | 17 | ## Rock Paper Scissors with Tkinter 18 | 19 | The game is created with tkinter as it's used random/randit also for each round. There are 3 options for player as we know the rules of the game. The computer makes a random choice which is also from the noted 3 options. Then the result are going to be open in new window. 20 | 21 | Libraries used: tkinter and random 22 | 23 | ![image](https://github.com/AlexanderBedrosyan/Simple-games-and-applications-with-Python/assets/126572116/a431d712-56e5-4e36-9956-98e7edef3931) 24 | 25 | An example how the result is opened. 26 | 27 | ![image](https://github.com/AlexanderBedrosyan/Simple-games-and-applications-with-Python/assets/126572116/25e8f8d4-2df7-47c9-ab8b-5119f98c86dc) 28 | 29 | ## Currency convertor with Tkinter 30 | 31 | The application has two optional buttons "Currency" which include only part of the currencies (everyone can add more of them). If you use two equal currencies or for some reason used forbiden symbols, a message with an error will show. 32 | 33 | Library used without installation: tkinter 34 | 35 | Library used with installation: forex_python 36 | 37 | ![image](https://github.com/AlexanderBedrosyan/Simple-games-and-applications-with-Python/assets/126572116/360ac61f-ba1b-4da2-b0bb-2d116f333841) 38 | 39 | An example for the error message 40 | 41 | ![image](https://github.com/AlexanderBedrosyan/Simple-games-and-applications-with-Python/assets/126572116/6a1d40fe-caf5-44f4-92c5-3cb595a8fcae) 42 | 43 | 44 | ## Login application with Tkinter. Simple app which is created without DB. 45 | 46 | Library used: tkinter 47 | 48 | Two pictures are used. They can be find in the folder in Github. 49 | 50 | ![image](https://github.com/AlexanderBedrosyan/Simple-games-and-applications-with-Python/assets/126572116/8168f1f5-dc9f-4871-a893-77ac4115462f) 51 | 52 | An example for second page: 53 | 54 | ![image](https://github.com/AlexanderBedrosyan/Simple-games-and-applications-with-Python/assets/126572116/606e1875-3ef0-4c9a-87f9-97d5f240d6f0) 55 | 56 | ## Ping Pomg game with Turtle 57 | 58 | This game has simple view which includes - bal, rectangles for players and score menu. Buttons for movements are: 59 | 60 | Left player: W and S 61 | 62 | Right player: Up and Down 63 | 64 | Library used: Turtle 65 | 66 | ![image](https://github.com/AlexanderBedrosyan/Simple-games-and-applications-with-Python/assets/126572116/571c6876-70d4-4c31-a090-cb2e0f2bdc64) 67 | 68 | 69 | ## Password generator with Tkinter. Simple app which automatically generate unique passwords. 70 | 71 | Libraries used: tkinter and random (randit) 72 | 73 | No pictures include. 74 | 75 | ![image](https://github.com/AlexanderBedrosyan/Simple-games-and-applications-with-Python/assets/126572116/3e92308c-11da-4091-924f-f91585ebcc77) 76 | 77 | ## Qr codes generator with Tkinter. 78 | 79 | The application is created to generate qrcodes and to save it in folder which is issued on your computer. There are only two boxes "Title" and "Import link". First of it will name the file in your computer, the second one will use the link which you need to be shown when you check the qr code. 80 | 81 | Libraries used: tkinter and qrcode (qrcode library should be install in terminal or by using the settings method) 82 | 83 | No pictures include. 84 | 85 | ![image](https://github.com/AlexanderBedrosyan/Simple-games-and-applications-with-Python/assets/126572116/92dff229-d65c-4ef1-8bd0-168c71db37fa) 86 | 87 | An example with result of google.com in qr code generated by the app. 88 | 89 | ![image](https://github.com/AlexanderBedrosyan/Simple-games-and-applications-with-Python/assets/126572116/fce32a3f-cc55-480b-8cb0-97b72244a2dd) 90 | 91 | ## Weather application for Europe with Tkinter. 92 | 93 | The application is created without API comunication. It's scrapping the html information from www.foreca.bg, this is the main difference from all other weather apps. From time to tome shows an error, because the scrapping type can marge and find information about the area (the developers of foreca.bg are using for some of the cities a key-word for area). 94 | 95 | Library used without installation: Tkinter 96 | 97 | Libraries used with installation: requests and bs4 98 | 99 | ![image](https://github.com/AlexanderBedrosyan/Simple-games-and-applications-with-Python/assets/126572116/9b6296d8-430e-44b3-8903-8b55ed6e137c) 100 | 101 | ## Tic Tac Toe with Tkinter. 102 | 103 | Simple game with tkinter with an unique view. Every button from each player is related with free box on the game screen. In the end the result would be shown. 104 | 105 | Library used: Tkinter 106 | 107 | ![image](https://github.com/AlexanderBedrosyan/Simple-games-and-applications-with-Python/assets/126572116/75f7ee37-e6fe-4fbf-80ab-a0bb741077b4) 108 | 109 | ## Quick search with Tkinter. 110 | 111 | This application is created with Tkinter. There is chance to create more buttons for some quick search web sites. 112 | 113 | Libraries used: tkinter and webbrowser 114 | 115 | ![image](https://github.com/AlexanderBedrosyan/Simple-games-and-applications-with-Python/assets/126572116/a50e929d-65d8-4f1b-962b-3896756afa53) 116 | 117 | An example when "Google" button is clicked: 118 | 119 | ![image](https://github.com/AlexanderBedrosyan/Simple-games-and-applications-with-Python/assets/126572116/4ac9ccfd-cb4b-4a1b-8532-fd3483dd3014) 120 | 121 | ## Application for comparing excel sheets with Tkinter 122 | 123 | In the beginning there are 4 open boxes - First File, Second File, First Column and Second Column. The boxes for the files are needed just to text the correct name of the files (they have to be in the same folder). In the other two boxes we are chosing which columns need to be compared. Then pressed button "Check for differences". 124 | 125 | Library used without installation: Tkinter 126 | 127 | Library used with installation: openpyxl 128 | 129 | ![image](https://github.com/AlexanderBedrosyan/Simple-games-and-applications-with-Python/assets/126572116/f0a75742-cd85-491a-b879-23948529799b) 130 | 131 | An example for the result 132 | 133 | ![image](https://github.com/AlexanderBedrosyan/Simple-games-and-applications-with-Python/assets/126572116/e72d113d-9554-4945-b2b0-13c0bcdd0c35) 134 | 135 | ## Calculator with Tkinter 136 | 137 | This application is created with Tkinter. Main functions of calculator included. 138 | 139 | Library: Tkinter 140 | 141 | ![image](https://github.com/AlexanderBedrosyan/Simple-games-and-applications-with-Python/assets/126572116/bbaccbab-9c60-451d-86a0-1747057e0b42) 142 | -------------------------------------------------------------------------------- /Rock Paper Scissors with Tkinter/game over.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AlexanderBedrosyan/Simple-games-and-applications-with-Python/2425a3baa698e0d749df59573f4b9c72fb0608f5/Rock Paper Scissors with Tkinter/game over.png -------------------------------------------------------------------------------- /Rock Paper Scissors with Tkinter/no winner.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AlexanderBedrosyan/Simple-games-and-applications-with-Python/2425a3baa698e0d749df59573f4b9c72fb0608f5/Rock Paper Scissors with Tkinter/no winner.png -------------------------------------------------------------------------------- /Rock Paper Scissors with Tkinter/paper.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AlexanderBedrosyan/Simple-games-and-applications-with-Python/2425a3baa698e0d749df59573f4b9c72fb0608f5/Rock Paper Scissors with Tkinter/paper.png -------------------------------------------------------------------------------- /Rock Paper Scissors with Tkinter/rock-paper-scissors.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AlexanderBedrosyan/Simple-games-and-applications-with-Python/2425a3baa698e0d749df59573f4b9c72fb0608f5/Rock Paper Scissors with Tkinter/rock-paper-scissors.ico -------------------------------------------------------------------------------- /Rock Paper Scissors with Tkinter/rock.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AlexanderBedrosyan/Simple-games-and-applications-with-Python/2425a3baa698e0d749df59573f4b9c72fb0608f5/Rock Paper Scissors with Tkinter/rock.png -------------------------------------------------------------------------------- /Rock Paper Scissors with Tkinter/rock_paper_scissors_tkinter.py: -------------------------------------------------------------------------------- 1 | from tkinter import * 2 | from random import randint 3 | 4 | root = Tk() 5 | root.title("Rock Paper Scissors.app") 6 | root.iconbitmap("D:/PyCharmProjects/PycharmProjects/tkinter_3/rock-paper-scissors.ico") 7 | root.geometry("700x300") 8 | root.resizable(False, False) 9 | 10 | rock_paper_scissors_list = ["rock", "paper", "scissors"] 11 | player_option = None 12 | draw_img = PhotoImage(file="no winner.png") 13 | winner_img = PhotoImage(file="winner.png") 14 | lost_img = PhotoImage(file="game over.png") 15 | 16 | 17 | def result(number): 18 | player_option = rock_paper_scissors_list[int(number)] 19 | computer_choice = rock_paper_scissors_list[int(randint(0, 2))] 20 | if computer_choice == player_option: 21 | screen = Toplevel(root) 22 | screen.title("Result page") 23 | screen.geometry("1000x800") 24 | screen.config(bg="black") 25 | screen.resizable(False, False) 26 | 27 | Label(screen, image=draw_img, fg="white", bg="black", 28 | font=('Arial Black', 28, "bold")).pack(expand=True) 29 | Label(screen, text=f"Тhe computer selected {computer_choice}.\n No one wins!",fg="white", bg="black", 30 | font=('Arial Black', 28, "bold")).place(x=180, y=2) 31 | else: 32 | if (computer_choice == rock_paper_scissors_list[0] and player_option == rock_paper_scissors_list[1]) \ 33 | or (computer_choice == rock_paper_scissors_list[1] and player_option == rock_paper_scissors_list[2]) \ 34 | or (computer_choice == rock_paper_scissors_list[2] and player_option == rock_paper_scissors_list[0]): 35 | screen = Toplevel(root) 36 | screen.title("Result page") 37 | screen.geometry("1000x800") 38 | screen.config(bg="black") 39 | screen.resizable(False, False) 40 | 41 | Label(screen, image=winner_img, fg="white", bg="black", 42 | font=('Arial Black', 28, "bold")).pack(expand=True) 43 | Label(screen, text=f"Тhe computer selected {computer_choice}.\n You are the winner!", fg="white", bg="black", 44 | font=('Arial Black', 28, "bold")).place(x=190, y=1) 45 | elif (computer_choice == rock_paper_scissors_list[0] and player_option == rock_paper_scissors_list[2])\ 46 | or (computer_choice == rock_paper_scissors_list[1] and player_option == rock_paper_scissors_list[0]) \ 47 | or (computer_choice == rock_paper_scissors_list[2] and player_option == rock_paper_scissors_list[0])\ 48 | or (computer_choice == rock_paper_scissors_list[2] and player_option == rock_paper_scissors_list[1]): 49 | screen = Toplevel(root) 50 | screen.title("Result page") 51 | screen.geometry("1000x800") 52 | screen.config(bg="black") 53 | screen.resizable(False, False) 54 | 55 | Label(screen, image=lost_img, fg="white", bg="black", 56 | font=('Arial Black', 28, "bold")).pack(expand=True) 57 | Label(screen, text=f"Тhe computer selected {computer_choice}.\n You lost!", fg="white", 58 | bg="black", 59 | font=('Arial Black', 28, "bold")).place(x=190, y=1) 60 | 61 | 62 | img_rock = PhotoImage(file="rock.png") 63 | Label(root, image=img_rock, bg="white").place(x=40, y=40) 64 | rock_button = Button(root, text="Rock", fg="white", bg="grey", font=('Calibri', 30), command=lambda: result(0)) 65 | rock_button.place(x=63, y=200) 66 | 67 | img_paper = PhotoImage(file="paper.png") 68 | Label(root, image=img_paper, bg="white", fg="white").place(x=260, y=40) 69 | paper_button = Button(root, text="Paper", fg="white", bg="grey", font=('Calibri', 30), command=lambda: result(1)) 70 | paper_button.place(x=270, y=200) 71 | 72 | img_scissors = PhotoImage(file="scissors.png") 73 | Label(root, image=img_scissors, bg="white", fg="white").place(x=500, y=40) 74 | scissors_button = Button(root, text="Scissors", fg="white", bg="grey", font=('Calibri', 30), command=lambda: result(2)) 75 | scissors_button.place(x=500, y=200) 76 | 77 | root.mainloop() -------------------------------------------------------------------------------- /Rock Paper Scissors with Tkinter/scissors.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AlexanderBedrosyan/Simple-games-and-applications-with-Python/2425a3baa698e0d749df59573f4b9c72fb0608f5/Rock Paper Scissors with Tkinter/scissors.png -------------------------------------------------------------------------------- /Rock Scissors Paper/rock_paper_scissors.py: -------------------------------------------------------------------------------- 1 | from random import randint 2 | 3 | 4 | def selected_options(number): 5 | game_task = int(number) - 1 6 | return game_task 7 | 8 | 9 | game_list = ["1", "2", "3"] 10 | rock_paper_scissors_list = ["rock", "paper", "scissors"] 11 | final_list = [] 12 | 13 | rock = ''' 14 | _______ 15 | ---' ____) 16 | (_____) 17 | (_____) 18 | (____) 19 | ---.__(___) 20 | ''' 21 | final_list.append(rock) 22 | paper = ''' 23 | ______ 24 | ---' ___)_____ 25 | ______) 26 | _______) 27 | _______) 28 | ---.__________) 29 | ''' 30 | final_list.append(paper) 31 | scissors = ''' 32 | ______ 33 | ---' ___)_____ 34 | ______) 35 | __________) 36 | (___) 37 | ---.__(__) 38 | ''' 39 | final_list.append(scissors) 40 | player_option = 0 41 | computer_choice = randint(1, 3) 42 | 43 | while True: 44 | option = input("1.Rock\n2.Paper\n3.Scissors\nSelect an option: ") 45 | if option in game_list: 46 | player_option = int(option) 47 | print(f"My choice is: {rock_paper_scissors_list[selected_options(option)]}") 48 | print(*final_list[selected_options(option)]) 49 | break 50 | else: 51 | print("INVALID OPTION. You have to choose from the numbers - 1, 2, 3!") 52 | 53 | print("VS.") 54 | print(f"Computer's choice is: {rock_paper_scissors_list[selected_options(computer_choice)]}") 55 | print(*final_list[selected_options(computer_choice)]) 56 | 57 | if computer_choice == player_option: 58 | print("We ended the game in a draw!") 59 | else: 60 | if (computer_choice == 1 and player_option == 2) or (computer_choice == 2 and player_option == 3) \ 61 | or (computer_choice == 3 and player_option == 1): 62 | print("You win!") 63 | elif (computer_choice == 1 and player_option == 3) or (computer_choice == 2 and player_option == 1) \ 64 | or (computer_choice == 3 and player_option == 1) or (computer_choice == 3 and player_option == 2): 65 | print("You lost!") 66 | -------------------------------------------------------------------------------- /Text to speech app with Tkinter/background.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AlexanderBedrosyan/Simple-games-and-applications-with-Python/2425a3baa698e0d749df59573f4b9c72fb0608f5/Text to speech app with Tkinter/background.png -------------------------------------------------------------------------------- /Text to speech app with Tkinter/sound.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AlexanderBedrosyan/Simple-games-and-applications-with-Python/2425a3baa698e0d749df59573f4b9c72fb0608f5/Text to speech app with Tkinter/sound.ico -------------------------------------------------------------------------------- /Text to speech app with Tkinter/text_to_speech.py: -------------------------------------------------------------------------------- 1 | from tkinter import * 2 | import pyttsx3 3 | 4 | root = Tk() 5 | root.title("Text to speech.app") 6 | root.iconbitmap("D:/PyCharmProjects/PycharmProjects/tkinter_3/sound.ico") 7 | root.geometry("676x400") 8 | root.resizable(False, False) 9 | 10 | engine = pyttsx3.init() 11 | 12 | 13 | def speak(): 14 | engine.say(text.get()) 15 | engine.runAndWait() 16 | engine.stop() 17 | 18 | 19 | frame = LabelFrame(root, text="Text to speech", font=20, bd=1) 20 | frame.pack(fill="both", expand="yes", padx=10, pady=10) 21 | 22 | img = PhotoImage(file="D:/PyCharmProjects/PycharmProjects/tkinter_3/background.png") 23 | Label(frame, image=img, bg="white").place(x=0, y=0) 24 | 25 | Label = Label(frame, text="Type text", font=12, bd=1) 26 | Label.place(x=255, y=70) 27 | 28 | text = Entry(frame, font=12) 29 | text.place(x=190, y=30) 30 | 31 | btn = Button(frame, text="Speak", font=12, bd=1, command=speak) 32 | btn.place(x=262, y=230) 33 | 34 | root.mainloop() -------------------------------------------------------------------------------- /Tic Tac Toe with Tkinter/game_tic_tac_toe.py: -------------------------------------------------------------------------------- 1 | from tkinter import * 2 | import tkinter as tk 3 | from tkinter import messagebox 4 | 5 | root = tk.Tk() 6 | 7 | list_one = [] 8 | list_two = [] 9 | mov = 0 10 | 11 | 12 | def CheckWinner(): 13 | if (1 in list_one) and (4 in list_one) and (7 in list_one): 14 | messagebox.showinfo(title="Congratulations.", 15 | message="Player 1 is the winner") 16 | elif (2 in list_one) and (5 in list_one) and (8 in list_one): 17 | messagebox.showinfo(title="Congratulations.", 18 | message="Player 1 is the winner") 19 | elif (3 in list_one) and (6 in list_one) and (9 in list_one): 20 | messagebox.showinfo(title="Congratulations.", 21 | message="Player 1 is the winner") 22 | elif (1 in list_one) and (5 in list_one) and (9 in list_one): 23 | messagebox.showinfo(title="Congratulations.", 24 | message="Player 1 is the winner") 25 | elif (3 in list_one) and (5 in list_one) and (7 in list_one): 26 | messagebox.showinfo(title="Congratulations.", 27 | message="Player 1 is the winner") 28 | elif (1 in list_one) and (2 in list_one) and (3 in list_one): 29 | messagebox.showinfo(title="Congratulations.", 30 | message="Player 1 is the winner") 31 | elif (4 in list_one) and (5 in list_one) and (6 in list_one): 32 | messagebox.showinfo(title="Congratulations.", 33 | message="Player 1 is the winner") 34 | elif (7 in list_one) and (8 in list_one) and (9 in list_one): 35 | messagebox.showinfo(title="Congratulations.", 36 | message="Player 1 is the winner") 37 | 38 | if (11 in list_two) and (14 in list_two) and (17 in list_two): 39 | messagebox.showinfo(title="Congratulations.", 40 | message="Player 2 is the winner") 41 | elif (12 in list_two) and (15 in list_two) and (18 in list_two): 42 | messagebox.showinfo(title="Congratulations.", 43 | message="Player 2 is the winner") 44 | elif (13 in list_two) and (16 in list_two) and (19 in list_two): 45 | messagebox.showinfo(title="Congratulations.", 46 | message="Player 2 is the winner") 47 | elif (11 in list_two) and (15 in list_two) and (19 in list_two): 48 | messagebox.showinfo(title="Congratulations.", 49 | message="Player 2 is the winner") 50 | elif (13 in list_two) and (15 in list_two) and (17 in list_two): 51 | messagebox.showinfo(title="Congratulations.", 52 | message="Player 2 is the winner") 53 | elif (11 in list_two) and (12 in list_two) and (13 in list_two): 54 | messagebox.showinfo(title="Congratulations.", 55 | message="Player 2 is the winner") 56 | elif (14 in list_two) and (15 in list_two) and (16 in list_two): 57 | messagebox.showinfo(title="Congratulations.", 58 | message="Player 2 is the winner") 59 | elif (17 in list_two) and (18 in list_two) and (19 in list_two): 60 | messagebox.showinfo(title="Congratulations.", 61 | message="Player 2 is the winner") 62 | 63 | if (len(list_one) + len(list_two)) == 9: 64 | messagebox.showinfo(title="Draw", 65 | message="There is no winner") 66 | 67 | 68 | def button_for_number(number): 69 | global list_one, list_two 70 | current = box1.get() 71 | box1.delete(0, END) 72 | box1.insert(0, str(current) + str(number)) 73 | myButton11["state"] = "disabled" 74 | myButton1["state"] = "disabled" 75 | list_one.append(1) 76 | CheckWinner() 77 | 78 | 79 | def button_for_number11(number): 80 | global list_one, list_two 81 | current = box1.get() 82 | box1.delete(0, END) 83 | box1.insert(0, str(current) + str(number)) 84 | myButton11["state"] = "disabled" 85 | myButton1["state"] = "disabled" 86 | list_two.append(11) 87 | CheckWinner() 88 | 89 | 90 | def button_for_number2(number): 91 | global list_one, list_two 92 | current = box2.get() 93 | box2.delete(0, END) 94 | box2.insert(0, str(current) + str(number)) 95 | myButton12["state"] = "disabled" 96 | myButton2["state"] = "disabled" 97 | list_one.append(2) 98 | CheckWinner() 99 | 100 | 101 | def button_for_number12(number): 102 | global list_one, list_two 103 | current = box2.get() 104 | box2.delete(0, END) 105 | box2.insert(0, str(current) + str(number)) 106 | myButton12["state"] = "disabled" 107 | myButton2["state"] = "disabled" 108 | list_two.append(12) 109 | CheckWinner() 110 | 111 | 112 | def button_for_number3(number): 113 | global list_one, list_two 114 | current = box3.get() 115 | box3.delete(0, END) 116 | box3.insert(0, str(current) + str(number)) 117 | myButton13["state"] = "disabled" 118 | myButton3["state"] = "disabled" 119 | list_one.append(3) 120 | CheckWinner() 121 | 122 | 123 | def button_for_number13(number): 124 | global list_one, list_two 125 | current = box3.get() 126 | box3.delete(0, END) 127 | box3.insert(0, str(current) + str(number)) 128 | myButton13["state"] = "disabled" 129 | myButton3["state"] = "disabled" 130 | list_two.append(13) 131 | CheckWinner() 132 | 133 | 134 | def button_for_number4(number): 135 | global list_one, list_two 136 | current = box4.get() 137 | box4.delete(0, END) 138 | box4.insert(0, str(current) + str(number)) 139 | myButton14["state"] = "disabled" 140 | myButton4["state"] = "disabled" 141 | list_one.append(4) 142 | CheckWinner() 143 | 144 | 145 | def button_for_number14(number): 146 | global list_one, list_two 147 | current = box4.get() 148 | box4.delete(0, END) 149 | box4.insert(0, str(current) + str(number)) 150 | myButton14["state"] = "disabled" 151 | myButton4["state"] = "disabled" 152 | list_two.append(14) 153 | CheckWinner() 154 | 155 | 156 | def button_for_number5(number): 157 | global list_one, list_two 158 | current = box5.get() 159 | box5.delete(0, END) 160 | box5.insert(0, str(current) + str(number)) 161 | myButton5["state"] = "disabled" 162 | myButton15["state"] = "disabled" 163 | list_one.append(5) 164 | CheckWinner() 165 | 166 | 167 | def button_for_number15(number): 168 | global list_one, list_two 169 | current = box5.get() 170 | box5.delete(0, END) 171 | box5.insert(0, str(current) + str(number)) 172 | myButton5["state"] = "disabled" 173 | myButton15["state"] = "disabled" 174 | list_two.append(15) 175 | CheckWinner() 176 | 177 | 178 | def button_for_number6(number): 179 | global list_one, list_two 180 | current = box6.get() 181 | box6.delete(0, END) 182 | box6.insert(0, str(current) + str(number)) 183 | myButton16["state"] = "disabled" 184 | myButton6["state"] = "disabled" 185 | list_one.append(6) 186 | CheckWinner() 187 | 188 | 189 | def button_for_number16(number): 190 | global list_one, list_two 191 | current = box6.get() 192 | box6.delete(0, END) 193 | box6.insert(0, str(current) + str(number)) 194 | myButton16["state"] = "disabled" 195 | myButton6["state"] = "disabled" 196 | list_two.append(16) 197 | CheckWinner() 198 | 199 | 200 | def button_for_number7(number): 201 | global list_one, list_two 202 | current = box7.get() 203 | box7.delete(0, END) 204 | box7.insert(0, str(current) + str(number)) 205 | myButton17["state"] = "disabled" 206 | myButton7["state"] = "disabled" 207 | list_one.append(7) 208 | print(list_one) 209 | CheckWinner() 210 | 211 | 212 | def button_for_number17(number): 213 | global list_one, list_two 214 | current = box7.get() 215 | box7.delete(0, END) 216 | box7.insert(0, str(current) + str(number)) 217 | myButton17["state"] = "disabled" 218 | myButton7["state"] = "disabled" 219 | list_two.append(17) 220 | CheckWinner() 221 | 222 | 223 | def button_for_number8(number): 224 | global list_one, list_two 225 | current = box8.get() 226 | box8.delete(0, END) 227 | box8.insert(0, str(current) + str(number)) 228 | myButton18["state"] = "disabled" 229 | myButton8["state"] = "disabled" 230 | list_one.append(8) 231 | CheckWinner() 232 | 233 | 234 | def button_for_number18(number): 235 | global list_one, list_two 236 | current = box8.get() 237 | box8.delete(0, END) 238 | box8.insert(0, str(current) + str(number)) 239 | myButton18["state"] = "disabled" 240 | myButton8["state"] = "disabled" 241 | list_two.append(18) 242 | CheckWinner() 243 | 244 | 245 | def button_for_number9(number): 246 | global list_one, list_two 247 | current = box9.get() 248 | box9.delete(0, END) 249 | box9.insert(0, str(current) + str(number)) 250 | myButton19["state"] = "disabled" 251 | myButton9["state"] = "disabled" 252 | list_one.append(9) 253 | CheckWinner() 254 | 255 | 256 | def button_for_number19(number): 257 | global list_one, list_two 258 | current = box9.get() 259 | box9.delete(0, END) 260 | box9.insert(0, str(current) + str(number)) 261 | myButton19["state"] = "disabled" 262 | myButton9["state"] = "disabled" 263 | list_two.append(19) 264 | CheckWinner() 265 | 266 | 267 | box1 = Entry(root, width=3, font=('Helvetica', 20)) 268 | box1.grid(row=0, column=0, columnspan=1) 269 | box2 = Entry(root, width=3, font=('Helvetica', 20)) 270 | box2.grid(row=1, column=0, columnspan=1) 271 | box3 = Entry(root, width=3, font=('Helvetica', 20)) 272 | box3.grid(row=2, column=0, columnspan=1) 273 | 274 | box4 = Entry(root, width=3, font=('Helvetica', 20)) 275 | box4.grid(row=0, column=1, columnspan=2) 276 | box5 = Entry(root, width=3, font=('Helvetica', 20)) 277 | box5.grid(row=1, column=1, columnspan=2) 278 | box6 = Entry(root, width=3, font=('Helvetica', 20)) 279 | box6.grid(row=2, column=1, columnspan=2) 280 | 281 | box7 = Entry(root, width=3, font=('Helvetica', 20)) 282 | box7.grid(row=0, column=3, columnspan=3) 283 | box8 = Entry(root, width=3, font=('Helvetica', 20)) 284 | box8.grid(row=1, column=3, columnspan=3) 285 | box9 = Entry(root, width=3, font=('Helvetica', 20)) 286 | box9.grid(row=2, column=3, columnspan=3) 287 | 288 | 289 | player_one_label = Label(root, text="Player1").grid(row=4, column=7) 290 | 291 | 292 | myButton1 = Button(root, width=4, height=2, text="1", command=lambda: button_for_number("X")) 293 | myButton1.grid(row=0, column=6, columnspan=4) 294 | myButton2 = Button(root, width=4, height=2, text="4", command=lambda: button_for_number2("X")) 295 | myButton2.grid(row=1, column=6, columnspan=5) 296 | myButton3 = Button(root, width=4, height=2, text="7", command=lambda: button_for_number3("X")) 297 | myButton3.grid(row=2, column=6, columnspan=5) 298 | myButton4 = Button(root, width=4, height=2, text="2", command=lambda: button_for_number4("X")) 299 | myButton4.grid(row=0, column=11, columnspan=5) 300 | myButton5 = Button(root, width=4, height=2, text="5", command=lambda: button_for_number5("X")) 301 | myButton5.grid(row=1, column=11, columnspan=5) 302 | myButton6 = Button(root, width=4, height=2, text="8", command=lambda: button_for_number6("X")) 303 | myButton6.grid(row=2, column=11, columnspan=5) 304 | myButton7 = Button(root, width=4, height=2, text="3", command=lambda: button_for_number7("X")) 305 | myButton7.grid(row=0, column=17, columnspan=6) 306 | myButton8 = Button(root, width=4, height=2, text="6", command=lambda: button_for_number8("X")) 307 | myButton8.grid(row=1, column=17, columnspan=6) 308 | myButton9 = Button(root, width=4, height=2, text="9", command=lambda: button_for_number9("X")) 309 | myButton9.grid(row=2, column=17, columnspan=6) 310 | 311 | 312 | player_two_label = Label(root, text="Player2").grid(row=9) 313 | 314 | 315 | myButton11 = Button(root, width=4, height=2, text="1", command=lambda: button_for_number11("O")) 316 | myButton11.grid(row=6, column=0, columnspan=1) 317 | myButton12 = Button(root, width=4, height=2, text="4", command=lambda: button_for_number12("O")) 318 | myButton12.grid(row=7, column=0, columnspan=1) 319 | myButton13 = Button(root, width=4, height=2, text="7", command=lambda: button_for_number13("O")) 320 | myButton13.grid(row=8, column=0, columnspan=1) 321 | myButton14 = Button(root, width=4, height=2, text="2", command=lambda: button_for_number14("O")) 322 | myButton14.grid(row=6, column=1, columnspan=2) 323 | myButton15 = Button(root, width=4, height=2, text="5", command=lambda: button_for_number15("O")) 324 | myButton15.grid(row=7, column=1, columnspan=2) 325 | myButton16 = Button(root, width=4, height=2, text="8", command=lambda: button_for_number16("O")) 326 | myButton16.grid(row=8, column=1, columnspan=2) 327 | myButton17 = Button(root, width=4, height=2, text="3", command=lambda: button_for_number17("O")) 328 | myButton17.grid(row=6, column=3, columnspan=3) 329 | myButton18 = Button(root, width=4, height=2, text="6", command=lambda: button_for_number18("O")) 330 | myButton18.grid(row=7, column=3, columnspan=3) 331 | myButton19 = Button(root, width=4, height=2, text="9", command=lambda: button_for_number19("O")) 332 | myButton19.grid(row=8, column=3, columnspan=3) 333 | 334 | 335 | 336 | root.mainloop() 337 | -------------------------------------------------------------------------------- /Weather application for Europe with Tkinter/weather_app_for_Europe.py: -------------------------------------------------------------------------------- 1 | from tkinter import * 2 | from tkinter import Label 3 | import tkinter.messagebox 4 | import requests 5 | from bs4 import BeautifulSoup 6 | 7 | root = Tk() 8 | root.title("Weather application") 9 | root.geometry("925x500+300+200") 10 | root.config(bg="#fff") 11 | root.resizable(False, False) # stop the maximize button on top right corner 12 | 13 | 14 | def checking_weather(): 15 | country_add = country.get() 16 | city_add = city.get() 17 | 18 | final_link = "https://www.foreca.bg/" + country_add + "/" + city_add + "/" + city_add 19 | 20 | if country_add == "United Kingdom": 21 | final_link = "https://www.foreca.bg/" + "United-Kingdom/England" + "/" + city_add 22 | 23 | if city_add == "Sofia": 24 | final_link = "https://www.foreca.bg/" + "Bulgaria/Sofia--Capital/Sofia" 25 | 26 | page = requests.get(final_link) 27 | soup = BeautifulSoup(page.content, 'html.parser') 28 | products = soup.select('div.current') # Extract and store in top_items according to instructions on the left if I want to check print(products) 29 | review_label = "" 30 | for elem in products: 31 | review_label = elem.select('span', class_="value temp temp_c")[0].text 32 | 33 | tkinter.messagebox.showinfo("Temperature!", f"The temperature in {city_add} is {review_label}") 34 | 35 | 36 | frame = Frame(root, width=350, height=200, bg="white") 37 | frame.place(x=250, y=150) 38 | 39 | country_label = Label(frame, text="Country", fg="black", bg="white", font=('Microsoft YaHei UI Light', 14)) 40 | country_label.place(x=80, y=0) 41 | country = Entry(frame, width=25, fg="black", bg="white", font=('Microsoft YaHei UI Light', 11)) 42 | country.place(x=80, y=30) 43 | 44 | city_label = Label(frame, text="City", fg="black", bg="white", font=('Microsoft YaHei UI Light', 14)) 45 | city_label.place(x=80, y=70) 46 | city = Entry(frame, width=25, fg="black", bg="white", font=('Microsoft YaHei UI Light', 11)) 47 | city.place(x=80, y=100) 48 | 49 | sign_button = Button(frame, text="Check the temperature", fg="white", bg="black", font=('Arial Black', 15), command=lambda: 50 | checking_weather()) 51 | sign_button.place(x=50, y=140) 52 | 53 | root.mainloop() 54 | --------------------------------------------------------------------------------