首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Entry()没有出现在我的程序中。

Entry()没有出现在我的程序中。
EN

Stack Overflow用户
提问于 2017-03-19 06:36:54
回答 1查看 1.1K关注 0票数 1

我很难弄清楚为什么我的条目()没有出现在我的程序窗口中。我环顾了一下互联网,不知道自己做错了什么。

我正在尝试将我的条目()字段放在我在程序中的主要文本上,但此时我会满足于它在程序中出现。

除了我要添加的EntryWidget之外,代码工作得很好。

代码语言:javascript
复制
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()
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-03-19 08:16:04

我正在尝试将我的条目()字段放在我的主文本文件的上方。

我想这就是你要找的:

如果是这样,那么只需更改:

代码语言:javascript
复制
keywordEntry.grid(row=3, column=1)

至:

代码语言:javascript
复制
keywordEntry.grid(row=1, column=0, sticky=W)

Nota Bene:这只是解决了您的问题,但是在您的程序中还有其他需要改进的地方。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/42883651

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档