文本锚点不起作用。 (使用canvas.create_window)

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了文本锚点不起作用。 (使用canvas.create_window)相关的知识,希望对你有一定的参考价值。

我希望一行文字始终位于底部。我使用了网格,因为之前使用了pack(),所以无法使用网格。我只是锚定它并没有改变任何东西。这里也是这个网址https://imgur.com/a/yrFzcDO上文字位置的图解说明

import tkinter as tk

window = tk.Tk()
window.configure(background='white')
label_1 = tk.Label(window, text="Conpyright 123456789123456798", anchor=tk.S)
label_1.pack()

ws = window.winfo_screenwidth()
hs = window.winfo_screenheight()
w = 980  # width for the Tk root
h = 600  # height for the Tk root
x = (ws / 2) - (w / 2)
y = (hs / 2) - (h / 2)



window.geometry('%dx%d+%d+%d' % (w, h, x, y))
canvas = tk.Canvas(window, bg="white", width=980, height=580, highlightthickness=0)
canvas.pack()
canvas_scroll = tk.Scrollbar(canvas, command=canvas.yview)
canvas_scroll.place(relx=1, rely=0, relheight=1, anchor=tk.NE)
canvas.configure(yscrollcommand=canvas_scroll.set, scrollregion=())

l0 = tk.Label(canvas, text="강재 NESTING 최적화 프로그램", font= "calibri 32 bold",fg="royalblue4",bg="white" )
canvas.create_window(200,70, window=l0, anchor=tk.NW)

l00 = tk.Label(canvas, text="제조사 시트 입력 정보", font= "calibri 14 bold", bg="white" )
canvas.create_window(30,155, window=l00, anchor=tk.NW)


l1 = tk.Label(canvas, text="MIN", font= "calibri 14", bg="white")
canvas.create_window(210,180, window=l1, anchor=tk.NW)


l2 = tk.Label(canvas, text="MAX", font= "calibri 14", bg="white")
canvas.create_window(340,180, window=l2, anchor=tk.NW)


l3 = tk.Label(canvas, text="Sheet 폭(SW)", font= "calibri 13", bg="white")
canvas.create_window(33,200, window=l3, anchor=tk.NW)

minw_var = tk.DoubleVar()
entry_minw_number = tk.Entry(canvas, textvariable=minw_var)
canvas.create_window(220,215, window=entry_minw_number)

maxw_var = tk.DoubleVar()
entry_maxw_number = tk.Entry(canvas, textvariable=maxw_var)
canvas.create_window(355,215, window=entry_maxw_number)

l4 = tk.Label(canvas, text="Sheet 높이(SH)", font= "calibri 13", bg="white")
canvas.create_window(33,230, window=l4, anchor=tk.NW)

minl_var = tk.DoubleVar()
entry_minl_number = tk.Entry(canvas, textvariable=minl_var)
canvas.create_window(220,240, window=entry_minl_number)

maxl_var = tk.DoubleVar()
entry_maxl_number = tk.Entry(canvas, textvariable=maxl_var)
canvas.create_window(355,240, window=entry_maxl_number)

l5 = tk.Label(canvas, text="소요 Component 개수", font= "calibri 13", bg="white")
canvas.create_window(33,260, window=l5, anchor=tk.NW)

rect_var = tk.IntVar()
entry_rect_number = tk.Entry(canvas, textvariable=rect_var)
canvas.create_window(290,270, window=entry_rect_number)

window.mainloop()
答案

更改

label_1.pack(side='bottom')

以上是关于文本锚点不起作用。 (使用canvas.create_window)的主要内容,如果未能解决你的问题,请参考以下文章

使用锚点单击打开折叠的容器

点击时 UIPageController 点不起作用

iOS核心动画:旋转的锚点不正确

UIScrollView 的右锚点不适用

以编程方式使用布局锚点的自动布局不起作用

使用 nuxt-link 导航到不同页面上的锚点/哈希不起作用