It is possible to place a Canvas Oval object over a Button and have them act as one.
This simple demo uses tags
to join canvas window objects together.
Code comments explain how.
Click mouse button 1 NEAR Button to pick and place Button/Oval objects
"""
import tkinter as tk
M = tk.Tk()
M.columnconfigure(0, weight = 1)
M.rowconfigure(0, weight = 1)
# Make Main Canvas and Button
C = tk.Canvas(M, width = 400, height = 400)
C.grid(sticky = tk.NSEW)
B = tk.Button(C, text = " Press Me")
B.grid(sticky = tk.NSEW)
# Insert B into window W1
W1 = C.create_window(10, 10, window = B, anchor = tk.NW, tags = "A")
# Make Local Canvas c
c = tk.Canvas(C, width = 16, height = 16)
# Now make Oval
O = c.create_oval(2, 2, 16, 16, fill = "blue")
# Insert O into window W2
W2 = C.create_window(13, 13, window = c, anchor = tk.NW, tags = "A")
# Use tags to move both W1 and W2 as single object
flag = 0
# Demonstration of dual movement using tags
def mover(e):
global flag, x, y, xx, yy
x, y = e.x, e.y
if e.num == 1 and int(e.type) == 4:
flag = 1 - flag
if flag:
C.move("A", x-xx, y-yy)
xx, yy = x, y
# bind
C.event_add("<<CC>>", "<Motion>", "<Button-1>")
C.bind("<<CC>>", mover)
M.mainloop()