【发布时间】:2021-10-18 01:38:41
【问题描述】:
我想修复两个按钮的位置,例如,如果我调整窗口大小,按钮将保持在其位置。或者我的按钮会随着窗口大小动态调整大小。我已经使用 place 定位了我的按钮。但我没有成功。这是到目前为止的代码。
import turtle
import tkinter as tk
##wn=turtle.Screen()
wn=tk.Tk()
image=tk.PhotoImage(file="MS-3.PNG")
wn.geometry("700x700")
label1=tk.Label(wn,image=image)
label1.pack(side="top",fill="both",expand="yes")
label1.grid_rowconfigure(0, weight=1)
label1.grid_columnconfigure(0, weight=1)
label1.grid_rowconfigure(1, weight=1)
def callback1():
import Detection1
def callback():
import detection
button1=tk.Button(label1,text="Health Identification", command=callback, bd=12,bg="grey",font="caliber")
button1.place(x=100,y=500 )
label1.image=image
button2=tk.Button(label1,text="Disease Classification", command=callback1, bd=10,bg="grey",font="caliber")
button2.place(x=400, y=500 )
label1.image=image
wn.mainloop()
【问题讨论】:
标签: python-3.x user-interface tkinter button tk