Issue with simple python program

ZykBee

Newbie
Joined
Oct 30, 2017
Messages
4
Reaction score
0
Can anyone possibly show me how to switch this exact code to print to a textbox instead of to the shell?<<<
from tkinter import *
root = Tk()
root.geometry("500x500")

def retrieve_input():
inputValue = textBox.get("1.0","end-1c")
if inputValue == "test":
print("yes")
else:
print("no")

textBox=Text(root, height=20, width=30)
textBox.pack()

buttonCommit = Button(root, height=1, width=10, text="Commit",
command=lambda:retrieve_input())
buttonCommit.pack()
mainloop()
>>>
 
Like this?

Code:
from tkinter import *
root = Tk()
root.geometry("500x500")

def retrieve_input():
inputValue = textBox.get("1.0","end-1c")
if inputValue == "test":
    ret = "yes"
else:
    ret = "no"

textBox=Text(root, height=20, width=30)
textBox.pack()
textBox.insert(END, ret)

buttonCommit = Button(root, height=1, width=10, text="Commit",
command=lambda:retrieve_input())
buttonCommit.pack()
mainloop()

And please wrap your code with CODE tag.
 
Like this?

Code:
from tkinter import *
root = Tk()
root.geometry("500x500")

def retrieve_input():
inputValue = textBox.get("1.0","end-1c")
if inputValue == "test":
    ret = "yes"
else:
    ret = "no"

textBox=Text(root, height=20, width=30)
textBox.pack()
textBox.insert(END, ret)

buttonCommit = Button(root, height=1, width=10, text="Commit",
command=lambda:retrieve_input())
buttonCommit.pack()
mainloop()

And please wrap your code with CODE tag.

Thank you! What I wound up doing was placing .strip() on the end of a content = line. I appreciate the help!
 
Back
Top