473,408 Members | 1,730 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

can't run py app after compile to exe by py2exe , gettext

hi.

I use python 23,py2exe 0.4.3 ,wxpython do my py app in win32.
I use gettext to support multi languages. I build a small fuction for load
language at top of main module.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def setLan(lan):
import gettext
langs = gettext.GNUTranslations(open (join ( localPath,
( "lan/"+lan+".mo" ) )
) )
langs.install()
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Above run normally in debug mode, when I compile to exe by py2exe.
the exe can't run, no error raised, I can see exe in task manager.
but after few seconds , exe disappear automaticlly.

If I remove the function setLan, EXE can show main GUI.
But the function I has used it in another app,python22 ,wxpython.

So I use other way of show multi language.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~
def setLan():
t = gettext.translation("tbt", os.path.join(dir,"locale\\"),
languages=['en'])
t.install()
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~

situation same as before, can run in script mode, exe can't show.
Remove this function, program ok.

I don't what happen , I have test many many times.
Somebody help me :(

ulysses
Jul 18 '05 #1
3 3617
I do a small test app for this. Still can't run.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~
#!/usr/bin/env python
#Boa:App:BoaApp

from wxPython.wx import *

def setLan():
import gettext
lan=gettext.GNUTranslations(open('en.mo'))
lan.install()

class BoaApp(wxApp):
def OnInit(self):
wxInitAllImageHandlers()
setLan()
self.main = wxFrame1(None)
# needed when running from Boa under Windows 9X
self.SetTopWindow(self.main)
self.main.Show();self.main.Hide();self.main.Show()
return True

class wxFrame1(wxFrame):
def __init__(self, parent):
wxFrame.__init__(self, id=-1, name='', parent=parent,
pos=wxPoint(193, 111), size=wxSize(505, 223),
style=wxDEFAULT_FRAME_STYLE, title='wxFrame1')
self.SetClientSize(wxSize(497, 196))
self.SetBackgroundColour(wxColour(192, 192, 192))
self.SetFont(wxFont(14, wxSWISS, wxNORMAL, wxNORMAL, False, 'Tahoma'))

self.staticText2 = wxStaticText(id=2222,
label=_('help me'), name='staticText2', parent=self, pos=wxPoint(72,
128), size=wxSize(336, 40), style=0)

self.staticText1 = wxStaticText(id=3333,
label=_('show text'), name='staticText1', parent=self,
pos=wxPoint(72, 56), size=wxSize(320, 48), style=0)

def main():
application = BoaApp(0)
application.MainLoop()

if __name__ == '__main__':
main()

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~
full source package
please download from

http://211.90.187.42/ourbt/gettexttest.rar

you test in in your computer. Thanks.

Ulysses
Jul 18 '05 #2
ul********@yahoo.com.cn (ulysses) writes:
I do a small test app for this. Still can't run. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~
full source package
please download from

http://211.90.187.42/ourbt/gettexttest.rar

you test in in your computer. Thanks.


I tried it, and it seems you have to make sure that the en.mo file is in
the same directory as the exe, and you have to manually include the
'encodings' package - there's a command line switch for that.

To help to find these types of problems, it's always useful to build the
exe as a console version first with the --console command line flag to
py2exe. There's no way for the --windows exe to notify you of the
tracebacks.

And if you want to try the 0.5.0 version of py2exe (which requires
Python 2.3), here is the setup script you would use:

"""
from distutils.core import setup
import py2exe

setup(name='testgettext',
options = {"py2exe": {"packages": ["encodings"]}},
windows = ['main.py'],
data_files = [("", ["en.mo"])],
)
"""

The latest py2exe 0.5.0 creates windows programs in such a way that
tracebacks are routed into a log file (that would be 'main.exe.log' in
the above case), and even displayes a message box when the program ends
pointing the user to the logfile.

Thomas
Jul 18 '05 #3
Thomas Heller <th*****@python.net> wrote in message news:<ek**********@python.net>...
Thank you very much.

I was killed this question. completely remove python22 and
python23,wxpython,py2exe. then reinstall python22,wxpython,py2exe
0.4.1.

Rewrite my source code to a new py file. it's work.
I still don't know where is bug. But I solve it.
maybe my code very confusion. Python don't like awful code. :)

anyway ,thanks Heller.

ul********@yahoo.com.cn (ulysses) writes:
I do a small test app for this. Still can't run.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~
full source package
please download from

http://211.90.187.42/ourbt/gettexttest.rar

you test in in your computer. Thanks.


I tried it, and it seems you have to make sure that the en.mo file is in
the same directory as the exe, and you have to manually include the
'encodings' package - there's a command line switch for that.

To help to find these types of problems, it's always useful to build the
exe as a console version first with the --console command line flag to
py2exe. There's no way for the --windows exe to notify you of the
tracebacks.

And if you want to try the 0.5.0 version of py2exe (which requires
Python 2.3), here is the setup script you would use:

"""
from distutils.core import setup
import py2exe

setup(name='testgettext',
options = {"py2exe": {"packages": ["encodings"]}},
windows = ['main.py'],
data_files = [("", ["en.mo"])],
)
"""

The latest py2exe 0.5.0 creates windows programs in such a way that
tracebacks are routed into a log file (that would be 'main.exe.log' in
the above case), and even displayes a message box when the program ends
pointing the user to the logfile.

Thomas

Jul 18 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Daniel CAUSSE | last post by:
Hello, I'm testing gettext on my website but it doesn't work. phpinfo returns correct informations: configure command => '--with-gettext=/usr' GetText Support => enabled I have no problem...
1
by: PythonMan | last post by:
warning: py2exe: * The following modules were not found: warning: py2exe: * SOCKS warning: py2exe: * rourl2path warning: py2exe: * ic when i compile btdownloadheadless.py of BitTorrent ,...
8
by: Kathleen Kudzma | last post by:
Does anyone know how to resolve the following problem that I'm getting in Python 2.2 and 2.3? PROBLEM: When I try to create a classReader object I get an exception: "SAXReaderNotAvailable: No...
14
by: Pierre Rouleau | last post by:
I have a problem writing self-testable modules using doctest when these modules have internationalized strings using gettext _('...'). - The main module of an application (say app.py) calls...
3
by: Werner Merkl | last post by:
Hi, Python is really great, for small to big programs. For my colleagues and some circumstances I sometimes need to "compile" a script using py2exe. Cause I use Windows, I like to use the...
2
by: billiejoex | last post by:
Hi all. I tried to compile this little source with py2exe: http://pastebin.com/350143 ....but once I execute the program I encount this error: C:\src\dist>sniffer.exe Traceback (most recent...
10
by: silverburgh.meryl | last post by:
I have a string array: colors = colorIndex = 0; and I want to loop thru each element of colors for str in strings: print colors
0
by: mchristopher | last post by:
I'm having trouble compiling DOM XML support into PHP 4.4.2 on CentOS 4.3. Everytime I attempt to compile, it spits back this: .... chmod 755 /usr/lib/apache/libphp4.so Installing PHP CLI...
0
by: Alexandr N Zamaraev | last post by:
OS: WinXP Home Ru + sp2 Python: 2.5.2 py2exe: latest CSV source gcc (GCC) 3.4.5 (mingw-vista special r2) GNU ld (GNU Binutils) 2.18.50.20080109 OS: WinXP Home Ru + sp2 Python: 2.5.2 py2exe:...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.