所以我對(duì)用 Python 編寫(xiě)面向?qū)ο蟮拇a很陌生,對(duì)制作 GUI 也很陌生。我需要幫助理解為什么下面沒(méi)有在按鈕上顯示任何圖像以及為什么按鈕不起作用但頂部菜單工作正常:def callback(): print("click!")class Window(Frame):# Define settings upon initialization. Here you can specifydef __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_windowdef 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")給出這個(gè)輸出:
tkinter 按鈕放置在窗口中時(shí)不起作用或顯示圖像
寶慕林4294392
2021-06-02 15:45:08