为了账号安全,请及时绑定邮箱和手机立即绑定

tkinter 按钮放置在窗口中时不起作用或显示图像

tkinter 按钮放置在窗口中时不起作用或显示图像

宝慕林4294392 2021-06-02 15:45:08
所以我对用 Python 编写面向对象的代码很陌生,对制作 GUI 也很陌生。我需要帮助理解为什么下面没有在按钮上显示任何图像以及为什么按钮不起作用但顶部菜单工作正常: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")给出这个输出:
查看完整描述

1 回答

  • 1 回答
  • 0 关注
  • 233 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号