'Python Tkinter How To Use Button For Consol Entry (Input())?

I am trying to set the button spade2's text to the user's input in the main loop but it doesn't seem to work. Any Ideas? Thanks. I am quite new to Tkinter.

class GUI:
    def __init__(self):
        self.root = Tk()
        self.root.geometry("500x500")
        
    def Clicked(self,btn):
        text = btn.cget("text")
        print("{}".format(text))

    def buttons(self):
        spade2 = Button(self.root, text = "This Text", padx = 50)
        spade2.configure(command=lambda btn=spade2: self.Clicked(btn))
        spade2.grid()

# # # # # # Main Loop # # # # # # 
gui = GUI()
gui.buttons()

# Counter Start
counter = CountingLog(8)
counter.Merg()

# Main Program Loop
while True:
    _input = input()
    if _input == "q":
        break
    inputSep = _input.split(" ")
    card = Card(inputSep[0], inputSep[1])
    # Excutes Other Code

When I try to set the text of the button to the user input it gives me this:

card = Card(inputSep[0], inputSep[1])
IndexError: list index out of range

But when I manually type the input everything works.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source