source: src/mlx/mlx.py@ 107:35310bf5309c

Last change on this file since 107:35310bf5309c was 107:35310bf5309c, checked in by István Váradi <ivaradi@…>, 12 years ago

Added support for internationalization and translated most of the flight wizard into Hungarian

File size: 1.5 KB
Line 
1# The main program
2
3from .gui.gui import GUI
4
5from config import Config
6from i18n import setLanguage
7
8import os
9import sys
10
11if os.name=="nt":
12 import win32api
13
14#--------------------------------------------------------------------------------------
15
16class StdIOHandler(object):
17 """Handler for the standard I/O messages."""
18 def __init__(self, gui):
19 """Construct the handler."""
20 self._gui = gui
21
22 def write(self, text):
23 """Write the given text into the log."""
24 self._gui.writeStdIO(text)
25
26#--------------------------------------------------------------------------------------
27
28def main():
29 """The main operation of the program."""
30 programDirectory = os.path.dirname(sys.argv[0])
31
32 config = Config()
33 config.load()
34
35 setLanguage(config.getLanguage())
36
37 gui = GUI(programDirectory, config)
38
39 sys.stdout = StdIOHandler(gui)
40 sys.stderr = StdIOHandler(gui)
41
42 try:
43 gui.build(programDirectory)
44
45 gui.run()
46 finally:
47 gui.flushStdIO()
48 sys.stdout = sys.__stdout__
49 sys.stderr = sys.__stderr__
50
51 config.save()
52
53 if gui.toRestart:
54 programPath = os.path.join(os.path.dirname(sys.argv[0]),
55 "runmlx.exe" if os.name=="nt" else "runmlx.sh")
56 if os.name=="nt":
57 programPath = win32api.GetShortPathName(programPath)
58
59 os.execl(programPath, programPath)
60
61#--------------------------------------------------------------------------------------
62
63if __name__ == "__main__":
64 main()
Note: See TracBrowser for help on using the repository browser.