python - 我如何让文本框适合其中的文本
问题描述
我正在使用 Tkinter 创建一个简单的界面,但是当我使用插入功能时,我无法让框适合其中的文本大小
root = Tk()
sub_name = Entry(root)
num = Entry(root)
search_type = Entry(root)
flair_name = Entry(root)
comments = Entry(root)
sub_name.insert(0,"Enter the name of a subreddit")
num.insert(1,"enter how many posts you want to check for a specific flair")
search_type.insert(2,"Enter searech type (top - top posts of all time. hot - top posts in the last few days. new - the newest posts")
flair_name.insert(3,"Enter Flair type")
comments.insert(4,"Enter amount of comments you want to analysie per post")
sub_name.pack()
num.pack()
search_type.pack()
flair_name.pack()
comments.pack()
def myclick():
global sub_name
global num
global search_type
global flair_name
global comments
sub_name = sub_name.get()
num = num.get()
search_type = search_type.get()
flair_name = flair_name.get()
comments = comments.get()
root.destroy()
myButton = Button(root, text="Enter: ", command=myclick)
myButton.pack()
root.protocol(myclick)
root.geometry("500x500")
root.mainloop()
任何建议,将不胜感激。
解决方案
这对你有用吗?
sub_name = Text(root)
num = Text(root)
search_type = Text(root)
flair_name = Text(root)
comments = Text(root)
sub_name.insert(‘end’,"Enter the name of a subreddit")
num.insert(‘end’,"enter how many posts you want to check for a specific flair”)
search_type.insert(‘end’,"Enter searech type (top - top posts of all time. hot - top posts in the last few days. new - the newest posts")
flair_name.insert(‘end’,"Enter Flair type")
comments.insert(‘end’,"Enter amount of comments you want to analysie per post")
推荐阅读
- python - 从索引列表创建子列表的 Pythonic 方法
- python - Python 数据透视列无法识别
- java - matcher.find() 正则表达式 Java 函数
- python - 如何添加具有现有边缘属性的边缘?
- kotlin - 在 TornadoFX 中重用元素
- google-admin-sdk - Google Admin SDK 推送通知仅发送同步消息
- python - 在 txt 文件中可视化坐标,Python
- c++ - 调用析构函数时出现分段错误
- jsonschema - 如何在 json-schema 中定义属性选择
- ionic-framework - cordova-plugin-file-transfer 在 ios 构建中不起作用