Unable to set the Entry box to correct position in python
Question: I am trying to learn creating GUI using Tkinter .I created a window which
includes text,Messagebox,Entry widget,labels and Radio buttons.

I used grid method for frames and tried to make entry boxes in row0 and row1
.And a message Box with Some text.But these are not properly aligned even
though i gave correct rows and columns but output is not in order.

Entry box is created very far though i mentioned column1 .And message box is
created as per the column specified.Can anyone help me how to solve this.If i
am missing anything please let me now .

    
    
    from Tkinter import*
    import tkMessageBox
    
    
    class Example:
        def __init__(self,root):
            root.title("Sample")
            #Entry functions ---------------------------------------
            Label(root, text="First Name").grid(row=0)
            Label(root, text="Last Name").grid(row=1)
            self.e1 = Entry(root)
            self.e1.bind("<Return>",self.ShowChoice_radio)
            self.e2 = Entry(root)
            self.e2.bind("<Return>",self.ShowChoice_radio)
            self.e1.grid(row=0,column=1)
            self.e2.grid(row =1,column = 1)
            #------------------------------------------------------------------------
            self.frame=Frame(root)
            self.frame.grid(row=3,sticky=W)
            self.label=Label(self.frame, text="mine", width=12,bg="green",fg="white",justify=LEFT)
    
            self.label.grid(row=3,column=4,sticky=W,pady=4)
            root.minsize(width=666, height=220)
            self.v=IntVar()
            role=[("ENGLISH",1),("SPANISH",2),("GERMAN",3)]
            Label(self.frame,text="Choose your role of target:",justify=LEFT,padx=2,pady=2).grid(row=4,sticky=W)
            i=0
            for txt,val in role:
                i=i+1
                self.rad_bt=Radiobutton(self.frame,text=txt,padx=20,variable=self.v,
                            command=self.ShowChoice_radio,value=val)
                self.rad_bt.grid(row=4,column=i+1)
    
            self.bottomframe = Frame(root)
            self.bottomframe.grid(row=12,sticky=W)
            self.hello(12)
            T=Text(self.bottomframe,height=2,width=30)
            T.pack(padx=100,side=TOP)
            T.insert(END,"just a normal text to display!\n")
            self.mbutton=Button(self.bottomframe,text='Quit',command=self.callback,state='normal')
            self.mbutton.pack(padx=3,pady=3,side='left')
            self.help=Button(self.bottomframe,text='Help',command=self.help_msg,width=5,justify=CENTER)
            self.help.pack(padx=93,pady=3,side='left')
    
        def ShowChoice_radio(self):
            print self.v.get()
    
        def help_msg(self):
            tkMessageBox.showinfo("Help to print ",message="Not yet implemented")
            root.minsize(width=666, height=666)
            self.show_entry_fields()
            self.help.config(state=DISABLED)
        def callback(self):
            if tkMessageBox.askyesno('verify','Really Quit?'):
                root.destroy()
    
        def hello(self,name):
            w=Label(root,text="Hello Tkinter!",width=15).grid(row=10)
    
            whatever_you_do = "Whatever . it is my test that \n i can anble to display manner  in this case find out whether it is correct one or wrong \n)"
            msg=Message(root, anchor='s',width=200,text = whatever_you_do)
            msg.config(bg='lightgreen', font=('times', 14, 'italic'))
            msg.grid(row=10,column=1,sticky=W)
        def show_entry_fields(self):
           print "First Name: %s\nLast Name: %s" % (self.e1.get(), self.e2.get())
    
    
    
    if __name__=="__main__":
        root=Tk()
        app=Example(root)
        root.mainloop()
    

Even the quit and Help buttons are not proper...!!!


Answer: I initially voted to close this because there is not a clear question, but
mostly only a series of statements and opinions, at least one of which is
incorrect. After looking more, I think I can answer your implied question "Why
is tkinter behaving in a way that seems wrong to me?". The answer, I believe,
is that you do not understand that grid coordinates are independent (start
over) for each container gridded. Also, coordinates not used are ignored. In
particular:

Root has a grid of 5 rows and 2 columns. Renumbering the rows 0, 1, 2, 3, 4
instead of the confusing labeling you used, there is no entry in column 1 for
rows 2 and 4. The width of column 0 is determined by the width of self.frame
in row 2, column 0. The entry boxes are far to the right because column 0 is
very wide.

Self.frame has a grid of 2 rows and 4 columns. The first 3 columns of row 0
are empty. Self.bottomframe is packed instead of gridded. The buttons are to
the left of where you want because you packed them to the left. In other
words, tkinter did just what you said, which is apparently not what you want.

You might list the result better if you got rid of self.frame, put 'mine' in
(2,0) or (2,0), 'Choose...' in (3, 0), and a frame with 3 radio buttoms in
(3,1). Then root column 0 would not be so overly wide.

