Tkinter添加图标图像(在python中正确声明?)

时间:2017-12-01 01:51:56

标签: python python-3.x tkinter

enter image description here我想用Tkinter添加我自己的自定义ico图像。

以下作品:

root = tk.Tk()
root.iconbitmap("C:\\Users\\Hoxton\\Pictures\\Saved Pictures\\download_U8F_icon.ico")

但是,当我尝试将其与我的脚本集成时,它不会读取图像。我相信答案就像没有宣布一样简单。但是我在圈子里走来走去。任何人都可以帮助我让这个图标图像工作吗?

import tkinter as tk

import tkinter as tk
import sys
class MyDialog:
    import tkinter as tk



    import tkinter

    def __init__(self, parent):
        top = self.top = tk.Toplevel(parent)
        top.iconbitmap("C:\\Users\\Hoxton\\Pictures\\Saved Pictures\\download_U8F_icon.ico")
        self.myLabel = tk.Label(top, text='Enter the Amount of Emails you would like to create')
        self.myLabel.pack()


        self.myEntryBox = tk.Entry(top)
        self.myEntryBox.pack()
        self.mySubmitButton = tk.Button(top, text='Submit', command=self.send)
        self.mySubmitButton.pack()


    def send(self):
        self.username = self.myEntryBox.get()
        self.top.destroy()

from selenium import webdriver
def onClick():
    inputDialog = MyDialog(root)
    root.wait_window(inputDialog.top)
    root.iconbitmap("C:\\Users\\Hoxton\\Pictures\\Saved Pictures\\download_U8F_icon.ico")
    print('Emails Created: ', inputDialog.username)
    print(inputDialog.username)
    x = int(inputDialog.username)
    for _ in range(x):
        driver = webdriver.Chrome()
        driver.set_window_size(1024, 600)
        #sys.exit()


    root.destroy()




root = tk.Tk()
mainLabel = tk.Label(root, text='How many Emails do you want to create?')
mainLabel.pack()

mainButton = tk.Button(root, text='Custom Amount', command=onClick)
mainButton.pack()

root.mainloop()
print('Username: ')

1 个答案:

答案 0 :(得分:0)

这是我不怀疑的事情。请注意你的声明:

Any

以及:

Any