Python Forum
change application image
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
change application image
#1
I created exe and working fine, and i wanted to change its application icon in taskbar to my own image.
i tried method below and not working for me.

https://reformatcode.com/code/python/add...yinstaller

i manage to change the exe icon by following method above, but not for the application in Task bar.
a.datas += [('logo.png','C:\\Users\\vijay\\System\\icon\\logo.png','DATA')]
Cry
* using pyinstaller.
Reply
#2
please, post your full spec file.
the icon in the taskbar is the same as the icon of the exe file. you need to specify the icon attribute in the exe part of the spec file.
The line that you show will tell pyinstaller that it need to include this png file when building the exe and this png will be used from your application (e.g. as an tray icon). when it is included with the exe you can use it by reference it with _MEIPASS2. If you don't use _MEIPASS2 you need to supply the png as an external file (i.e. you will distribute exe + png file).
Reply
#3
(Jan-19-2018, 12:05 PM)buran Wrote: please, post your full spec file. the icon in the taskbar is the same as the icon of the exe file. you need to specify the icon attribute in the exe part of the spec file. The line that you show will tell pyinstaller that it need to include this png file when building the exe and this png will be used from your application (e.g. as an tray icon). when it is included with the exe you can use it by reference it with _MEIPASS2. If you don't use _MEIPASS2 you need to supply the png as an external file (i.e. you will distribute exe + png file).

sample as below;
# -*- mode: python -*-

block_cipher = None


a = Analysis(['LT_SC.py'],
             pathex=['C:\\ProgramData\\Miniconda3\\envs\\LT'],
             binaries=[],
             datas=[],
             hiddenimports=['pandas._libs.tslibs.timedeltas'],
             hookspath=[],
             runtime_hooks=[],
             excludes=[],
             win_no_prefer_redirects=False,
             win_private_assemblies=False,
             cipher=block_cipher)
a.datas += [('LOAD.png','C:\\ProgramData\\Miniconda3\\envs\\LT\\LOAD.png','Data')]
pyz = PYZ(a.pure, a.zipped_data,
             cipher=block_cipher)
exe = EXE(pyz,
          a.scripts,
          a.binaries,
          a.zipfiles,
          a.datas,
          name='LT_SC',
          debug=False,
          strip=False,
          upx=True,
          runtime_tmpdir=None,
          console=False ,
          icon='C:\\ProgramData\\Miniconda3\\envs\\LT\\dist\LOAD.ico' )
Reply
#4
This looks OK, icon is set on the last line. I don't see the need for line#17 for the purpose of setting application icon (which is also used in the taskbar)
Reply
#5
If keep icon in root folder then is really simple.
So i usually use virtual environment with Pyinstaller.
In root folder of environment my.py and my.ico
The only line added in spec file.
console=True , icon='my.ico') 
Or build from command line:
pyinstaller --onefile --icon=my.ico my.py
Remember to clean icon cache,or you may not see the new icon.
# Before Win-10 
ie4uinit.exe -ClearIconCache
# For Windows 10, use
ie4uinit.exe -show
Reply
#6
sorry if I didn't elaborate clearly in description,
what I am trying to do is to change the application image in the task bar, not the exe icon.
my application is running with tk GUI not console.
after launching the exe, the default application image as link below;
https://ibb.co/i6mm1S
where i interested to change the default application image to other image.
Reply
#7
I'm not sure you can change the taskbar image to different from the exe icon. what is the purpose to have different image on the taskbar? I don't think I have seen an software that has different taskbar image. Note we are talking about the taskbar, not the tray

ADDITION: What you have shown as icon is the tkinter icon.So you didn't change the exe icon either?
Reply
#8
(Feb-12-2018, 10:32 AM)buran Wrote: I'm not sure you can change the taskbar image to different from the exe icon. what is the purpose to have different image on the taskbar? I don't think I have seen an software that has different taskbar image. Note we are talking about the taskbar, not the tray

ADDITION: What you have shown as icon is the tkinter icon.So you didn't change the exe icon either?

i manage to change the exe icon, but not the taskbar image.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  How to change the resolution of an image and save multiple plots. pianistseb 1 1,254 Dec-11-2018, 07:45 PM
Last Post: micseydel
  Change color pixel in an image louloudevinci 2 33,050 Mar-25-2018, 08:27 PM
Last Post: louloudevinci

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020