Skip to content

Commit

Permalink
Image Insertion
Browse files Browse the repository at this point in the history
  • Loading branch information
Ronish authored and Ronish committed May 2, 2021
1 parent 1917f54 commit a744f42
Show file tree
Hide file tree
Showing 13 changed files with 88 additions and 17 deletions.
30 changes: 15 additions & 15 deletions Calculator.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# Defining the title of the project*
root.title("Simple Calculator")
root.resizable(0,0,)
root.iconbitmap("image.ico")
root.iconbitmap("calculator.ico")
e = Entry(root, width=35 , font=("Times New roman", 18) , bg="skyblue" , borderwidth=20)
e.grid(row=0, column=0, columnspan=10, padx=10, pady=10)

Expand Down Expand Up @@ -75,20 +75,20 @@ def button_divide():


# Defining the buttons
button_1 = Button(root, text="1", font=("Times New Roman", 20,), padx=40, pady=20, command=lambda: button_click(1))
button_2 = Button(root, text="2", font=("Times New Roman", 20,), padx=40, pady=20, command=lambda: button_click(2))
button_3 = Button(root, text="3", font=("Times New Roman", 20,), padx=40, pady=20, command=lambda: button_click(3))
button_4 = Button(root, text="4", font=("Times New Roman", 20,), padx=40, pady=20, command=lambda: button_click(4))
button_5 = Button(root, text="5", font=("Times New Roman", 20,), padx=40, pady=20, command=lambda: button_click(5))
button_6 = Button(root, text="6", font=("Times New Roman", 20,), padx=40, pady=20, command=lambda: button_click(6))
button_7 = Button(root, text="7", font=("Times New Roman", 20,), padx=40, pady=20, command=lambda: button_click(7))
button_8 = Button(root, text="8", font=("Times New Roman", 20,), padx=40, pady=20, command=lambda: button_click(8))
button_9 = Button(root, text="9", font=("Times New Roman", 20,), padx=40, pady=20, command=lambda: button_click(9))
button_0 = Button(root, text="0", font=("Times New Roman", 20,), padx=40, pady=20, command=lambda: button_click(0))
button_add = Button(root, text="+", font=("Times New Roman", 20,), padx=39, pady=20, command=button_add)
button_subtract = Button(root, text="-", font=("Times New Roman", 20,), padx=40, pady=20, command=button_subract)
button_multiply = Button(root, text="×", font=("Times New Roman", 20,), padx=39, pady=20, command=button_multiply)
button_divide = Button(root, text="÷", font=("Times New Roman", 20,), padx=39, pady=20, command=button_divide)
button_1 = Button(root, text="1",bg="lightgrey", font=("Times New Roman", 20,), padx=40, pady=20, command=lambda: button_click(1))
button_2 = Button(root, text="2", bg="lightgrey", font=("Times New Roman", 20,), padx=40, pady=20, command=lambda: button_click(2))
button_3 = Button(root, text="3", bg="lightgrey", font=("Times New Roman", 20,), padx=40, pady=20, command=lambda: button_click(3))
button_4 = Button(root, text="4", bg="lightgrey", font=("Times New Roman", 20,), padx=40, pady=20, command=lambda: button_click(4))
button_5 = Button(root, text="5", bg="lightgrey", font=("Times New Roman", 20,), padx=40, pady=20, command=lambda: button_click(5))
button_6 = Button(root, text="6", bg="lightgrey", font=("Times New Roman", 20,), padx=40, pady=20, command=lambda: button_click(6))
button_7 = Button(root, text="7", bg="lightgrey", font=("Times New Roman", 20,), padx=40, pady=20, command=lambda: button_click(7))
button_8 = Button(root, text="8", bg="lightgrey", font=("Times New Roman", 20,), padx=40, pady=20, command=lambda: button_click(8))
button_9 = Button(root, text="9", bg="lightgrey", font=("Times New Roman", 20,), padx=40, pady=20, command=lambda: button_click(9))
button_0 = Button(root, text="0", bg="lightgrey", font=("Times New Roman", 20,), padx=40, pady=20, command=lambda: button_click(0))
button_add = Button(root, text="+", bg="lightgrey", font=("Times New Roman", 20,), padx=39, pady=20, command=button_add)
button_subtract = Button(root, text="-", bg="lightgrey", font=("Times New Roman", 20,), padx=40, pady=20, command=button_subract)
button_multiply = Button(root, text="×", bg="lightgrey", font=("Times New Roman", 20,), padx=39, pady=20, command=button_multiply)
button_divide = Button(root, text="÷", bg="lightgrey", font=("Times New Roman", 20,), padx=39, pady=20, command=button_divide)
button_equal = Button(root, bg="skyblue", font=("Times New Roman", 20,), text="=", padx=39, pady=20,
command=button_equal)
button_clear = Button(root, text="Clear", bg="red", font=("Times New Roman", 20, ""), padx=20, pady=20,
Expand Down
71 changes: 71 additions & 0 deletions Image Insertion.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
from tkinter import *
from PIL import ImageTk, Image

root = Tk()

root.title("Image Insertion")
root.iconbitmap("image.ico")

my_image1 = ImageTk.PhotoImage(Image.open("facebook.png"))
my_image2 = ImageTk.PhotoImage(Image.open("messenger.png"))
my_image3 = ImageTk.PhotoImage(Image.open("twitter.png"))
my_image4 = ImageTk.PhotoImage(Image.open("youtube.png"))
my_image5 = ImageTk.PhotoImage(Image.open("google.png"))

image_list = [my_image1, my_image2, my_image3, my_image4, my_image5]


my_label = Label(image=my_image1)
my_label.grid(row=0, column=0, columnspan=3)

def forward(image_number):
global my_label
global button_forward
global button_back

my_label.grid_forget()
my_label = Label(image=image_list[image_number-1])
button_forward = Button(root, text=">>", command=lambda: forward(image_number+1))
button_back = Button(root, text="<<", command=lambda: back(image_number-1))

if image_number == 5:
button_forward = Button(root, text=">>", state=DISABLED)

my_label.grid(row=0, column=0, columnspan=3)
button_back.grid(row=1, column=0)
button_forward.grid(row=1, column=2)

if image_number == 5:
button_forward = Button(root, text=">>", state=DISABLED)


def back(image_number):
global my_label
global button_forward
global button_back

my_label.grid_forget()
my_label = Label(image=image_list[image_number -1])
button_forward = Button(root, text=">>", command=lambda: forward(image_number+1))
button_back = Button(root, text="<<", command=lambda: back(image_number-1))

if image_number == 1:
button_back = Button(root, text="<<", state=DISABLED)

my_label.grid(row=0, column=0, columnspan=3)
button_back.grid(row=1, column=0)
button_forward.grid(row=1, column=2)




button_back = Button(root, text="<<", command=lambda: back, state=DISABLED)
button_back.grid(row=1, column=0)

button_exit = Button(root, text="Exit", command=root.quit)
button_exit.grid(row=1, column=1, )

button_forward = Button(root, text=">>", command=lambda: forward(2))
button_forward.grid(row=1,column=2)

root.mainloop()
Binary file added calculator.ico
Binary file not shown.
Binary file added facebook.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added google.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
2 changes: 1 addition & 1 deletion main.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
def myClick():
textoutput = 'Hello,' + e1.get()

myLabel = Label(root, text = textoutput)
myLabel = Label(root,fg= "red", text = textoutput)

myLabel.pack()

Expand Down
Binary file added messenger.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added photoo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion test.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
root = Tk()

#title
root.ttle("Image Insertion")
root.title("Image Insertion")

#icon images
# png icons does not support sometimes
Expand Down
Binary file added twitter.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added venv/photoo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added youtube.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit a744f42

Please sign in to comment.