Entry() Is not showing up in my program

Question:

I am having trouble figuring out why my Entry() is not showing up in my program window. I have looked around the internet and I can not figure out what I am doing wrong.

I am trying to place my Entry() field above my main text filed in the program but at this point I would settle for it showing up at all in the program.

The code works fine except for the EntryWidget I am tying to add in.

from tkinter import *
from tkinter.ttk import *
import subprocess as sub
import tkinter.messagebox

#use the doNothing function as a holder for anything that needs to call a function you have not made yet

def doNothing():
    print("Do lots of nothing?")

#~~~~~~~~~~~< Message Box >~~~~~~~~~~~

def ihnb():
    tkinter.messagebox.showinfo("This is an example!", "Icecream Has No Bones!")
    answer = tkinter.messagebox.askquestion("This is not a real question", "Are you trying to become a programer?")
    if answer == "yes":
        a1 = "Then be prepared to spend countless hours hating life!"
        root.text.insert(tkinter.END, a1)
        root.text.see(tkinter.END)
    else:
        a2= "Smart move. Now go away!"
        root.text.insert(tkinter.END, a2)
        root.text.see(tkinter.END)



#create the window
root = Tk()
#modify root window
root.title("MINT:   Mobile Information & Note-taking Tool")
root.geometry("800x600")
root.config(bg = 'Orange')

#~~~~~~~~~~~< Entry Widget >~~~~~~~~~~~
keywordEntry = Entry(root)
keywordEntry.grid(row=3, column=1)
keywordEntry.delete(0, END)
keywordEntry.insert(END, 'default text')

#~~~~~~~~~~~< Menu >~~~~~~~~~~~
menu = Menu(root)
root.config(menu=menu)

fileMenu = Menu(menu)
menu.add_cascade(label="File", menu=fileMenu)
fileMenu.add_command(label="Save", command=doNothing)
fileMenu.add_command(label="Save As", command=doNothing)
fileMenu.add_separator()
fileMenu.add_command(label="Exit", command= doNothing)

helpMenu = Menu(menu)
menu.add_cascade(label="Help", menu=helpMenu)
helpMenu.add_command(label="Info", command=doNothing)

#~~~~~~~~~~~< Toolbar >~~~~~~~~~~~
spacer10 = "          "
toolbar = Frame(root)

somethingButt = tkinter.Button(toolbar, fg = 'Black', bg = 'Orange', text = "Do Python?", command = ihnb)
somethingButt.grid(row = 0, column = 0, padx = 1, pady = 1, sticky = W)
buttonSpacer0_1 = tkinter.Button(toolbar, fg = 'Black', bg = 'Black', text = spacer10)
buttonSpacer0_1.grid(row = 0, column = 1, padx = 1, pady = 1, sticky = W)
somethingButt2 = tkinter.Button(toolbar, fg = 'White', bg = 'Black', text = "Do something?", command = doNothing)
somethingButt2.grid(row = 0, column = 2, padx = 1, pady = 1, sticky = W)
buttonSpacer0_1 = tkinter.Button(toolbar, fg = 'Black', bg = 'Black', text = spacer10)
buttonSpacer0_1.grid(row = 0, column = 3, padx = 1, pady = 1, sticky = W)
somethingButt3 = tkinter.Button(toolbar, fg = 'White', bg = 'Black', text = "Do something?", command = doNothing)
somethingButt3.grid(row = 0, column = 4, padx = 1, pady = 1, sticky = W)

toolbar.grid(row = 0, sticky = W)

#~~~~~~~~~~~< Toolbar >~~~~~~~~~~~

root.text = Text (root, width = 100, height = 10, fg='White', bg='Black', wrap = WORD)
root.text.grid(row = 10, padx=5, pady=5)

#~~~~~~~~~~~< Status Bar >~~~~~~~~~~~

status = Label(root, text = "Preparing to do nothing...", relief = SUNKEN, anchor = W)
status.grid(padx=5, pady=5, sticky = W)


root.mainloop()
Asked By: Mike – SMT

||

Answers:

I am trying to place my Entry() field above my main text filed

I think this is what you are looking for:

enter image description here

If so, then simply change:

keywordEntry.grid(row=3, column=1)

To:

keywordEntry.grid(row=1, column=0, sticky=W)

Nota Bene: This just resolves your problem, but there are other things to improve in your program.

Answered By: Billal Begueradj

It is showing for me i did the same code as you did you forget to save the code?

Answered By: Humaidh Azam
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.