How to integrate code into application in python
Question: This is my application code:

    
    
    #GUI
    from tkinter import *
    #Create the window
    root = Tk()
    #Modify root window
    root.title("Simple Bot")
    root.geometry("500x400")
    #Kick off the event loop
    root.mainloop()
    

This is the bot code:

    
    
    botName = input("Bot: Hello User, my name is ______ please name me: ");
    botName = botName + ": ";
    print(botName + "Thankyou for naming me.");
    firstName = input(botName + "What is your name? ");
    print(botName + "Hello, " + firstName);
    favourite =  input(botName + "Tell us what you like doing the most? ");
    print(botName + "Nice, I like to do that as well.");
    print(botName + "If you have any Questions just ask.");
    

How do I get the bot code to work inside of the application I have created,
and what other code do I have to add for the bot code to work in the
application.

P.S. I am new to python and trying out different things.


Answer: As a simple example to begin, try this:

    
    
    from  Tkinter import *
    import tkMessageBox
    
    root = Tk()
    
    root.title("Simple Bot")
    root.geometry("500x80")
    
    def msg(ev=None):
       tkMessageBox.showinfo("Message", v.get() + " Thank you for naming me.")
    
    
    root.bind('<Return>', msg)
    
    L = Label(root, text="Bot: Hello User, my name is ______ please name me: ", font=("Helvetica", 14)) 
    
    v = StringVar()
    E = Entry(root, textvariable=v, font=("Helvetica", 16))
    
    L.pack()
    E.pack(side=BOTTOM, fill=BOTH, expand=1)
    
    root.mainloop()
    

print is replaced with `tkMessageBox` and input with `Entry`

Use `v.get()` to get text from `Entry` and v.set() to change Entry content.

I hope it will be useful.

