awlsim-gui 1.76 KB
Newer Older
Michael Büsch's avatar
Michael Büsch committed
1 2 3 4
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# AWL simulator - GUI
5
#
6
# Copyright 2012-2014 Michael Buesch <[email protected]>
Michael Büsch's avatar
Michael Büsch committed
7
#
8 9 10 11 12 13 14 15 16 17 18 19 20
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
Michael Büsch's avatar
Michael Büsch committed
21 22
#

23
from __future__ import division, absolute_import, print_function, unicode_literals
24 25 26
if __name__ == "__main__":
	import multiprocessing
	multiprocessing.freeze_support()
27
from awlsim.common.compat import *
28

Michael Büsch's avatar
Michael Büsch committed
29
from awlsim.common import *
30
from awlsim.gui import *
31

32
import getopt
Michael Büsch's avatar
Michael Büsch committed
33

Michael Büsch's avatar
Michael Büsch committed
34

35
def usage():
Michael Büsch's avatar
Michael Büsch committed
36 37
	print("awlsim-gui version %s" % VERSION_STRING)
	print("")
Michael Büsch's avatar
Michael Büsch committed
38
	print("Usage: awlsim-gui [OPTIONS] [PROJECT.awlsim]")
Michael Büsch's avatar
Michael Büsch committed
39 40 41
	print("")
	print("Options:")
	print(" -h|--help             Print this help text")
42

Michael Büsch's avatar
Michael Büsch committed
43
def main():
44
	opt_awlSource = None
45 46 47

	try:
		(opts, args) = getopt.getopt(sys.argv[1:],
Michael Büsch's avatar
Michael Büsch committed
48 49
			"h",
			[ "help", ])
50
	except getopt.GetoptError as e:
Michael Büsch's avatar
Michael Büsch committed
51
		printError(str(e))
52 53 54 55 56 57 58 59 60 61 62 63 64
		usage()
		return 1
	for (o, v) in opts:
		if o in ("-h", "--help"):
			usage()
			return 0
	if args:
		if len(args) == 1:
			opt_awlSource = args[0]
		else:
			usage()
			return 1

65
	mainwnd = MainWindow.start(initialAwlSource = opt_awlSource)
66
	return mainwnd.runEventLoop()
Michael Büsch's avatar
Michael Büsch committed
67 68 69

if __name__ == "__main__":
	sys.exit(main())