'Trying to take a user input and put it into a file, but cannot get it out of the entry box
I am working on a college project and I am building a DnD assistant for it. I am trying to take the user's input and transfer it into a file, however, it no work...
I do not have a lot of experience in the field, so I do not know what is wrong with this code. If anyone could help, please do. I am trying to take the user input and print it out using a button
import tkinter as tk
from tkinter import *
root2=tk.Tk()
F2=Frame(root2)
F2.pack(
ipadx=100,
ipady=100
)
def getItTogether():
global playerName
string = playerName.get()
print (string)
global playerName
playerName = Entry(root2, width= 10)
playerName.place(x=70,y=100)
Button(root2,text="pull your stuff together tkinter", command = getItTogether()).pack()
Solution 1:[1]
I think all you need to do is:
Button(root2,text="pull your stuff together tkinter", command = getItTogether).pack()
and you should be fine. The problem was, that you called the function when defining the button. Just remove the () from the command = getItTogether.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | A J |
