所以我对用 Python 编写面向对象的代码很陌生,对制作 GUI 也很陌生。我需要帮助理解为什么下面没有在按钮上显示任何图像以及为什么按钮不起作用但顶部菜单工作正常:
def callback():
print("click!")
class Window(Frame):
# Define settings upon initialization. Here you can specify
def __init__(self, master=None):
# parameters that you want to send through the Frame class.
Frame.__init__(self, master)
# reference to the master widget, which is the tk window
self.master = master
# with that, we want to then run init_window, which doesn't yet exist
self.init_window()
def __init__(self, master=None):
# parameters that you want to send through the Frame class.
Frame.__init__(self, master)
# reference to the master widget, which is the tk window
self.master = master
# with that, we want to then run init_window, which doesn't yet exist
self.init_window()
# Creation of init_window
def init_window(self):
self.master.title("ABC Automation Platform")
p1 = IdsPage(self)
self.grid()
# creating a menu instance
menu = Menu(self)
self.master.config(menu=menu)
# create the file object)
file = Menu(menu, tearoff=False)
file.add_command(label="Exit", command=client_exit)
file.add_command(label="Download All", command=download_all)
file.add_command(label="Rename All", command=rename_all)
menu.add_cascade(label="File", menu=file)
edit = Menu(menu, tearoff=False)
help = Menu(menu, tearoff=False)
help.add_command(label="Help")
edit.add_command(label="Undo")
menu.add_cascade(label="Edit", menu=edit)
menu.add_cascade(label="Help", menu=help)
btn_paths = "Resources/Buttons/"
img_ids = PhotoImage(file=btn_paths + "btn_btn_1.png")
img_sox = PhotoImage(file=btn_paths + "btn_btn_1.png")
img_sps = PhotoImage(file=btn_paths + "btn_btn_1.png")
给出这个输出:
相关分类