-1

I want my half circle to be bolded when I click. Currently, it keeps drawing as already bold.

import tkinter as tk


root = tk.Tk()
canvas = tk.Canvas(root, width=300, height=200, bg='black')
canvas.pack(fill="both", expand=True)

# when you click on the half circle, it becomes bold
half_circle = canvas.create_arc(100, 0, 200, 100, start=0, extent=-180, outline="white", style="arc")

def bold():
    canvas.itemconfigure(half_circle,width=2.5)

canvas.tag_bind(half_circle,"<Button-1>", bold())
root.mainloop()

Update: I changed bold() to bold(event), and am also passing bold. Still not working. I think it could be a problem with PyCharm. Even when I ask it to just print("random") after a click, when the window opens "random" prints immediately and I can't seem to interact with it after. Second update: I wasn't clicking the exact outline, and now understand the difference between calls and callbacks. lol

Christina Zhou
  • 1,483
  • 1
  • 7
  • 17
  • `canvas.tag_bind(half_circle,"", bold())` should be `canvas.tag_bind(half_circle,"", bold)` and your function should be `bold(event):`. – Mike - SMT Sep 23 '19 at 19:53

1 Answers1

1

The argument should be a callback, not a call:

canvas.tag_bind(half_circle, "<Button-1>", bold)
ipaleka
  • 3,745
  • 2
  • 13
  • 33