Mercurial > pyarq-presupuestos
comparison pyArq-Presupuestos.py @ 23:65e7ae0d0e63
GTK2 to GTK3
| author | Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es> |
|---|---|
| date | Thu, 02 May 2019 16:31:17 +0200 |
| parents | 2a13413dcc13 |
| children | 16f91684686b |
comparison
equal
deleted
inserted
replaced
| 22:7bd4ca56607d | 23:65e7ae0d0e63 |
|---|---|
| 1 #!/usr/bin/python | 1 #!/usr/bin/python |
| 2 # -*- coding: utf-8 -*- | 2 # -*- coding: utf-8 -*- |
| 3 ## File presupuestos.py | 3 ## File presupuestos.py |
| 4 ## This file is part of pyArq-Presupuestos. | 4 ## This file is part of pyArq-Presupuestos. |
| 5 ## | 5 ## |
| 6 ## Copyright (C) 2010 Miguel Ángel Bárcena Rodríguez | 6 ## Copyright (C) 2010-2019 Miguel Ángel Bárcena Rodríguez |
| 7 ## <miguelangel@obraencurso.es> | 7 ## <miguelangel@obraencurso.es> |
| 8 ## | 8 ## |
| 9 ## pyArq-Presupuestos is free software: you can redistribute it and/or modify | 9 ## pyArq-Presupuestos is free software: you can redistribute it and/or modify |
| 10 ## it under the terms of the GNU General Public License as published by | 10 ## it under the terms of the GNU General Public License as published by |
| 11 ## the Free Software Foundation, either version 3 of the License, or | 11 ## the Free Software Foundation, either version 3 of the License, or |
| 19 ## You should have received a copy of the GNU General Public License | 19 ## You should have received a copy of the GNU General Public License |
| 20 ## along with this program. If not, see <http://www.gnu.org/licenses/>. | 20 ## along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 21 | 21 |
| 22 # Modules | 22 # Modules |
| 23 import sys | 23 import sys |
| 24 import getopt | |
| 24 import gettext | 25 import gettext |
| 25 # pyArq-Presupuestos modules | 26 # pyArq-Presupuestos modules |
| 27 from Generic import win32Locale | |
| 26 from Generic import globalVars | 28 from Generic import globalVars |
| 27 from Generic import win32Locale | |
| 28 | 29 |
| 29 def _take_APPDATA_path(): | 30 def _take_APPDATA_path(): |
| 30 # take path to find mo file | 31 # take path to find mo file |
| 31 _path = sys.path[0] | 32 _path = sys.path[0] |
| 32 globalVars.path["APPDATA"]= _path | 33 globalVars.path["APPDATA"]= _path |
| 38 """ | 39 """ |
| 39 _app = "pyArq-Presupuestos" | 40 _app = "pyArq-Presupuestos" |
| 40 _dir = globalVars.path["APPDATA"] + "/mo/" | 41 _dir = globalVars.path["APPDATA"] + "/mo/" |
| 41 if sys.platform == 'win32': | 42 if sys.platform == 'win32': |
| 42 win32Locale.check_win32_locale() | 43 win32Locale.check_win32_locale() |
| 43 gettext.install(_app, _dir, unicode=1) | 44 kwargs = {} |
| 45 if sys.version_info < (3,): | |
| 46 kwargs['unicode'] = True | |
| 47 gettext.install(_app, _dir, **kwargs) | |
| 44 | 48 |
| 45 def _run_gui(): | 49 def _run_gtk(): |
| 50 print("Iniciando interfaz Gtk3.") | |
| 51 from Gtk import gui | |
| 52 _app = gui.App() | |
| 53 _app.run(sys.argv) | |
| 54 | |
| 55 def _run_gui(argumentList): | |
| 46 """def _run_gui | 56 """def _run_gui |
| 47 | 57 |
| 48 Shows main window and starts the GTK+ event processing loop. | 58 Shows main window and starts the GTK+ event processing loop. |
| 49 """ | 59 """ |
| 50 from Gtk import gui | 60 unixOptions = "h" |
| 51 _window = gui.MainWindow() | 61 gnuOptions = ["help"] |
| 62 # import before transtale | |
| 63 from Generic import base | |
| 64 | |
| 65 help = base.help | |
| 66 try: | |
| 67 arguments, values = getopt.getopt(argumentList, unixOptions, gnuOptions) | |
| 68 if len(arguments) > 0: | |
| 69 for currentArgument, currentValue in arguments: | |
| 70 if currentArgument in ("-h", "--help"): | |
| 71 print(help) | |
| 72 break | |
| 73 else: | |
| 74 _run_gtk() | |
| 75 else: | |
| 76 _run_gtk() | |
| 77 except getopt.error as err: | |
| 78 # output error | |
| 79 print (str(err)) | |
| 52 | 80 |
| 53 # Run pyArq-Presupuestos | 81 # Run pyArq-Presupuestos |
| 54 if __name__ == "__main__": | 82 if __name__ == "__main__": |
| 55 _take_APPDATA_path() | 83 _take_APPDATA_path() |
| 56 _translate() | 84 _translate() |
| 57 _run_gui() | 85 _run_gui(sys.argv[1:]) |
