I have a button that calls a function that asks the user to select a colour. The problem is the colour selection window gets called immediately and the button doesn't work after you input something into the window.
import tkinter as tk
from tkinter.colorchooser import askcolor
main = tk.Tk()
def color_picker(type):
color = askcolor(title = 'choose ' + type + ' color')
return color
track_color = tk.Button(main, text='chose track color', command = color_picker('track'))
track_color.pack()
try :
main()
except TypeError:
pass
I have no idea why this happens as the function, in theory, is only called when the button is pressed.