From 8739e3d4876edac1e51dc7ff58129ef9a0774829 Mon Sep 17 00:00:00 2001 From: Ronish Date: Tue, 27 Apr 2021 11:28:59 +0545 Subject: [PATCH] Dialog box --- Calculator.py | 1 + dialog_box.py | 22 ++++++++++++++++++++++ imag.py | 11 +++++++++++ image.ico | Bin 0 -> 67646 bytes photo.png | Bin 0 -> 6028 bytes test.py | 23 +++++++++++++++++++++++ venv/frame.py | 5 +++++ 7 files changed, 62 insertions(+) create mode 100644 dialog_box.py create mode 100644 imag.py create mode 100644 image.ico create mode 100644 photo.png create mode 100644 venv/frame.py diff --git a/Calculator.py b/Calculator.py index a2a313b..6162779 100644 --- a/Calculator.py +++ b/Calculator.py @@ -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) diff --git a/dialog_box.py b/dialog_box.py new file mode 100644 index 0000000..a257fad --- /dev/null +++ b/dialog_box.py @@ -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() \ No newline at end of file diff --git a/imag.py b/imag.py new file mode 100644 index 0000000..84c6445 --- /dev/null +++ b/imag.py @@ -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() \ No newline at end of file diff --git a/image.ico b/image.ico new file mode 100644 index 0000000000000000000000000000000000000000..e7f8a75cb0d1b3e418106089a74d2fc300a23d78 GIT binary patch literal 67646 zcmeI5%Z}7W6ox&`j1oqn*H0_%4~Ts zJNoQe_DYszN6oAVg?TwPvGvif&Rl-t(vHmbGb8ms(?Mx5wiJ!kFET?*`^s1*}B~5lKbDVT|b%OJmCGenRxfl znOvu>!3xa44s~ys9Wp~AW0xzJEPvaIcFb@b^ds)+a1V7s9iaS<*(oz5vUa)h-f-9o zZkwS#^b?*>`7~ofmS79UNSqH~j);VN1jl^V7wyB4h`f(xKPmD1V?*k`n+n?u)b^5I97;-N6(0IQE0Tk&ATcbY5h`M7{wj7!uo}4z{*U*%*|~x}K0m0dud?Nf3t68v=J?DQjQLrCcrPFCkSSST zGVb`^0Q;$lu&(mUrw6j$HtzQe{=6@U_ww-$nUXcWH>4KAI?6A<4tO6B>*Z%H#$qfD zNCVPOnk2Zj`6cD#iD^(*`p8ai^l(Y z_C9~ikzOjmlXa1Ox?*`><3JPk^c8*5{BJyeUjvxqaUR9^J%wLvu)J#xko|Y&2j}_p zWs;BAZKvNyY|BPtFmHUj_`H4w|#GuPn+l7ZNGJV z`B_mLoZ2|2n3c>H9g9WsTI9JF-A|owyoMIRZ4u`Xqw$Q|j?HfQ!M~>8<#h2~L)&p% zrt{CEf#;0-_hvtuJ#U6I%lCL<-`}-9Nwf24fX^3;eVj}u@vhs~L<4*_lk0o{2o@X< zx_-u>u5T)vO{4Q@Ai$ny#eTMU$EeFD8W8(*IZx7Fod)WjDGvFwj>i1-bwLeaj*q{; zK_Xw5t1h_@&uZd#5}_}iW0KaiFHWtHo%qMer_Jkz?ETMnczsu|`f84KH2$ZnnL75I z&sS;J=U7)7NKXSz*yCE~^&Tog8dweX(m;Bg>*ftju6thF`uulw+3WkC)n)I`>oAu1 z|3~21p!q=j`j}_T_u1q4MVzDVex$N?^|MHBi#(UOx62*zZG%@E=ad!}uZ1=_wRvu7 zVfR|-f=?H1NDIxi&?T2H+maThYoQMweY7bpjB24z4t=&QEwnSwZyHx=VDy@78pC<& z#}xONe3>VfsT~tzykqn!HLkPx8*`jv_HCBf#$Jc-0FU|mn0YmD-9EQO{MpCYS#<3m z7_6|397oxcC3Z#=eOL$Y1aOujh|ga{TA}|5N|{mv!qCpDoqzzl`V3 z>xlgQ`5)tlv0uOcG(ColWvXjx0Kb*?j@kagu+863<2^UVKGL^I{t%X z#BTz@FO;PayVU)UMFT!-Z2S2be4OM%=x>;xbgcH3_c>hi91Bv6OX~io7<2htUO$S3 zVj&Gk1JZyrAPqET&yOa*z;BQ%@Eg=pR6*k3OAV=PFy zPx5_seq?>gn4c@SQxl5g>~TyrR%8wK2h8pi8sL2))qctE>Dnb@Fb8|2FU=4;{{52T zI6aQ3#)ynB0DO^7*!qzf`b2%C+CTX{Ub|%b&^RAAL)zn3*=M#!>>d|u#c_NbQ;iMT zo-de#J>N~RY1=mn_8cQp?Wg=6)h?OhcTM-2A(1`bt#R1OZkr)~tgl#(#xk{-kmZhX zJz|DL<}O#>2ToZ5>QMu{XQb9=`RnF#WRLki*dpT3 zC_Q!&OQgXyEYA$FL|Qw8<+Uv=^Mp-T=<=xQ4sv;%%AM5Zq1sJP$=LRljJjp>?p$T_ zt}U;5_~JJYU;XBBGQW8=<~I*#{N~}T-#i@fn>PneAKP+WDVEprkd#Fq{8nyb>*RxK ze*ezod{{p`U(jCYPv~#hpRm7SJi>T|@eJaP;QKrfd_Q0z&yaVhhfpt}o&vpvdJOgI z*q21t1HG?@*TX@;DX*8o5c$E-7D|alV5{oy$o*|t-9HHP7pwa>!uzc^ilOGd?P~qw K;r%?k-~SKLh}8Q4 literal 0 HcmV?d00001 diff --git a/photo.png b/photo.png new file mode 100644 index 0000000000000000000000000000000000000000..769a46ad80d77c1d96c0de261843980dd3e1c509 GIT binary patch literal 6028 zcmeG=`8!no+n+Ng1_@C!$ufmXNJL~Trzj(ZWG{QNWy_Y4=BTGd5uO&MN5)gOGE@vj z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)+O1M)Xo zlt!e$u3nNgr+Ki$jr~xHbz^DH^q%Nn`^f3K-T1LU4o_mV=Um;xK1VB#CDJ@D(O$J`Ip5YliQXlpW zkeRFy9*uV!YJKEwI@<8u)JkVsPFwBMEB>X5fk7LDEH~cBw&t1U4ZM18D<4|NOU9VJ zAn{MP*UoW<{ARN_^>w}cqfiE`@(!b9H2<>23c}C3jrVr@ygCdKSD)kSraDfqWd@Dd z2y~Vi!=44EV3L*34+u$`JSN4O%WEu4Vvq;vZR#--63e%vI;R|`zfJBG9_TCiQm!G< zRMrw-;yXPI7X74Hy?6ML`eX4+5G|-J^s!ZE-$D{of^af(>PO3kw99jxtapnmD~&3L z{2myLvA0!h1+7Mn5z!Y{Ok82scvmp z&f4)no}{QAp%7T;mGa@<>mvs(>kj>Rm)zE_m;W%%*hZt%_24Jl%=Y^-qBF#O)0|6I rEUU@RBNUr@#*zA;4Y%#q3FVn#vNjd;SDxrCJFwsDXj`$z|LlJO|4^V+ literal 0 HcmV?d00001 diff --git a/test.py b/test.py index e69de29..320b489 100644 --- a/test.py +++ b/test.py @@ -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() \ No newline at end of file diff --git a/venv/frame.py b/venv/frame.py new file mode 100644 index 0000000..b424849 --- /dev/null +++ b/venv/frame.py @@ -0,0 +1,5 @@ + + +Frame = LabelFrame(root, text ="MyFrame", padx=5, pady=5) +Frame.pack(padx=10,pady=10) +root.mainloop() \ No newline at end of file