我有一个带有图片的按钮。图片不显示,也不单击按钮。line是按钮,照片是粘贴在其上的图片。这是代码:
班级申请:
def __init__(self, master):
self.win = master
self.geo = self.win.geometry
self.geo("800x800+400+400")
self.win['bg'] = "black"
self.fig = Figure(figsize=(6, 4), dpi=96)
self.ax = self.fig.add_subplot(111)
self.graph = FigureCanvasTkAgg(self.fig, master=self.win)
self.canvas = self.graph.get_tk_widget()
photo = tk.PhotoImage(file = r"line.png")
# here, image option is used to
# set image on button
self.line = tk.Button(self.win,
text="Line Graph",
fg="red", image = photo,
command=self.linegraph)
self.line.config( height = 50, width =120 )
self.line.place(x=0, y=180, in_=self.win)
def linegraph(self):
print("hi")