Hi everyone,
I am trying to build application with Tkinter like a wizard, i'll use background image for application, and put some text and image to application window. But i couldn't do that.
When I use background with that code, text labels background color is blocking background view. Is there a way to create transparent texts with Tkinter.Label?
# use a Tkinter label as a panel/frame with a background image
# (note that Tkinter reads only GIF and PGM/PPM images)
import Tkinter as tk
root = tk.Tk()
root.title('background image')
# pick a .gif image file you have in the working directory
image1 = tk.PhotoImage(file="back1.gif")
w = image1.width()
h = image1.height()
root.geometry("%dx%d+0+0" % (w, h))
# tk.Frame has no image argument
# so use a label as a panel/frame
panel1 = tk.Label(root, image=image1)
panel1.pack(side='top', fill='both', expand='yes')
button2 = tk.Button(panel1, text='button2')
button2.pack(side='top')
text1=tk.Label(panel1, text="Welcome to my app")
text1.pack(side=tk.TOP)
# save the panel's image from 'garbage collection'
panel1.image = image1
# start the event loop
root.mainloop()
And when I use canvas to that, text Labels work but I can get buttons to right positions.
import Tkinter as tk
root = tk.Tk()
c = tk.Canvas(width=640, height=480)
c.pack()
# the image
image = tk.PhotoImage(file="back1.gif")
c.create_image(0, 0, image=image)
# and now the text at coordinates (50, 50)
c.create_text(50, 50, text="whatever", fill="blue")
d=tk.Button(text="Click")
d.pack()
root.mainloop()
I am also using bind functions to show a mouseover and out text when cursor is on the buttons.
I prefer to use first code but I can't handle with text Labels