答案 0 :(得分:1)
要更改图标,您应该使用iconbitmap
或wn_iconbitmap
我认为您希望将其更改为的文件必须是ico文件。
import tkinter as tk
root = tk.Tk()
root.iconbitmap("myIcon.ico")
答案 1 :(得分:1)
如果没有 icon.ico 文件,则可以使用PIL将照片更改为.ico文件
{
"bool" : {
"should" : [
{
"term" : {
"ABC.keyword" : {
"value" : "X1",
"boost" : 1.0
}
}
},
{
"term" : {
"ABC.keyword" : {
"value" : "Y1",
"boost" : 1.0
}
}
}
]
}
}
答案 2 :(得分:0)
您不得在代码所在的目录中或文件夹中拥有favicon.ico。输入完整的路径名。例如:
from tkinter import *
root = Tk()
root.iconbitmap(r'c:\Python32\DLLs\py.ico')
root.mainloop()
这将起作用
答案 3 :(得分:0)
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
using namespace std;
string locateProduct (int num)
{
int line;
string lineStr, productName;
ifstream myfile;
myfile.open("inventory.dat");
if(!myfile)
cout << "file failed to open";
while(getline(myfile,lineStr) && getline(myfile,productName))
{
std::stringstream ss(lineStr);
ss >> line;
if(line == num)
{
cout << "Product code " << num << ": " << productName << endl;
myfile.close();
return productName;
}
}
cout << "Code not found, try again." << endl;
myfile.close();
return "NOTFOUND";
}
from tkinter import *
app = Tk()
app.title('Tk')
app.geometry('')
app.iconbitmap(r'C:\Users\User\PycharmProjects\HelloWorld\my.ico')
app.mainloop()