annotate Generic/globalVars.py @ 26:16f91684686b default tip

Upgrade to python 3. Keep python 2/3 compatibility
author Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
date Tue, 18 Jun 2019 17:50:23 +0200
parents 189f8274aecd
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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 -*-
6
2fc6b47dbe70 rename module globals to globalVars
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 1
diff changeset
3 ## File globalVars.py
1
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: 22
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
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
22 # module for global variables
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
23 # not translatable strings here _("strig")
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
24
26
16f91684686b Upgrade to python 3. Keep python 2/3 compatibility
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 25
diff changeset
25 # python 2/3 compatibility
16f91684686b Upgrade to python 3. Keep python 2/3 compatibility
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 25
diff changeset
26 from __future__ import absolute_import, division, print_function, unicode_literals
16f91684686b Upgrade to python 3. Keep python 2/3 compatibility
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 25
diff changeset
27
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
28 import os
12
29a4044a95ff svg to png
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 11
diff changeset
29 import sys
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
30
26
16f91684686b Upgrade to python 3. Keep python 2/3 compatibility
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 25
diff changeset
31
16f91684686b Upgrade to python 3. Keep python 2/3 compatibility
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 25
diff changeset
32
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
33 name = "pyArq Presupuestos"
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
34 version = "v0.0.0"
26
16f91684686b Upgrade to python 3. Keep python 2/3 compatibility
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 25
diff changeset
35 changeset = "c26"
7
0359329a1c26 Navigation buttons. Version of the data structure.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 6
diff changeset
36 baseversion = 0
12
29a4044a95ff svg to png
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 11
diff changeset
37
29a4044a95ff svg to png
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 11
diff changeset
38 # path: Paths where find the program files needed
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
39 path = {
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
40 "HOME" : "",
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
41 "APPDATA" : "",
7
0359329a1c26 Navigation buttons. Version of the data structure.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 6
diff changeset
42 "BUDGET": "/pyArq-Presupuestos/budget/",
12
29a4044a95ff svg to png
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 11
diff changeset
43 "ICON" : "/images/pyArq-Presupuestos.png",
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
44 "ICON16" : "/images/pyArq-Presupuestos-16.svg",
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
45 "ICON32" : "/images/pyArq-Presupuestos-32.svg",
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
46 "ICON64" : "/images/pyArq-Presupuestos-64.svg",
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
47 "ICON128" : "/images/pyArq-Presupuestos-128.svg",
12
29a4044a95ff svg to png
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 11
diff changeset
48 "CHAPTER-ICON" : "/images/chapter.png",
29a4044a95ff svg to png
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 11
diff changeset
49 "UNIT-ICON" : "/images/unit.png",
29a4044a95ff svg to png
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 11
diff changeset
50 "MATERIAL-ICON" : "/images/material.png",
29a4044a95ff svg to png
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 11
diff changeset
51 "MACHINERY-ICON" : "/images/machinery.png",
29a4044a95ff svg to png
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 11
diff changeset
52 "LABOURFORCE-ICON": "/images/labourforce.png",
29a4044a95ff svg to png
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 11
diff changeset
53 "MENU-ICON": "/images/menu.png",
29a4044a95ff svg to png
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 11
diff changeset
54 "CONNECTED-ICON": "/images/connected.png",
29a4044a95ff svg to png
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 11
diff changeset
55 "DISCONNECTED-ICON": "/images/disconnected.png",
29a4044a95ff svg to png
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 11
diff changeset
56 "CLOSE-ICON": "/images/close.png",
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
57 "HORIZONTAL": "/images/horizontal.svg",
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
58 "VERTICAL": "/images/vertical.svg",
12
29a4044a95ff svg to png
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 11
diff changeset
59 "DESCRIPTION-ICON": "/images/description.png",
29a4044a95ff svg to png
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 11
diff changeset
60 "SHEET-ICON": "/images/sheet.png",
29a4044a95ff svg to png
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 11
diff changeset
61 "DECOMPOSITION-ICON" : "/images/decomposition.png",
29a4044a95ff svg to png
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 11
diff changeset
62 "MEASURE-ICON" : "/images/measure.png",
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
63 "FILEVIEW-ICON" : "/images/fileview.png",
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
64 "COMPANY-ICON" : "/images/company.png",
12
29a4044a95ff svg to png
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 11
diff changeset
65 "ACUMULATEDLINE-ICON" : "/images/acumulatedline.png",
29a4044a95ff svg to png
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 11
diff changeset
66 "PARCIALLINE-ICON" : "/images/parcialline.png",
29a4044a95ff svg to png
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 11
diff changeset
67 "NORMALLINE-ICON" : "/images/normalline.png",
29a4044a95ff svg to png
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 11
diff changeset
68 "CALCULATEDLINE-ICON" : "/images/calculatedline.png",
29a4044a95ff svg to png
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 11
diff changeset
69 "ARROW-ICON": "/images/arrow.png",
29a4044a95ff svg to png
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 11
diff changeset
70 "IMAGE-ICON": "/images/image.png",
29a4044a95ff svg to png
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 11
diff changeset
71 "DXF-ICON": "/images/dxf.png",
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
72 "PDF-ICON": "/images/pdf.png",
12
29a4044a95ff svg to png
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 11
diff changeset
73 "BUDGET-ICON": "/images/budget.png",
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
74 "PYARQ-ICON": "/images/pyArq.png",
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
75 }
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
76
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
77 color = {
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
78 "ACTIVE" : "#CDD7FF", # Lavender Blue (205,215,255,1)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
79 "INDEX-EVEN" : "#C4C4C4", # Silver, dark grey (196,196,196,1)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
80 "INDEX-UNEVEN" : "#DDDDDD", # Gainsboro, grey (221,221,221,1)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
81 "EVEN" : "#E6E6E6", # Whisper, dark white (230,230,230,1)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
82 "UNEVEN": "#FFFFFF", # White (255,255,255,1)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
83 "CHAPTER-EVEN": "#D8E6E6", # Zircon, dark cian (216,230,230,1)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
84 "CHAPTER-UNEVEN": "#F0FFFF", # Azure, cian (240,255,255,1)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
85 "TEXT": "#000000", # Black ( 0, 0, 0,1)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
86 "CALCULATED-TEXT": "#FF00FF", # Magenta (255, 0,255,1)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
87 "SUBTOTAL": "#FAC8C8", # Coral Candy (250,200,200,1)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
88 "SUBTOTAL-PARCIAL": "#ADD8E6", # Light Blue (173,216,230,1)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
89 }
12
29a4044a95ff svg to png
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 11
diff changeset
90
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
91 desktop = {
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
92 "autodetect" : True, # True: try to autodect desktop
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
93 "desktop" : "", # "linux", "macosx" or "windows"
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
94 "browser" : "", # "firefox"
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
95 "mailapp" : "", # "evolution"
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
96 "imageapp" : "", # "gthumb"
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
97 "wmfapp" : "", # "inkscape"
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
98 "cadapp" : "", # "librecad"
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
99 "videoapp" : "", # "vlc"
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
100 "officeapp" : "", # "libreoffice"
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
101 "txtapp" : "", # "gedit"
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
102 "rtfapp" : "", # "libreoffice"
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
103 }
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
104
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
105 def getAppPath(key):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
106 return path["APPDATA"] + path[key]
12
29a4044a95ff svg to png
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 11
diff changeset
107
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
108 def getHomePath(key):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
109 return path["HOME"] + path[key]
12
29a4044a95ff svg to png
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 11
diff changeset
110
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
111 if os.name == 'posix':
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
112 path["HOME"] = os.environ.get('HOME')
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
113 elif sys.platform == 'win32':
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
114 path["HOME"] = os.environ.get('HOMEPATH')
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
115 # TODO: Mac Os,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
116 # TODO: Test in diferents os
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
117
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
118 #-#
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
119 path["BUDGET"] = "/pyArq-Presupuestos/"
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
120 #-#