【问题标题】:how can i position frame right to left hasn't margin我怎样才能从右到左定位框架没有边距
【发布时间】:2021-09-10 00:29:49
【问题描述】:

我想把右边的文本框放在左边然后注销按钮的位置不应该移动任何位置 '''

from tkinter import *

# container window
root = Tk()

# frame
frame = Frame(root)

# content of the frame
frame.text = Text(root)
frame.text.insert('1.0', 'Geeks for Geeks')

frame.text.pack_propagate(True)
# to add margin to the frame
frame.text.grid(row=0, column=1,
                pady=20)
# simple button
frame.quitw = Button(root)
frame.quitw["text"] = "Logout",
frame.quitw["command"] = root.quit
frame.quitw.grid(row=1, column=0, padx=100)
frame.quitw.pack_propagate(True)
root.mainloop()

'''

【问题讨论】:

    标签: python tkinter position margin


    【解决方案1】:

    您可以将小部件放在同一列中:

    from tkinter import *
    
    # container window
    root = Tk()
    
    # frame
    frame = Frame(root)
    
    # content of the frame
    frame.text = Text(root)
    frame.text.insert('1.0', 'Geeks for Geeks')
    
    frame.text.pack_propagate(True)
    # to add margin to the frame
    frame.text.grid(row=0, column=1,
                    pady=20)
    # simple button
    frame.quitw = Button(root)
    frame.quitw["text"] = "Logout",
    frame.quitw["command"] = root.quit
    frame.quitw.grid(row=1, column=1, padx=100)
    frame.quitw.pack_propagate(True)
    root.mainloop()
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-08-07
      • 1970-01-01
      • 1970-01-01
      • 2022-08-09
      • 1970-01-01
      • 2012-01-07
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多