Python Forum
Print func textbox instead of shell
Thread Rating:
  • 1 Vote(s) - 3 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Print func textbox instead of shell
#1
Can anyone help me print this simple function to a text box instead of the shell?
from tkinter import *
root = Tk()
root.geometry("800x800")

def retrieve_input():
inputValue = textBox.get("1.0","end-1c")
if inputValue == "password":
print("ok")
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?
from tkinter import *
root = Tk()
root.geometry("800x800")

def retrieve_input():
    inputValue = textBox.get("1.0","end-1c")
    if inputValue == "password":
        print("fff")
    else:
        print("got em")

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()
Reply
#2
This seems to work:
>>> import tkinter as tk
>>> root = tk.Tk()
>>> in_text = tk.Text(root, height=20, width=30)
>>> in_text.pack()
>>> out_text = tk.Text(root, height=20, width=30)
>>> out_text.pack()
>>> def on_click():
...   value = in_text.get("0.0", tk.END)
...   out_text.insert("0.0", "you clicked!" + value * 2)
...
>>> tk.Button(root, height=1, width=10, text="Commit", command=on_click).pack()
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  How to output one value per request of the CSV and print it in another func? Student44 3 1,278 Nov-11-2022, 10:45 PM
Last Post: snippsat
  Func Animation not displaying my live graph jotalo 0 1,524 Nov-13-2020, 10:56 PM
Last Post: jotalo
  Trying to write func("abcd") -> "abbcccdddd" omm 8 3,984 Oct-24-2020, 03:41 AM
Last Post: bowlofred
  Take particular symbol from textbox help samuelbachorik 3 2,116 Apr-14-2020, 03:55 AM
Last Post: steve_shambles
  call func from dict mcmxl22 3 2,822 Jun-21-2019, 05:20 AM
Last Post: snippsat
  About [from FILE import FUNC] Nwb 7 3,524 Apr-21-2019, 02:46 PM
Last Post: snippsat
  Executing func() from a different folder ebolisa 2 2,310 Jan-14-2019, 10:18 AM
Last Post: ebolisa
  Correct number wrong position func. albry 5 5,961 Jan-11-2019, 04:01 PM
Last Post: Larz60+
  How can I return my list from a func? Mike Ru 3 3,043 Oct-22-2018, 01:15 PM
Last Post: buran
  add a textbox in an image Akhou 17 10,793 May-23-2018, 09:07 AM
Last Post: Akhou

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020