How to integrate code into application in python
Solution 1:
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 its content.