source: src/mlx/mlx.py@ 38:08f7e6592452

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

The status icon is now hidden properly when the program quits, and made restarting nicer

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