2014-01-16 2 views
1

나는 wxpython을 사용하여 gui 응용 프로그램을 작성하고 py2exe를 사용하여 실행 파일로 변환했습니다. 그러나 실행 파일을 실행할 때마다 명령 프롬프트가 백그라운드에서 나타나고 프로그램을 종료 할 때 닫힙니다. 그것이 나타나지 않게 할 방법이 있습니까?wxpython 응용 프로그램에서 명령 프롬프트 숨기기

당신은 propply py2exe에 설정에서 console에 응용 프로그램 유형을 설정

답변

2

: 여기

setup(windows=... 

나는 example.pyw라는 이름의 파일에 간단한 wxPython에 응용 프로그램을 가지고 : 당신이 그것을 windows을 만들 필요가있는 동안

setup(console=... 

:

# -*-coding: utf-8 -*- 
#!python 

# @file: example.pyw 

import wx 

class AppFrame(wx.Frame): 
    def __init__(self, title, *args, **kwargs): 
    super(AppFrame, self).__init__(None, title=title, *args, **kwargs) 
    self.panel = wx.Panel(self) 


class AppMain(wx.App): 
    def OnInit(self): 
    self.frame = AppFrame("Example") 
    self.frame.Show() 
    return True 


AppMain(True).MainLoop() 

이것은 sim입니다. 모든 것이 잘 된 경우는 폴더와 dist 이름 뻔

> python setup.py py2exe 
running py2exe 
creating C:\Users\XXX\build 
creating C:\Users\XXX\build\bdist.win32 
... 
    KERNEL32.dll - C:\Windows\system32\KERNEL32.dll 
    MSVCP90.dll - C:\Program Files\CMake 2.8\bin\MSVCP90.dll 
    RPCRT4.dll - C:\Windows\system32\RPCRT4.dll 
> 

:라는 이름의 파일에 PLE 설치 setup.py :

# -*-coding: utf-8 -*- 
#!python 

# @file: setup.py 

from distutils.core import setup 
import py2exe 

# http://msdn.microsoft.com/en-us/library/ms648009%28v=vs.85%29.aspx 
RT_MANIFEST = 24 

# http://en.wikipedia.org/wiki/Side-by-side_assembly 
manifest = """ 
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> 
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0"> 
<dependency> 
    <dependentAssembly> 
    <assemblyIdentity 
     type="win32" 
     name="Microsoft.Windows.Common-Controls" 
     version="6.0.0.0" 
     processorArchitecture="*" 
     publicKeyToken="6595b64144ccf1df" 
     language="*" 
    /> 
    </dependentAssembly> 
</dependency> 
<dependency> 
    <dependentAssembly> 
    <assemblyIdentity 
     type="win32" 
     name="Microsoft.VC90.CRT" 
     version="9.0.21022.8" 
     processorArchitecture="*" 
     publicKeyToken="1fc8b3b9a1e18e3b" 
     language="*" 
    /> 
    </dependentAssembly> 
</dependency> 
</assembly> 
""" 

setup(
    windows = [{ 
    "script" : "example.pyw", 
    # "icon_resources" : [(1, "icon.ico")] # have an icon? 
    "other_resources" : [(RT_MANIFEST, 1, manifest)] 
    }] 
) 

python setup.py py2exe을 해당 디렉토리와 같은 디렉토리 및 cd에 넣어 실행 내부는 example.exe입니다. 그것을 실행하면 콘솔이없는 창이 표시됩니다.

+0

잘 모르겠지만, wx의 새로운 버전이 SxS 매니페스트를 더 이상 필요로하지 않는다고 생각합니다. 나는 파이썬 2.6과 wx 2.8에서만 생각하고 있었다. –

+0

Sweet !! 매우 감사. 그래도 "other_resources"라인을 주석 처리해야했습니다. 나에게 "SyntaxError : invalid syntax"를 보여 주었다. – user2963623