【问题标题】:Label to the right side of the tkinter window标签到 tkinter 窗口的右侧
【发布时间】:2021-08-11 13:58:11
【问题描述】:

标签:“Right Text”应该在 tkinter 窗口的右侧。如图所示。

为此,我尝试了下面的代码,但它不在右边。

m_root = Tk()
m_root.wm_state('zoomed')

label_time = Label(m_root, text="Right Text", anchor="e", justify="right").grid()

m_root.mainloop()

【问题讨论】:

  • 了解 Tkinter 中的布局管理器,for example。你的问题是网格函数错误。
  • 有多种方法可以做到这一点。正确的方法取决于窗口中的其他内容。你真的想要一个右边只有一个标签的窗口,还是窗口会有其他东西?您如何添加其他小部件(packgrid?)
  • @BryanOakley 右侧只有单个标签,其他标签也使用网格

标签: python python-3.x tkinter justify layout-anchor


【解决方案1】:

label_time.pack(side="right",anchor="n") 这可能有效。 anchor 将文本定位到右上角。

【讨论】:

    猜你喜欢
    • 2023-02-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多