编译我的python代码时如何包含图标文件?

问题描述

我能够为可执行文件设置通用图标,但是,我在正确编译代码时遇到问题,以便在我使用 tkinter 为新窗口调用它时显示图标文件(如帮助、关于等) .

我的代码如下:

Window.iconbitmap(r'snake.ico')

感谢您的帮助!谢谢。

解决方法

我会给你一个例子来说明如何做到这一点:

from tkinter import Tk

win = Tk()

photo = PhotoImage(file = "Any image file")

win.iconphoto(True,photo)

让我知道它是否有效。

,

感谢@acw1668 的帮助!答案是:

  1. 将 png 或 ico 转换为 base64,例如https://onlinepngtools.com/convert-png-to-base64 (其他转换工具提供 HTML 等转换。确保删除开头的“数据:...”。仅使用原始文本)。

psp1 <-   tm_shape(province) + 
  tm_borders(col = 'black') + 
  tm_shape(county) + 
  tm_polygons(col = 'estimate',title = 'Changes in %',style = 'fixed',palette = brewer.pal(n = 6,name = 'Spectral'),breaks = c(-15,-10,-5,5,10,15),legend.hist = F) + 
  tm_facets('warming',ncol = 2) + 
  tm_shape(province) + 
  tm_borders(col = 'black') + 
  tm_compass(north = 0,type = 'arrow',show.labels =0,position = c('right','top')) + 
  tm_layout(legend.format = list(fun = function(x) formatC(x,digits = 1,format = "f")),fontface = 'bold',legend.text.size = 1.3,legend.width = 0.2,legend.title.size = 1.5,panel.label.size = 1.5,panel.label.fontface = 'bold')