作者vvbird (vv)
看板Python
标题Re: [问题] 请问关於tkinter的问题
时间Mon Jun 10 15:25:24 2019
※ 引述《alubasteve (poorguy)》之铭言:
: 我目前正在学习使用tkinter
: 来练习制作选单排版
: 有2个问题想请教
: 1.我一直想要够更好的调整排版
: 可是一直做不好
: 因为当我这样做时
: https://pastebin.com/fg1fVW4W
: 结果变成
: https://imgur.com/a/6HOlQBH
: 不知为何push2还有push3
: 就是没办法整齐地挤在push1下面
: 然後左右两侧切齐
: 请问怎麽做才好
import tkinter as tk
base=tk.Tk()
button1=tk.Button(base,text="push1",width=30)
button2=tk.Button(base,text="push2",width=15)
button3=tk.Button(base,text="push3",width=15)
button4=tk.Button(base,text="push4",width=30)
button1.grid(row=0,column=0,columnspan=2,sticky=tk.E+tk.W)
button2.grid(row=1,column=0)
button3.grid(row=1,column=1)
button4.grid(row=2,column=0,columnspan=2,sticky=tk.E+tk.W)
base.mainloop()
试试看这样, 是不是你要的?
--
家教经验谈 & 利用 TeX 编考卷与讲义
http://dunst-kang.blogspot.com/
要转录文章的人请注意三件事
1. 请注明出处, 2. 请保留签名档, 3. 请发个 mail 让我知道
我的动态...(要简单的注册才能互动)欢迎一起来罗
--
※ 发信站: 批踢踢实业坊(ptt.cc), 来自: 175.181.185.243 (台湾)
※ 文章网址: https://webptt.com/cn.aspx?n=bbs/Python/M.1560151526.A.2B5.html
1F:推 alubasteve: 感谢您的协助,这样有用,但我想请教您sticky的用途 06/11 22:05
3F:→ alubasteve: 解决对齐方式,从您sticky=tk.E+tk.W来看,您让标签 06/11 22:19
4F:→ alubasteve: 左右两面对齐,但我无法理解为何这样就可解决 06/11 22:20
5F:→ alubasteve: 之前无法解决的对齐问题 06/11 22:20
6F:→ alubasteve: 可以请您指点一下原因吗 06/11 22:23