Partage
  • Partager sur Facebook
  • Partager sur Twitter

[Py2exe] Je n'arrive pas à inclure une icône dans mon .exe !

    2 décembre 2010 à 11:55:38

    Bonjour!

    Alors voilà j'ai un problème, je n'arrive pas à inclure mon icône dans mon exécutable ... j'ai créé mon icône en faisant 3 .png de tailles respectives 16x16, 32x32, 48x48 avec png2ico, puis j'ai placé mon icône dans le dossier du code ... J'ai essayé d'inclure l'icône dans les data_files mais ça change rien.

    Un screen des répertoires : http://is.gd/i5uCI

    compilor.py :
    from subprocess import Popen as popen
    
    popen(['python', 'setup.py', 'py2exe', '-i wx'])
    


    setup.py :
    # -*- coding:Utf-8 -*-
    
    from distutils.core import setup 
    import py2exe
    
    setup(zipfile=None, windows=[{"script":"main.py", "icon_resources":[(0, "esu_icon.ico")]}], data_files=[("", ["esu_icon.ico"])])
    


    main.py :
    import os
    import wx
    import sys
    import time
    import urllib
    
    TEMP_FILENAME = "temp.data"
    SCRN_FILENAME = "temp.png"
    
    def uploadScreen(filepath):
    	os.system("curl -H Expect: -F fileupload=\"@" + filepath + "\" -F xml=yes -# \"http://www.imageshack.us/index.php\" > " + TEMP_FILENAME)
    	with open(TEMP_FILENAME, "r") as file:
    		content = file.read()
    	start = content.find("<image_link>")
    	end = content.find("</image_link>")
    	link = content[start+12:end]
    	os.remove(TEMP_FILENAME)
    	os.remove(SCRN_FILENAME)
    	return link
    	
    def shorten_url(url):
    	try:
    		return urllib.urlopen("http://is.gd/api.php?longurl=%s" % url).read()
    	except:
    		return ''
    	
    class MyFrame(wx.Frame):
    	def __init__(self):
    		wx.Frame.__init__(self, None, wx.ID_ANY, "Easy screenshot uploader - by FMIS@Menace.", size=(390, 100))
    		
    		self.panel = wx.Panel(self, wx.ID_ANY)
    		self.button = wx.Button(self.panel, wx.ID_ANY, "Take Screenshot", size=(350, -1))
    		self.button.Bind(wx.EVT_BUTTON, self.onTakeScreenshot)
    		self.urlText = wx.TextCtrl(self.panel, wx.ID_ANY, style=wx.TE_READONLY, size=(350, -1))
     
    		self.sizer = wx.BoxSizer(wx.VERTICAL)
    		self.sizer.Add(self.button, 0, wx.EXPAND | wx.ALL, 3)
    		self.sizer.Add(self.urlText, 0, wx.EXPAND | wx.ALL, 3)
    		self.panel.SetSizer(self.sizer)
    		
    	def onTakeScreenshot(self, event):
    		self.Show(False)
    		time.sleep(0.5)
    		dcScreen = wx.ScreenDC()
    		memDC = wx.MemoryDC()
    		x, y = wx.DisplaySize()
    		bmp = wx.EmptyBitmap(x, y)
    		memDC.SelectObject(bmp)
    		memDC.Blit(0, 0, x, y, dcScreen, 0, 0)
    		memDC.SelectObject(wx.NullBitmap)
    		img = bmp.ConvertToImage()
    		img.SaveFile(SCRN_FILENAME, wx.BITMAP_TYPE_PNG)
    		link = uploadScreen(os.getcwd() + os.sep + SCRN_FILENAME)
    		if not len(link):
    			wx.MessageDialog(None, "You have not installed cURL\nCheck http://www.paehl.com/open_source/?CURL_7.21.2 !", "Easy Screenshot Uploader - Error", wx.OK | wx.ICON_HAND).ShowModal()
    		if not link.startswith('http') and len(link):
    			wx.MessageDialog(None, "Server didn't respond in time\nGet a better connection and try again!", "Easy Screenshot Uploader - Error", wx.OK | wx.ICON_HAND).ShowModal()
    		short_link = shorten_url(link)
    		if not len(short_link):
    			short_link = link
    		self.urlText.SetLabel(short_link)
    		self.Show(True)
    		
    myApp = wx.App(False)
    myFrame = MyFrame()
    myFrame.Show()
    myApp.MainLoop()
    


    L'icône : http://ompldr.org/vNmU4dA

    Merci d'avance, FMIS@Menace.
    • Partager sur Facebook
    • Partager sur Twitter

    [Py2exe] Je n'arrive pas à inclure une icône dans mon .exe !

    × Après avoir cliqué sur "Répondre" vous serez invité à vous connecter pour que votre message soit publié.
    × Attention, ce sujet est très ancien. Le déterrer n'est pas forcément approprié. Nous te conseillons de créer un nouveau sujet pour poser ta question.
    • Editeur
    • Markdown