I have trouble creating a tk.label that has three buttons where I want them. I don't see the buttons and I don't know how to move them through the self.w and self.h
class App(tk.Tk):
def __init__(self, delay):
global image_files
tk.Tk.__init__(self)
self.w = self.winfo_screenwidth()
self.h = self.winfo_screenheight()
self.overrideredirect(1)
self.geometry("%dx%d+0+0" % (self.w, self.h))
self.delay = delay*1000
self.pictures = []
self.setKeyBindings()
self.track_img_ndex = 0
for img in image_files:
self.pictures.append(img)
self.picture_display = tk.Label(self)
self.picture_display.pack(expand=True, fill="both")
frame = tk.Frame(self).pack()
self.boton_izquierdo= tk.Button(frame, text='Previous picture', command=lambda: move(-1)).pack(side=tk.LEFT)
self.boton_derecho= tk.Button(frame, text='Next picture', command=lambda: move(+1)).pack(side=tk.LEFT)
self.boton_salida= tk.Button(frame, text='Quit', command=self.quit).pack(side=tk.LEFT)`
I'd like to see the buttons above the picture
FIRST SOLUTION NOT ALL THE BEST
up = tk.Frame(root)
up.grid(column=0, row=0,columnspan=3,sticky='n')
s1 = tk.Label(up, text='spacer')
s1.pack()
left = tk.Frame(root)
b1 = tk.Button(left, text='B1')
left.grid(column=0,row=1,sticky='w')
b1.pack()
middle = tk.Frame(root)
middle.grid(column=1, row=1)
s2 = tk.Label(middle, text='spacer')
image = Image.open(image_list[current])
photo = ImageTk.PhotoImage(image)
s2['image'] = photo
s2.photo = photo
s2.pack()
down = tk.Frame(root)
qb = tk.Button(down, text='Exit', command= root.destroy)
down.grid(column=0, row=2,columnspan=3,sticky='s')
qb.pack()
right = tk.Frame(root)
right.grid(column=2,row=1,sticky='e')
b2 = tk.Button(right, text='B2')
b2.pack()
root.columnconfigure(0,weight=1) #left get space
root.columnconfigure(2,weight=1) #right get space
root.rowconfigure(0, weight=1) #up get space
root.rowconfigure(2, weight=1) #down get space
root.mainloop()
SOLUTION TO PUT OVERLAYS IN WIDGETS.
label = Tkinter.Label(root, compound=Tkinter.TOP)
label.pack()
A=Tkinter.Button(root, text='Previous picture', command=lambda: move(-1))
A.place(relx=0, x=2, y=20,width=130,height=100)
B=Tkinter.Button(root, text='Next picture', command=lambda: move(+1))
B.place(relx=0, x=135, y=20,width=130,height=100)
C=Tkinter.Button(root, text='PRINT', command=root.quit)
C.place(relx=1, x=-130, y=20,width=130,height=100)
move(0)
root.update()
root.mainloop()
finally the problem is solved with place(), when you want to put buttons on top of images.