0

I am trying to make a button the command: print("test"). Here is what I have so far:

import os
root = tk.Tk()
button = tk.Button(text="print",
                   fg="black",
                   command=print("test")
                   )
button.pack()
root.mainloop()

how can I do this?

Phudge
  • 1

1 Answers1

0

Following the solution to this question, the following should work:

import os
root = tk.Tk()
button = tk.Button(text="print",
                   fg="black",
                   command=lambda: print("test")
                   )
button.pack()
root.mainloop()
3ddavies
  • 546
  • 2
  • 19