如何在 tkinter python 中为屏幕的下半部分添加填充

问题描述 投票:0回答:1

所以我为这个窗口使用了填充 the window 但正如你所看到的,底部没有填充。

我尝试搜索,但没有任何内容可以帮助解决这个问题 我尝试对按钮使用填充,但结果是这样的。 the image 这也是代码

root = Tk()
root.title(string="Pomodoro work")
root.config(padx=224, pady=100, bg=YELLOW)

canvas = Canvas(width=200, height=224, bg=YELLOW, highlightthickness=0)
tomato_png = PhotoImage(file="tomato.png")
canvas.create_image(100, 112, image=tomato_png)
canvas.create_text(100, 130, text="00.00", fill="white", font=(FONT_NAME, 35, "bold"))
logo = Label(text="Timer", fg=GREEN, bg=YELLOW, font=(FONT_NAME, 70, "bold"))
logo.pack()
times_done = Label(text="✘✘✘✘", fg=RED, bg=YELLOW, font=(FONT_NAME, 35, "bold"))
times_done.place(x=55.5, y=350)
canvas.pack()

start = Button(text="Start", font=("Courier", 20, "normal"))
start.place(x=-139, y=350)
reset = Button(text="reset", font=("Courier", 20, "normal"))
reset.place(x=250, y=350)

root.mainloop()
python tkinter
1个回答
0
投票

您可以使用

geometry
属性设置根窗口的尺寸。所以不要使用:

root.config(padx=224, pady=100, bg=YELLOW)

你应该使用:

root.geometry('224x100')

注意尺寸

  • 必须是字符串
  • 对应于像素中的“x”
© www.soinside.com 2019 - 2024. All rights reserved.