source: src/mlx/mlx.py@ 123:3b181cd0ab99

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

The Preferences dialog works

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