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
|
Rev | Line | |
---|
[18] | 1 | # The main program
|
---|
| 2 |
|
---|
[28] | 3 | from .gui.gui import GUI
|
---|
[36] | 4 |
|
---|
| 5 | from config import Config
|
---|
[107] | 6 | from i18n import setLanguage
|
---|
[27] | 7 |
|
---|
[29] | 8 | import os
|
---|
[36] | 9 | import sys
|
---|
[27] | 10 |
|
---|
[38] | 11 | if os.name=="nt":
|
---|
| 12 | import win32api
|
---|
| 13 |
|
---|
[36] | 14 | #--------------------------------------------------------------------------------------
|
---|
| 15 |
|
---|
| 16 | class 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 |
|
---|
| 28 | def main():
|
---|
[29] | 29 | """The main operation of the program."""
|
---|
[36] | 30 | programDirectory = os.path.dirname(sys.argv[0])
|
---|
| 31 |
|
---|
| 32 | config = Config()
|
---|
[40] | 33 | config.load()
|
---|
[107] | 34 |
|
---|
| 35 | setLanguage(config.getLanguage())
|
---|
[40] | 36 |
|
---|
[36] | 37 | gui = GUI(programDirectory, config)
|
---|
[38] | 38 |
|
---|
[36] | 39 | sys.stdout = StdIOHandler(gui)
|
---|
| 40 | sys.stderr = StdIOHandler(gui)
|
---|
| 41 |
|
---|
[38] | 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__
|
---|
[27] | 50 |
|
---|
[40] | 51 | config.save()
|
---|
| 52 |
|
---|
[38] | 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)
|
---|
[27] | 60 |
|
---|
[36] | 61 | #--------------------------------------------------------------------------------------
|
---|
| 62 |
|
---|
[20] | 63 | if __name__ == "__main__":
|
---|
[36] | 64 | main()
|
---|
Note:
See
TracBrowser
for help on using the repository browser.