Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to set the Pygame icon in the taskbar? set_icon() only seem to affect the small icon in the actual window

Tags:

python

pygame

While running my program the icon I configured with pygame.display.set_icon(icon) displays only in the window. In the taskbar the default python icon remains the same.

Is there a way to change that?

Source:

import pygame
from pygame.locals import *
import sys, os
import time

pygame.init()


# Load Images
try:
    bg = os.getcwd() + '\\images\\background.png'
    background = pygame.image.load(bg).convert()
except:
    print 'Error: Could not find background.png'

try:
    logo = os.getcwd() + '\\images\\logo.png'
    c_logo = pygame.image.load(logo).convert()
except:
    print 'Error: Could not find logo.png'

try:
    about_dialog_infile = os.getcwd() + '\\images\\about_dialog[alpha].png'
    about_dialog = pygame.image.load(about_dialog_infile).convert_alpha()
except:
    pass

i_icon = os.getcwd() + '\\images\\icon.png'
icon = pygame.image.load(i_icon)
pygame.display.set_icon(icon)
pygame.display.set_caption("Test program")
screenSize =(640,480)

screen = pygame.display.set_mode(screenSize,0,32)
pygame.display.set_caption('My Test Program')



while True:
    for event in pygame.event.get():
        if event.type == QUIT:
            pygame.quit()
            # sys.exit()
        if event.type == MOUSEBUTTONDOWN:
            check_click(about, event.pos)


screen.blit(background, (0,0))

pygame.display.update()
like image 210
Zack Avatar asked Apr 30 '12 15:04

Zack


1 Answers

I finally figured it out.

As far as I can tell, the only way to actually set that icon in the taskbar is during packaging.

With pyinstaller for example, you would call python pyinstaller.py --icon=icon.ico Where icon is the icon you want displayed in the task bar.

like image 76
Zack Avatar answered Oct 03 '22 00:10

Zack