【发布时间】:2015-06-01 14:32:18
【问题描述】:
我无法让我的小部件适合我的计算机屏幕,并且布局未按预期形成。
两个Text 小部件应该扩展并占据它们可用的其余帧,并且包含response2Field 的第二个帧应该适合屏幕,但它没有发生。
我怎样才能实现这些目标?
# -*- coding: utf-8 -*-
from Tkinter import Tk,Label,Entry,Text,Button,Frame
text = """Python was created in the early 1990s by Guido van Rossum at Stichting
Mathematisch Centrum (CWI, see http://www.cwi.nl) in the Netherlands
as a successor of a language called ABC. Guido remains Python's
principal author, although it includes many contributions from others."""
root = Tk()
request = Frame(root)
response = Frame(root)
response1 = Frame(response)
response2 = Frame(response)
request.grid(row=0,column=0,sticky='news')
response.grid(row=0,column=1)
response1.grid(row=0,column=0,sticky='w')
response2.grid(row=1,column=0,sticky='news')
InputText = Text(request)
InputText.pack(expand='true')
Button(response1,text='Submit',bg='brown',fg='yellow').pack()
response2Field = Text(response2,bg='black',fg='green')
response2Field.pack(expand='true')
InputText.insert("1.0",text)
response2Field.insert("1.0",text)
root.mainloop()
输出:
【问题讨论】:
标签: python user-interface layout tkinter widget