Skip to content

Commit

Permalink
Dialog box
Browse files Browse the repository at this point in the history
  • Loading branch information
Ronish authored and Ronish committed Apr 27, 2021
1 parent cbb1c8e commit 8739e3d
Show file tree
Hide file tree
Showing 7 changed files with 62 additions and 0 deletions.
1 change: 1 addition & 0 deletions Calculator.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
# Defining the title of the project*
root.title("Simple Calculator")
root.resizable(0,0,)
root.iconbitmap("image.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
22 changes: 22 additions & 0 deletions dialog_box.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
from tkinter import *
from PIL import ImageTk, Image
from tkinter import filedialog

root = Tk()
root.title("Dialog Box")
root.iconbitmap("image.ico")

def open():
global my_image
root.filename = filedialog.askopenfilename(initialdir="/Downloads", title="Select a file",
filetypes=(("Png Files ", "*.png"), ("All Files", "*.*")))

# sets the location of the selected image in the label
my_label = Label(root, text=root.filename).pack()
#image also gets displayed
my_image = ImageTk.PhotoImage(Image.open(root.filename))
my_image_label = Label(image=my_image).pack()

my_btn = Button(root, text ="Open File", command =open).pack()

mainloop()
11 changes: 11 additions & 0 deletions imag.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from tkinter import *

root = Tk()

root.title("Images Insertion")

root.iconbitmap("image.ico")
Frame = LabelFrame(root, text ="MyFrame", padx=5, pady=5)
Frame.pack(padx=10,pady=10)

root.mainloop()
Binary file added image.ico
Binary file not shown.
Binary file added photo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
23 changes: 23 additions & 0 deletions test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
from tkinter import *
from PIL import ImageTk, Image

root = Tk()

#title
root.ttle("Image Insertion")

#icon images
# png icons does not support sometimes
root.iconbitmap("image.ico")

my_image = ImageTk.PhotoImage(Image.open("photo.png"))
my_label = Label( image = my_image)
my_label.pack()


button_quit= Button(root, text="Exit", command=root.quit, width=20)
button_quit.pack()



root.mainloop()
5 changes: 5 additions & 0 deletions venv/frame.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@


Frame = LabelFrame(root, text ="MyFrame", padx=5, pady=5)
Frame.pack(padx=10,pady=10)
root.mainloop()

0 comments on commit 8739e3d

Please sign in to comment.