[英]How to align text widget in tkinter
I am trying to align two text widgets so they are side by side instead of being below but I cannot find any method that does this. 我正在尝试对齐两个文本窗口小部件,以便它们并排而不是在下面,但是我找不到执行此操作的任何方法。
from Tkinter import *
win = Tk()
win.geometry('800x500')
win.configure()
textbox1 = Text(win, height=10, width=10)
textbox2 = Text(win, height=10, width=10)
textbox1.pack(pady=25)
textbox2.pack(pady=25)
textbox1.configure(borderwidth=0)
textbox2.configure( borderwidth=0)
mainloop()
You can use side=LEFT
and padx
: 您可以使用
side=LEFT
和padx
:
textbox1.pack(side=LEFT,padx=10)
textbox2.pack(side=LEFT,padx=10)
Or you can use the grid
geometry manager: 或者,您可以使用
grid
几何管理器:
textbox1.grid(row=0,column=0,padx=10)
textbox2.grid(row=0,column=1,padx=10)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.