0

I recently started coding and wanted to try something.

I wanted to print the data from an Entry widget (tkinter). But somehow it does not work, can someone explain why and what didn't work. I tried to troubleshoot but without success.

import tkinter as tk

root = tk.Tk()

userInput1 = tk.StringVar()
userInput2 = tk.StringVar()


def pri():
    first = userInput1.get()
    print(first)


canvas = tk.Canvas(root, height=600, width=400, bg='grey',)
canvas.pack()

entry1 = tk.Entry(root, textvariable=userInput1)
entry1.pack()

entry2 = tk.Entry(root, textvariable=userInput2)
entry2.pack()

button = tk.Button(root, text='Create Directory', fg='white', bg='green', command=pri())
button.pack()


root.mainloop()

I'm really clueless, I watched some tutorials and did exactly what they did. :(

0 Answers0