in this section we will be placing widgets on top of a background image in tkinter image. please refer previous_post to understand basic of setting a background image
below is the code for the screen above.
# program
try:
from Tkinter import * # supports Python 2
except:
from tkinter import * # supports Python 3
mw = Tk()
mw.title("AETies : Automation Expert Technologies")
mw.geometry('400x50+50+50')
pic = PhotoImage(file="./bg_2.png")
lbl = Label(mw, image=pic)
lbl.pack(fill=BOTH, expand=YES)
btn = Button(lbl, text="click on below image button to close", highlightcolor='red', command=mw.destroy, padx=5)
btn.pack()
pic_1=PhotoImage(file="./favicon.ico")
btn = Button(lbl, image=pic_1, highlightcolor='red',padx=5, command=mw.destroy)
btn.pack()
mw.mainloop()
as mentioned in previous post, if we skip step 3, background image will not be visible.
# program
try:
from Tkinter import * # supports Python 2
except:
from tkinter import * # supports Python 3
mw = Tk()
mw.title("AETies : Automation Expert Technologies")
mw.geometry('400x50+50+50')
pic = PhotoImage(file="./bg_2.png")
lbl = Label(mw, image=pic)
lbl.pack() #bypassing this, refer above code to know what we are bypassing
btn = Button(lbl, text="click on below image button to close", highlightcolor='red', command=mw.destroy, padx=5)
btn.pack()
pic_1=PhotoImage(file="./favicon.ico")
btn = Button(lbl, image=pic_1, highlightcolor='red',padx=5, command=mw.destroy)
btn.pack()
mw.mainloop()
Comments
Post a Comment