Mercurial > pyarq-presupuestos
annotate 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 |
rev | line source |
---|---|
1
2ac1551ad2ab
add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff
changeset
|
1 #!/usr/bin/python |
2ac1551ad2ab
add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff
changeset
|
2 # -*- coding: utf-8 -*- |
2ac1551ad2ab
add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff
changeset
|
3 ## File presupuestos.py |
2ac1551ad2ab
add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff
changeset
|
4 ## This file is part of pyArq-Presupuestos. |
2ac1551ad2ab
add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff
changeset
|
5 ## |
23
65e7ae0d0e63
GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
15
diff
changeset
|
6 ## Copyright (C) 2010-2019 Miguel Ángel Bárcena Rodríguez |
1
2ac1551ad2ab
add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff
changeset
|
7 ## <miguelangel@obraencurso.es> |
2ac1551ad2ab
add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff
changeset
|
8 ## |
2ac1551ad2ab
add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff
changeset
|
9 ## pyArq-Presupuestos is free software: you can redistribute it and/or modify |
2ac1551ad2ab
add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff
changeset
|
10 ## it under the terms of the GNU General Public License as published by |
2ac1551ad2ab
add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff
changeset
|
11 ## the Free Software Foundation, either version 3 of the License, or |
2ac1551ad2ab
add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff
changeset
|
12 ## (at your option) any later version. |
2ac1551ad2ab
add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff
changeset
|
13 ## |
2ac1551ad2ab
add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff
changeset
|
14 ## pyArq-Presupuestos is distributed in the hope that it will be useful, |
2ac1551ad2ab
add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff
changeset
|
15 ## but WITHOUT ANY WARRANTY; without even the implied warranty of |
2ac1551ad2ab
add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff
changeset
|
16 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
2ac1551ad2ab
add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff
changeset
|
17 ## GNU General Public License for more details. |
2ac1551ad2ab
add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff
changeset
|
18 ## |
2ac1551ad2ab
add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff
changeset
|
19 ## You should have received a copy of the GNU General Public License |
2ac1551ad2ab
add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff
changeset
|
20 ## along with this program. If not, see <http://www.gnu.org/licenses/>. |
2ac1551ad2ab
add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff
changeset
|
21 |
15
2a13413dcc13
gettext on windows
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
14
diff
changeset
|
22 # Modules |
2a13413dcc13
gettext on windows
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
14
diff
changeset
|
23 import sys |
23
65e7ae0d0e63
GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
15
diff
changeset
|
24 import getopt |
15
2a13413dcc13
gettext on windows
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
14
diff
changeset
|
25 import gettext |
2a13413dcc13
gettext on windows
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
14
diff
changeset
|
26 # pyArq-Presupuestos modules |
23
65e7ae0d0e63
GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
15
diff
changeset
|
27 from Generic import win32Locale |
15
2a13413dcc13
gettext on windows
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
14
diff
changeset
|
28 from Generic import globalVars |
2a13413dcc13
gettext on windows
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
14
diff
changeset
|
29 |
2a13413dcc13
gettext on windows
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
14
diff
changeset
|
30 def _take_APPDATA_path(): |
2a13413dcc13
gettext on windows
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
14
diff
changeset
|
31 # take path to find mo file |
2a13413dcc13
gettext on windows
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
14
diff
changeset
|
32 _path = sys.path[0] |
2a13413dcc13
gettext on windows
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
14
diff
changeset
|
33 globalVars.path["APPDATA"]= _path |
2a13413dcc13
gettext on windows
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
14
diff
changeset
|
34 |
1
2ac1551ad2ab
add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff
changeset
|
35 def _translate(): |
2ac1551ad2ab
add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff
changeset
|
36 """def translate() |
2ac1551ad2ab
add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff
changeset
|
37 |
2ac1551ad2ab
add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff
changeset
|
38 Translates the program using gettext module |
2ac1551ad2ab
add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff
changeset
|
39 """ |
2ac1551ad2ab
add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff
changeset
|
40 _app = "pyArq-Presupuestos" |
6
2fc6b47dbe70
rename module globals to globalVars
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
3
diff
changeset
|
41 _dir = globalVars.path["APPDATA"] + "/mo/" |
15
2a13413dcc13
gettext on windows
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
14
diff
changeset
|
42 if sys.platform == 'win32': |
2a13413dcc13
gettext on windows
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
14
diff
changeset
|
43 win32Locale.check_win32_locale() |
23
65e7ae0d0e63
GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
15
diff
changeset
|
44 kwargs = {} |
65e7ae0d0e63
GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
15
diff
changeset
|
45 if sys.version_info < (3,): |
65e7ae0d0e63
GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
15
diff
changeset
|
46 kwargs['unicode'] = True |
65e7ae0d0e63
GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
15
diff
changeset
|
47 gettext.install(_app, _dir, **kwargs) |
1
2ac1551ad2ab
add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff
changeset
|
48 |
23
65e7ae0d0e63
GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
15
diff
changeset
|
49 def _run_gtk(): |
65e7ae0d0e63
GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
15
diff
changeset
|
50 print("Iniciando interfaz Gtk3.") |
65e7ae0d0e63
GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
15
diff
changeset
|
51 from Gtk import gui |
65e7ae0d0e63
GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
15
diff
changeset
|
52 _app = gui.App() |
65e7ae0d0e63
GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
15
diff
changeset
|
53 _app.run(sys.argv) |
65e7ae0d0e63
GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
15
diff
changeset
|
54 |
65e7ae0d0e63
GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
15
diff
changeset
|
55 def _run_gui(argumentList): |
1
2ac1551ad2ab
add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff
changeset
|
56 """def _run_gui |
2ac1551ad2ab
add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff
changeset
|
57 |
2ac1551ad2ab
add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff
changeset
|
58 Shows main window and starts the GTK+ event processing loop. |
2ac1551ad2ab
add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff
changeset
|
59 """ |
23
65e7ae0d0e63
GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
15
diff
changeset
|
60 unixOptions = "h" |
65e7ae0d0e63
GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
15
diff
changeset
|
61 gnuOptions = ["help"] |
65e7ae0d0e63
GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
15
diff
changeset
|
62 # import before transtale |
65e7ae0d0e63
GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
15
diff
changeset
|
63 from Generic import base |
65e7ae0d0e63
GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
15
diff
changeset
|
64 |
65e7ae0d0e63
GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
15
diff
changeset
|
65 help = base.help |
65e7ae0d0e63
GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
15
diff
changeset
|
66 try: |
65e7ae0d0e63
GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
15
diff
changeset
|
67 arguments, values = getopt.getopt(argumentList, unixOptions, gnuOptions) |
65e7ae0d0e63
GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
15
diff
changeset
|
68 if len(arguments) > 0: |
65e7ae0d0e63
GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
15
diff
changeset
|
69 for currentArgument, currentValue in arguments: |
65e7ae0d0e63
GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
15
diff
changeset
|
70 if currentArgument in ("-h", "--help"): |
65e7ae0d0e63
GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
15
diff
changeset
|
71 print(help) |
65e7ae0d0e63
GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
15
diff
changeset
|
72 break |
65e7ae0d0e63
GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
15
diff
changeset
|
73 else: |
65e7ae0d0e63
GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
15
diff
changeset
|
74 _run_gtk() |
65e7ae0d0e63
GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
15
diff
changeset
|
75 else: |
65e7ae0d0e63
GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
15
diff
changeset
|
76 _run_gtk() |
65e7ae0d0e63
GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
15
diff
changeset
|
77 except getopt.error as err: |
65e7ae0d0e63
GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
15
diff
changeset
|
78 # output error |
65e7ae0d0e63
GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
15
diff
changeset
|
79 print (str(err)) |
1
2ac1551ad2ab
add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff
changeset
|
80 |
2ac1551ad2ab
add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff
changeset
|
81 # Run pyArq-Presupuestos |
2ac1551ad2ab
add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff
changeset
|
82 if __name__ == "__main__": |
15
2a13413dcc13
gettext on windows
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
14
diff
changeset
|
83 _take_APPDATA_path() |
1
2ac1551ad2ab
add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff
changeset
|
84 _translate() |
23
65e7ae0d0e63
GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
15
diff
changeset
|
85 _run_gui(sys.argv[1:]) |