How to use input widget in Tkinter

I am trying to make a program in Tkinter that requires an input widget to be used. I have looked at various websites, but none of them CLEAN how to use the Entry widget and its functions. Someone please explain this or give me a great link?

Help will be appreciated how to get information from the widget.

+3
source share
1 answer

This seems like a very general question, but here is a website that has great granularity, and here is a very simple general example:

import Tkinter as tk

class application:
    def __init__(self,window):
        """ Initalize the Application """
        self.myentrybox = tk.Entry(window)
        self.myentrybox.pack()
        self.myentrybox.insert(0,"some default value")
        self.myentrybox.bind("<Return>",self.Enter)

    def Enter(self,event):
        """ Someone Pressed Enter """
        print "You entered >> %s" % (self.myentrybox.get())

root=tk.Tk()
myapp = application(root)
root.mainloop()

Hope you can extrapolate what you need to know ...

+8
source

All Articles