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

时间:2019-04-16 08:22:23

标签: python tkinter tkinter-canvas

我希望一行文本始终位于底部。我使用了网格,并且由于更早使用了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()

1 个答案:

答案 0 :(得分:1)

更改

label_1.pack(side='bottom')