python - How to get a different output in textbox then what the user enters -


i started using tkinter, , question how different output in widget user enters. gui prints whatever user types in entry box , prints user types textbox.

how go making if word entered in entry box sentence printed instead of actual word. example: user types in "cat", prints "hello heard cats" in textbox

this current code:

from tkinter import * import sys  class display(frame):      mgui = tk()     mgui.geometry("500x500-500-300")     mgui.title("gui")     mlabel = label(mgui, text="welcome").pack()      def __init__(self):         frame.__init__(self)         self.entry = entry(self)         self.entry.pack()         self.entry.bind("<return>", self.onenter)         self.clearbutton = button(self, text="clear text", command=self.clear_text)         self.clearbutton.pack()         self.output = text(self)         self.output.pack()         sys.stdout = self         self.pack()      def onenter(self, frame):         print(self.entry.get())      def write(self, txt):         self.output.insert(end, str(txt))      def clear_text(self):         self.entry.delete(0, "end")  if __name__ == '__main__':     display().mainloop() 

make changes in onenter function follows

def onenter(self, frame):         if self.entry.get().lower() == "cat":             print("hello heard " + self.entry.get() + "s")         else:             print(self.entry.get()) 

Comments

Popular posts from this blog

jquery - How do you format the date used in the popover widget title of FullCalendar? -

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -