annotate Gtk/gui.py @ 25:189f8274aecd

gui. switch navigation menu on switch page
author Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
date Mon, 20 May 2019 13:18:33 +0200
parents 65e7ae0d0e63
children 16f91684686b
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 # -*- coding: utf-8 -*-
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2 ## File gui.py
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3 ## This file is part of pyArq-Presupuestos.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4 ##
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
5 ## 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
6 ## <miguelangel@obraencurso.es>
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
7 ##
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
8 ## 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
9 ## 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
10 ## 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
11 ## (at your option) any later version.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
12 ##
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
13 ## 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
14 ## 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
15 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
16 ## GNU General Public License for more details.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
17 ##
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
18 ## 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
19 ## 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
20 ##
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 """Gui module
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
23
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
24 The MainWindow class contain the toplevel WINDOW,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
25 this window have a notebook with a page for each budget.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
26 Each budget or notebook page is showed by the Page class, this class contain
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
27 the main widget showed in a page notebook.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
28 The main widget can show the budget information in several panes.
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
29 This panes are ordened in Gtk.Paned represented for the class Paned which can
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
30 have 2 viewes represented for the View class or other Gtk.Paned that have other
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
31 viewes or more Gtk.Paned.
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
32 The view can have diferente type of widgets to show the budget information.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
33 The DecompositionList class show the decompositon list information of a record
7
0359329a1c26 Navigation buttons. Version of the data structure.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 6
diff changeset
34 The Measure class show the measure information of a record
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
35 The Sheet class class show the sheet of condition information of a record
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
36
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
37 The views can send signal to the others.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
38 All the viewes ordered in panes can be or not be connected to the others,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
39 if there are connecteded to the others when the user change the active code in
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
40 one of the panes the active code change in the others.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
41
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
42 """
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
43 # TODO: Config file
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
44
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
45 # Modules
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
46
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
47 # python 2/3 compatibility
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
48 from __future__ import absolute_import, division, print_function, unicode_literals
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
49
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
50 # Standar Modules
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
51 import sys
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
52 import os
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
53 import time
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
54
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
55 # gui
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
56 import gi
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
57 gi.require_version('Gtk', '3.0')
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
58 from gi.repository import Gtk
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
59 from gi.repository import GdkPixbuf
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
60 from gi.repository import Gio
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
61 from gi.repository import GLib
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
62 from gi.repository import Gdk
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
63 from gi.repository import Pango
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
64
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
65 import weakref
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
66
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
67 # pyArq-Presupuestos Modules
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
68 from Gtk import importFiebdc
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
69 from Generic import base
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
70 from Generic import fiebdc
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
71 from Generic import utils
6
2fc6b47dbe70 rename module globals to globalVars
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 5
diff changeset
72 from Generic import globalVars
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
73 from Generic import openwith
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
74
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
75 # Load default icon
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
76 _icons = [ "ICON16", "ICON32","ICON64","ICON128"]
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
77 _pixbufIcons = []
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
78 for _icon in _icons:
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
79 if os.path.exists(globalVars.getAppPath(_icon)):
25
189f8274aecd gui. switch navigation menu on switch page
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 23
diff changeset
80 _icon_file = globalVars.getAppPath(_icon)
189f8274aecd gui. switch navigation menu on switch page
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 23
diff changeset
81 _pixbufIcon = GdkPixbuf.Pixbuf.new_from_file(_icon_file)
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
82 _pixbufIcons.append(_pixbufIcon)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
83 else:
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
84 print(utils.mapping(_("The icon file does not exist. '$1'"),
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
85 (str(globalVars.getAppPath(_icon)),)) )
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
86 if len(_pixbufIcons) > 0:
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
87 Gtk.Window.set_default_icon_list(_pixbufIcons)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
88
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
89 else:
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
90 print(utils.mapping(_("The icon file does not exist. '$1'"),
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
91 (str(globalVars.getAppPath("ICON")),)) )
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
92
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
93 # Autodetect desktop
6
2fc6b47dbe70 rename module globals to globalVars
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 5
diff changeset
94 if globalVars.desktop["autodetect"]:
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
95 openwith.autodetect_desktop()
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
96 print(utils.mapping(_("pyArq-Presupuestos running on $1"),
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
97 (globalVars.desktop["desktop"],)))
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
98
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
99
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
100 class App(Gtk.Application):
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
101 """gui.App:
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
102
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
103 Description:
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
104 This is the Gtk application base class.
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
105 Constructor:
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
106 App()
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
107 Ancestry:
25
189f8274aecd gui. switch navigation menu on switch page
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 23
diff changeset
108 +-- Gtk.Application
189f8274aecd gui. switch navigation menu on switch page
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 23
diff changeset
109 https://lazka.github.io/pgi-docs/Gtk-3.0/classes/Application.html
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
110 +-- App
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
111 Atributes:
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
112 Methods:
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
113 do_activate
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
114 do_startup
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
115 do_open
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
116 """
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
117
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
118 def __init__(self, *args, **kwargs):
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
119 """__init__()
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
120
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
121 Sets the application id and application_name.
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
122 """
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
123 self.filesToOpen = []
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
124 self._application_id = "es.obraencurso.pyarq.presupuestos"
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
125 super(App, self).__init__(application_id=self._application_id,
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
126 flags=Gio.ApplicationFlags.HANDLES_OPEN,
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
127 **kwargs)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
128 GLib.set_prgname(self._application_id)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
129
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
130 def do_open(self, files, n_files, hint):
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
131 """do_open(files, n_files, hint)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
132
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
133 Set the filename list to open.
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
134 """
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
135 self.filesToOpen = files
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
136 self.activate()
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
137 self.filesToOpen = []
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
138 return 0
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
139
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
140 def do_activate(self):
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
141 """do_activate()
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
142
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
143 Shows new appplication windows.
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
144 """
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
145 _mainWindow = MainWindow(self, self.filesToOpen )
25
189f8274aecd gui. switch navigation menu on switch page
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 23
diff changeset
146 _mainWindow.window.present_with_time(Gtk.get_current_event_time())
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
147
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
148 def do_startup(self):
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
149 """do_startup()
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
150
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
151 Sets the app actions.
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
152 """
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
153 Gtk.Application.do_startup(self)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
154 # App Actions
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
155 action = Gio.SimpleAction.new("newWindow", None)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
156 action.connect("activate", self._on_newWindow)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
157 self.add_action(action)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
158
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
159 action = Gio.SimpleAction.new("acell_newWindow", None)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
160 action.connect("activate", self._on_control_n)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
161 self.add_action(action)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
162
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
163 action = Gio.SimpleAction.new("about", None)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
164 action.connect("activate", self._on_about)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
165 self.add_action(action)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
166
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
167 action = Gio.SimpleAction.new("quit", None)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
168 action.connect("activate", self._on_quit)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
169 self.add_action(action)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
170
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
171 action = Gio.SimpleAction.new("acell_quit", None)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
172 action.connect("activate", self._on_control_q)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
173 self.add_action(action)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
174
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
175 # App menu
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
176 _app_menu = Gio.Menu()
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
177 _section_window = Gio.Menu()
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
178 _section_window.append(_("_New window"), "app.newWindow")
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
179 _section_window.append(_("_Close window"), "win.CloseWindow")
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
180 _app_menu.append_section(None,_section_window)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
181 self.set_accels_for_action('win.acell_close', ["<Primary>x"])
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
182 self.set_accels_for_action('app.acell_newWindow', ["<Primary>n"])
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
183 _section_general = Gio.Menu()
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
184 _section_general.append(_("About") + " " + globalVars.name, "app.about")
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
185 _app_menu.append_section(None,_section_general)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
186 _section_quit = Gio.Menu()
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
187 _section_quit.append(_("_Quit application"), "app.quit")
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
188 self.set_accels_for_action('app.acell_quit', ["<Primary>q"])
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
189 _app_menu.append_section(None,_section_quit)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
190 self.set_app_menu(_app_menu)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
191 # TODO : from gui config
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
192 win_menu = False
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
193 # Win Menu
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
194 if win_menu:
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
195 _win_menu = Gio.Menu()
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
196 _win_submenu_file = Gio.Menu.new()
25
189f8274aecd gui. switch navigation menu on switch page
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 23
diff changeset
197 _import_fiebdc = Gio.MenuItem.new(_("_Import Fiebdc"),
189f8274aecd gui. switch navigation menu on switch page
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 23
diff changeset
198 "win.ImportFiebdc")
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
199 _import_fiebdc.set_icon(Gio.Icon.new_for_string("document-open"))
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
200 _win_submenu_file.append_item(_import_fiebdc)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
201
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
202 _close_tab = Gio.MenuItem.new(_("_Close tab"), "win.CloseTab")
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
203 _close_tab.set_icon(Gio.Icon.new_for_string("window-close"))
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
204 _win_submenu_file.append_item(_close_tab)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
205
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
206 _win_menu.append_submenu(_("_File"), _win_submenu_file)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
207 _win_submenu_go = Gio.Menu.new()
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
208 _back = Gio.MenuItem.new(_("_Back"), "win.GoPrevious")
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
209 _back.set_icon(Gio.Icon.new_for_string("go-previous"))
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
210 _win_submenu_go.append_item(_back)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
211 _forward = Gio.MenuItem.new(_("_Forward"), "win.GoPosterior")
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
212 _forward.set_icon(Gio.Icon.new_for_string("go-next"))
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
213 _win_submenu_go.append_item(_forward)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
214 _up = Gio.MenuItem.new(_("_Up Item"), "win.GoUp")
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
215 _up.set_icon(Gio.Icon.new_for_string("go-up"))
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
216 _win_submenu_go.append_item(_up)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
217 _root = Gio.MenuItem.new(_("_Root"), "win.GoToRoot")
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
218 _root.set_icon(Gio.Icon.new_for_string("go-top"))
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
219 _win_submenu_go.append_item(_root)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
220 _win_menu.append_submenu(_("_Go"), _win_submenu_go)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
221 self.set_menubar(_win_menu)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
222
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
223 def _on_newWindow(self, action, param):
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
224 """on_newWindow(action, param)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
225
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
226 Shows new appplication windows.
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
227 """
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
228 _mainWindow = MainWindow(self, [])
25
189f8274aecd gui. switch navigation menu on switch page
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 23
diff changeset
229 _mainWindow.window.present_with_time(Gtk.get_current_event_time())
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
230
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
231 def _on_about(self, action, param):
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
232 """_on_about(action, param)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
233
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
234 Shows About dialog.
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
235 """
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
236 _aboutDialog = Gtk.AboutDialog(modal=False)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
237 _aboutDialog.set_program_name(globalVars.name)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
238 _aboutDialog.set_copyright(base.copyright)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
239 _aboutDialog.set_authors(base.authors)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
240 _aboutDialog.set_version(globalVars.version + globalVars.changeset)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
241 _aboutDialog.set_website(base.website)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
242 _aboutDialog.set_website_label(base.website_label)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
243 _aboutDialog.set_license_type(Gtk.License(3))
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
244 _aboutDialog.set_comments(base.comments)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
245 _aboutDialog.connect("response", self._on_close_aboutdialog)
25
189f8274aecd gui. switch navigation menu on switch page
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 23
diff changeset
246 _aboutDialog.present_with_time(Gtk.get_current_event_time())
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
247
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
248 def _on_close_aboutdialog(self, action, parameter):
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
249 """on_close_aboutdialog(action, param)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
250
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
251 Close About dialog.
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
252 """
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
253 action.destroy()
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
254
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
255 def _on_control_q(self, action, param):
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
256 """on_control_q(action, param)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
257
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
258 Quit app.
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
259 """
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
260 print("Control q -> Quit app")
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
261 self.quit()
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
262
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
263 def _on_quit(self, action, param):
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
264 """_on_quit(action, param)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
265
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
266 Quit app.
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
267 """
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
268 self.quit()
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
269
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
270 def _on_control_n(self, action, param):
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
271 """on_control_n(action, param)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
272
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
273 Shows new appplication windows.
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
274 """
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
275 print("Control n -> New window")
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
276 self._on_newWindow(action, param)
11
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
277
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
278
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
279 class MainWindow(object):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
280 """gui.MainWindow:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
281
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
282 Description:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
283 Creates and shows the main window.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
284 This is the interface base class.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
285 Constructor:
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
286 MainWindow(app, files)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
287 Ancestry:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
288 +-- object
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
289 +-- MainWindow
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
290 Atributes:
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
291 self.window: Gtk.ApplicationWindow object
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
292 Methods:
11
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
293 changeHistorySignal
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
294 changeActiveSignal
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
295 appendEmptyPage
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
296 updatePage
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
297 closePage
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
298 """
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
299 # TODO:* Can choose open budget in new window
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
300 # TODO:* Can choose show more than one notebook in the same window or
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
301 # TODO: can show basedata notebook in a side pane
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
302
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
303 def __init__(self, app, files):
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
304 """__init__(app, files)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
305
11
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
306 Initialize the atributes self.__page_list without data.
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
307 Creates the widgets "window" and "__notebook".
7
0359329a1c26 Navigation buttons. Version of the data structure.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 6
diff changeset
308
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
309 app: Gtk.Application instance
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
310 files: Gio.file list from command line
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
311
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
312 self.window: Gtk.ApplicationWindow object
7
0359329a1c26 Navigation buttons. Version of the data structure.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 6
diff changeset
313 self.__page_list: List of pages ("Page" object)
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
314 self.__notebook: Notebook widget ("Gtk.Notebook" object)
7
0359329a1c26 Navigation buttons. Version of the data structure.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 6
diff changeset
315 self.__general_action_group: "General" action group
11
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
316 self.__navigation_action_group: "Navigation" action group
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
317 self.__navigation_is_enabled: True/False
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
318 self.__goBack_button
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
319 """
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
320 self.__page_list = []
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
321 # Main window
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
322 self.window = Gtk.ApplicationWindow(application=app)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
323 self.window.set_default_size(771, 570)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
324 self.window.set_title("Presupuestos")
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
325 self.window.set_border_width(5)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
326 self.window.connect("delete_event", self._delete_event)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
327 # HeaderBar
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
328 _hb = Gtk.HeaderBar()
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
329 _hb.set_show_close_button(True)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
330 _hb.props.title = "Presupuestos"
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
331 self.window.set_titlebar(_hb)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
332 _hb.show()
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
333 # Actions
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
334 # General Actions
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
335 self.__general_action_group = Gio.SimpleActionGroup.new()
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
336 # CloseWindow Action
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
337 _action = Gio.SimpleAction.new("CloseWindow", None)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
338 _action.connect("activate", self._menuitemClose)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
339 self.window.add_action(_action)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
340 self.__general_action_group.insert(_action)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
341 # CloseWindow from acell Action
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
342 _action = Gio.SimpleAction.new("acell_close", None)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
343 _action.connect("activate", self._on_control_x)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
344 self.window.add_action(_action)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
345 self.__general_action_group.insert(_action)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
346 # ImportFiebdc Action
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
347 _action = Gio.SimpleAction.new("ImportFiebdc", None)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
348 _action.connect("activate", self._on_menuitemImportFiebdc)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
349 self.window.add_action(_action)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
350 self.__general_action_group.insert(_action)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
351 # CloseTab action
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
352 self.__closeTab_action = Gio.SimpleAction.new("CloseTab", None)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
353 self.__closeTab_action.connect("activate", self._on_CloseTab)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
354 self.window.add_action(self.__closeTab_action)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
355 self.__general_action_group.insert(self.__closeTab_action)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
356 # Navigation Actions
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
357 self.__navigation_is_enabled = False
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
358 self.__navigation_action_group = Gio.SimpleActionGroup.new()
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
359 # Go Previous action
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
360 self.__GoPrevious_action = Gio.SimpleAction.new("GoPrevious", None)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
361 self.__GoPrevious_action.connect("activate", self._menuitemGoPrevious)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
362 self.window.add_action(self.__GoPrevious_action)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
363 self.__general_action_group.insert(self.__GoPrevious_action)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
364 self.__GoPrevious_action.set_enabled(False)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
365 # Go posterior action
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
366 self.__GoPosterior_action = Gio.SimpleAction.new("GoPosterior", None)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
367 self.__GoPosterior_action.connect("activate", self._menuitemGoPosterior)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
368 self.window.add_action(self.__GoPosterior_action)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
369 self.__general_action_group.insert(self.__GoPosterior_action)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
370 self.__GoPosterior_action.set_enabled(False)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
371 # Go Up action
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
372 self.__GoUp_action = Gio.SimpleAction.new("GoUp", None)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
373 self.__GoUp_action.connect("activate", self._menuitemGoUp)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
374 self.window.add_action(self.__GoUp_action)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
375 self.__general_action_group.insert(self.__GoUp_action)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
376 self.__GoUp_action.set_enabled(False)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
377 # Go to Root action
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
378 self.__GoToRoot_action = Gio.SimpleAction.new("GoToRoot", None)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
379 self.__GoToRoot_action.connect("activate", self._menuitemGoToRoot)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
380 self.window.add_action(self.__GoToRoot_action)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
381 self.__general_action_group.insert(self.__GoToRoot_action)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
382 self.__GoToRoot_action.set_enabled(False)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
383 # Vertical Grid
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
384 _vbox1 = Gtk.Grid()
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
385 _vbox1.set_orientation(Gtk.Orientation(1)) # 1 Vertical
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
386 self.window.add(_vbox1)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
387 _vbox1.show()
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
388 # Toolbar
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
389 _toolbar = Gtk.Toolbar()
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
390 _toolbar.get_style_context().add_class(Gtk.STYLE_CLASS_PRIMARY_TOOLBAR)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
391 # Import Fiebdc
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
392 _gtk_image = Gtk.Image.new_from_icon_name("document-open",1)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
393 _gtk_image.show()
25
189f8274aecd gui. switch navigation menu on switch page
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 23
diff changeset
394 _ImportFiebdc_button = Gtk.ToolButton.new(_gtk_image,
189f8274aecd gui. switch navigation menu on switch page
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 23
diff changeset
395 _("Import Fiebdc"))
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
396 _ImportFiebdc_button.set_tooltip_text(_("Import Fiebdc"))
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
397 _ImportFiebdc_button.set_is_important(False) # label not shown
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
398 _toolbar.insert(_ImportFiebdc_button, -1)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
399 _ImportFiebdc_button.show()
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
400 _ImportFiebdc_button.set_action_name("win.ImportFiebdc")
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
401 # Close tab
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
402 _gtk_image = Gtk.Image.new_from_icon_name("window-close",1)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
403 _gtk_image.show()
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
404 _closeTabButton = Gtk.ToolButton.new(_gtk_image , _("_Close tab"))
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
405 _closeTabButton.set_tooltip_text(_("Close tab"))
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
406 _closeTabButton.set_is_important(False) # label not shown
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
407 _toolbar.insert(_closeTabButton, -1)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
408 _closeTabButton.show()
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
409 _closeTabButton.set_action_name("win.CloseTab")
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
410 # Separator item
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
411 _separator = Gtk.SeparatorToolItem()
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
412 _separator.show()
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
413 _toolbar.insert(_separator, -1)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
414 # Go Back
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
415 _gtk_image = Gtk.Image.new_from_icon_name("go-previous",1)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
416 _gtk_image.show()
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
417 self.__goBack_button = Gtk.MenuToolButton.new(_gtk_image ,_("Back"))
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
418 self.__goBack_button.set_tooltip_text(_("Back"))
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
419 self.__goBack_button.set_is_important(False) # label not shown
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
420 _toolbar.insert(self.__goBack_button, -1)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
421 self.__goBack_button.show()
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
422 self.__goBack_button.set_action_name("win.GoPrevious")
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
423 # Go Forward
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
424 _gtk_image = Gtk.Image.new_from_icon_name("go-next",1)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
425 _gtk_image.show()
25
189f8274aecd gui. switch navigation menu on switch page
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 23
diff changeset
426 self.__goForward_button = Gtk.MenuToolButton.new(_gtk_image,
189f8274aecd gui. switch navigation menu on switch page
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 23
diff changeset
427 _("Forward"))
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
428 self.__goForward_button.set_tooltip_text(_("Forward"))
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
429 self.__goForward_button.set_is_important(False) # label not shown
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
430 _toolbar.insert(self.__goForward_button, -1)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
431 self.__goForward_button.show()
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
432 self.__goForward_button.set_action_name("win.GoPosterior")
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
433 # Go Up Item
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
434 _gtk_image = Gtk.Image.new_from_icon_name("go-up",1)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
435 _gtk_image.show()
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
436 _goUP_button = Gtk.ToolButton.new(_gtk_image ,_("Up Item"))
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
437 _goUP_button.set_tooltip_text(_("Up Item"))
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
438 _goUP_button.set_is_important(False) # label not shown
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
439 _toolbar.insert(_goUP_button, -1)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
440 _goUP_button.show()
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
441 _goUP_button.set_action_name("win.GoUp")
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
442 # Go Root Item
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
443 _gtk_image = Gtk.Image.new_from_icon_name("go-top",1)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
444 _gtk_image.show()
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
445 _goRoot_button = Gtk.ToolButton.new(_gtk_image ,_("Root"))
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
446 _goRoot_button.set_tooltip_text(_("Root"))
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
447 _goRoot_button.set_is_important(False) # label not shown
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
448 _toolbar.insert(_goRoot_button, -1)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
449 _goRoot_button.show()
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
450 _goRoot_button.set_action_name("win.GoToRoot")
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
451 # Pack and show
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
452 _toolbar.set_hexpand(True) # with extra horizontal space
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
453 _toolbar.show()
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
454 _vbox1.add(_toolbar)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
455 # Notebook
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
456 self.__notebook = Gtk.Notebook()
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
457 _vbox1.add(self.__notebook)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
458 self.__notebook.set_tab_pos(Gtk.PositionType(2)) # Up
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
459 self.__notebook.set_property("expand", True) # widget expand all space
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
460 self.__notebook.set_show_tabs(True)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
461 self.__notebook.set_show_border(True)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
462 self.__notebook.set_scrollable(True)
11
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
463 self.__notebook.connect("switch-page", self._switch_page)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
464 self.__notebook.show()
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
465 self._main()
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
466 if len(files) > 0:
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
467 for file in files:
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
468 _budget = base.Budget()
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
469 _budget_file = fiebdc.Read()
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
470 _read_method = _budget_file.readFile
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
471 _filename = file.get_path()
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
472 _filetype = "budget"
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
473 _exit_method = _budget_file.cancel
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
474 _file_window = FileSelectionWindow(self,
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
475 _read_method, _budget, _filename, _exit_method, _filetype)
11
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
476
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
477 def changeHistorySignal(self):
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
478 """changeHistorySignal()
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
479
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
480 A pane emit the updateHistory signal.
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
481
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
482 Nothing to do now
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
483 """
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
484 pass
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
485
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
486 def changeActiveSignal(self):
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
487 """changeActiveSignal()
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
488
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
489 A pane emit the change-active signal.
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
490
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
491 Chech buttons sensitive
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
492 """
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
493 self._checkButtonsSensitive(self.__notebook.get_current_page())
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
494
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
495 def _checkButtonsSensitive(self, page_num):
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
496 """_checkButtonsSensitive(page_num)
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
497
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
498 page_num: page number in notebook
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
499
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
500 Check and if necessary update the enabled state of the navigation
11
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
501 buttons.
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
502 """
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
503 _page = self.__page_list[page_num]
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
504 if isinstance(_page, Page) and \
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
505 self.__navigation_is_enabled:
11
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
506 # GoToRoot and GoUp actions
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
507 _goto_root = self.__GoToRoot_action
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
508 _go_up = self.__GoUp_action
11
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
509 if len(_page.activePathRecord) == 1 and \
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
510 _goto_root.get_enabled():
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
511 _goto_root.set_enabled(False)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
512 _go_up.set_enabled(False)
11
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
513 elif len(_page.activePathRecord) != 1 and \
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
514 not _goto_root.get_enabled():
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
515 _goto_root.set_enabled(True)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
516 _go_up.set_enabled(True)
11
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
517 # GoPrevMenu action
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
518 _go_Previous = self.__GoPrevious_action
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
519 _go_prev = self.__GoPrevious_action
11
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
520 if _page.previousPathRecord is None:
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
521 if _go_prev.get_enabled():
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
522 _go_prev.set_enabled(False)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
523 self.__goBack_button.props.menu = None
11
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
524 else:
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
525 if not _go_prev.get_enabled():
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
526 _go_prev.set_enabled(True)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
527 self.__goBack_button.set_menu(_page.back_menu)
11
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
528 # GoPostMenu action
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
529 _go_Posterior = self.__GoPosterior_action
11
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
530 if _page.posteriorPathRecord is None:
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
531 if _go_Posterior.get_enabled():
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
532 _go_Posterior.set_enabled(False)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
533 self.__goForward_button.props.menu = None
11
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
534 else:
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
535 if not _go_Posterior.get_enabled():
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
536 _go_Posterior.set_enabled(True)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
537 self.__goForward_button.set_menu(_page.forward_menu)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
538
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
539 def _disable_navigation(self):
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
540 self.__GoPrevious_action.set_enabled(False)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
541 self.__GoPosterior_action.set_enabled(False)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
542 self.__GoUp_action.set_enabled(False)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
543 self.__GoToRoot_action.set_enabled(False)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
544 self.__navigation_is_enabled = False
11
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
545
25
189f8274aecd gui. switch navigation menu on switch page
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 23
diff changeset
546 def _switch_page(self, notebook, page, page_num):
11
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
547 """_switch_page(notebook, page, page_num)
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
548
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
549 Method connected to the "switch-page" signal of the notebook widget
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
550
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
551 It shows/hides closeTabButton
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
552 and changes the sensitive state of the navigation action group
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
553 """
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
554 for _page_num, _page in enumerate(self.__page_list):
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
555 if _page_num == page_num:
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
556 _page.closeTabButton.show()
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
557 else:
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
558 _page.closeTabButton.hide()
11
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
559 _page = self.__page_list[page_num]
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
560
11
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
561 if isinstance(_page, EmptyPage) and \
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
562 self.__navigation_is_enabled:
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
563 self._disable_navigation()
11
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
564 elif isinstance(_page, Page):
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
565 if not self.__navigation_is_enabled:
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
566 self.__navigation_is_enabled = True
25
189f8274aecd gui. switch navigation menu on switch page
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 23
diff changeset
567 self.__goBack_button.set_menu(_page.back_menu)
189f8274aecd gui. switch navigation menu on switch page
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 23
diff changeset
568 self.__goForward_button.set_menu(_page.forward_menu)
189f8274aecd gui. switch navigation menu on switch page
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 23
diff changeset
569 self._checkButtonsSensitive(page_num)
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
570
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
571 def _main(self):
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
572 """main()
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
573
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
574 Shows window.
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
575 """
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
576 self.window.show()
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
577
11
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
578 def appendEmptyPage(self, emptyPage):
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
579 """appendEmptyPage(emptyPage)
11
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
580
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
581 Append a empty page to the notebook.
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
582 """
11
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
583 self.__page_list.append(emptyPage)
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
584 self.__notebook.append_page(emptyPage.widget, emptyPage.title)
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
585 # TODO: reordenable and detachable Pages
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
586 #self.__notebook.set_tab_reorderable(emptyPage.widget, True)
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
587 #self.__notebook.set_tab_detachable(emptyPage.widget, True)
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
588
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
589 def updatePage(self, empty_page, page):
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
590 """updatePage(page)
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
591
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
592 Update emptyPage to Page.
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
593 """
11
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
594 _page_num = self.__notebook.page_num(empty_page.widget)
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
595 self.__page_list[_page_num] = page
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
596 if self.__notebook.get_current_page() == _page_num:
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
597 if not self.__navigation_is_enabled:
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
598 self.__navigation_is_enabled = True
11
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
599 self._checkButtonsSensitive(_page_num)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
600
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
601 def _on_control_x(self, action, param):
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
602 print("Control x -> Close window")
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
603 self.window.destroy()
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
604
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
605 def _on_menuitemImportFiebdc(self, action, parameter):
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
606 """_on_menuitemImportFiebdc(action, parameter)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
607
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
608 action: the action where the event is emitted from
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
609 parameter: None
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
610 Callback to open a budget file.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
611
7
0359329a1c26 Navigation buttons. Version of the data structure.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 6
diff changeset
612 Creates and shows a file selection window to open a budget file.
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
613 """
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
614 _budget = base.Budget()
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
615 _budget_file = fiebdc.Read()
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
616 _read_method = _budget_file.readFile
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
617 _filename = ""
4
4e976a99efb9 update ImportPriceDatabase
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 3
diff changeset
618 _filetype = "budget"
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
619 _exit_method = _budget_file.cancel
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
620 _file_window = FileSelectionWindow(self,
4
4e976a99efb9 update ImportPriceDatabase
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 3
diff changeset
621 _read_method, _budget, _filename, _exit_method, _filetype)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
622
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
623 def _menuitemClose(self, action, parameter):
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
624 """_menuitemClose(action, parameter)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
625
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
626 action: the action where the event is emitted from
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
627 parameter: None
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
628
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
629 Callback to close the main window.
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
630 """
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
631 self.window.destroy()
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
632
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
633 def _on_CloseTab(self, action, parameter):
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
634 """_on_CloseTab(action, parameter)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
635
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
636 action: the action where the event is emitted from
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
637 parameter: None
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
638
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
639 Callback to close tab.
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
640 """
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
641 _page_num = self.__notebook.get_current_page()
7
0359329a1c26 Navigation buttons. Version of the data structure.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 6
diff changeset
642 if _page_num != -1:
0359329a1c26 Navigation buttons. Version of the data structure.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 6
diff changeset
643 _page = self.__page_list[_page_num]
16
60bc5117926c no durus
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 11
diff changeset
644 _page.close()
7
0359329a1c26 Navigation buttons. Version of the data structure.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 6
diff changeset
645
11
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
646 def closePage(self, page):
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
647 """closePage(page)
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
648
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
649 page: EmptyPage or Page object
7
0359329a1c26 Navigation buttons. Version of the data structure.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 6
diff changeset
650
0359329a1c26 Navigation buttons. Version of the data structure.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 6
diff changeset
651 Removes a page from notebook and page_list.
11
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
652 Hide navigation action group if necessary
7
0359329a1c26 Navigation buttons. Version of the data structure.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 6
diff changeset
653 """
11
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
654 if page in self.__page_list:
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
655 _page_num = self.__page_list.index(page)
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
656 self.__page_list.pop(_page_num)
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
657 page.clear()
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
658 self.__notebook.remove_page(_page_num)
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
659 if len(self.__page_list) == 0:
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
660 self._disable_navigation()
11
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
661 else:
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
662 raise IndexError( _("The page is not in the page list") )
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
663
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
664 def _menuitemGoToRoot(self, action, parameter):
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
665 """_menuitemGoToRoot(action, parameter)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
666
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
667 action: the action where the event is emitted from
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
668 parameter: None
7
0359329a1c26 Navigation buttons. Version of the data structure.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 6
diff changeset
669
0359329a1c26 Navigation buttons. Version of the data structure.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 6
diff changeset
670 Callback to go to root record.
0359329a1c26 Navigation buttons. Version of the data structure.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 6
diff changeset
671 """
0359329a1c26 Navigation buttons. Version of the data structure.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 6
diff changeset
672 _page_num = self.__notebook.get_current_page()
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
673 if _page_num == -1:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
674 return
5
6502bfdaa84d update import durus database
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 4
diff changeset
675 _page = self.__page_list[_page_num]
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
676 if isinstance(_page, Page):
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
677 # not loading budget
7
0359329a1c26 Navigation buttons. Version of the data structure.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 6
diff changeset
678 _page.propagateMessageFrom("change_active", (-1,), (0,))
0359329a1c26 Navigation buttons. Version of the data structure.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 6
diff changeset
679
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
680 def _menuitemGoUp(self, action, parameter):
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
681 """_menuitemGoUp(action, parameter)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
682
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
683 action: the action where the event is emitted from
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
684 parameter: None
7
0359329a1c26 Navigation buttons. Version of the data structure.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 6
diff changeset
685
0359329a1c26 Navigation buttons. Version of the data structure.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 6
diff changeset
686 Callback to go to up record.
0359329a1c26 Navigation buttons. Version of the data structure.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 6
diff changeset
687 """
0359329a1c26 Navigation buttons. Version of the data structure.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 6
diff changeset
688 _page_num = self.__notebook.get_current_page()
0359329a1c26 Navigation buttons. Version of the data structure.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 6
diff changeset
689 if _page_num != -1:
0359329a1c26 Navigation buttons. Version of the data structure.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 6
diff changeset
690 _page = self.__page_list[_page_num]
0359329a1c26 Navigation buttons. Version of the data structure.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 6
diff changeset
691 if isinstance(_page, Page):
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
692 # not loading budget
7
0359329a1c26 Navigation buttons. Version of the data structure.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 6
diff changeset
693 _active_path = _page.activePathRecord
0359329a1c26 Navigation buttons. Version of the data structure.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 6
diff changeset
694 if len(_active_path) > 1:
11
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
695 _budget = _page.budget
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
696 _up_path = _active_path[:-1]
7
0359329a1c26 Navigation buttons. Version of the data structure.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 6
diff changeset
697 if _budget.hasPath(_up_path):
0359329a1c26 Navigation buttons. Version of the data structure.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 6
diff changeset
698 _page.propagateMessageFrom("change_active", (-1,),
0359329a1c26 Navigation buttons. Version of the data structure.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 6
diff changeset
699 _up_path)
0359329a1c26 Navigation buttons. Version of the data structure.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 6
diff changeset
700
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
701 def _menuitemGoPrevious(self, action, parameter):
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
702 """_menuitemGoPrevious(action, parameter)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
703
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
704 action: the action where the event is emitted from
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
705 parameter: None
7
0359329a1c26 Navigation buttons. Version of the data structure.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 6
diff changeset
706
0359329a1c26 Navigation buttons. Version of the data structure.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 6
diff changeset
707 Callback to go to previous record.
0359329a1c26 Navigation buttons. Version of the data structure.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 6
diff changeset
708 """
0359329a1c26 Navigation buttons. Version of the data structure.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 6
diff changeset
709 _page_num = self.__notebook.get_current_page()
0359329a1c26 Navigation buttons. Version of the data structure.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 6
diff changeset
710 if _page_num != -1:
0359329a1c26 Navigation buttons. Version of the data structure.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 6
diff changeset
711 _page = self.__page_list[_page_num]
0359329a1c26 Navigation buttons. Version of the data structure.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 6
diff changeset
712 if isinstance(_page, Page):
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
713 # not loading budget
7
0359329a1c26 Navigation buttons. Version of the data structure.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 6
diff changeset
714 _previous_path = _page.previousPathRecord
0359329a1c26 Navigation buttons. Version of the data structure.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 6
diff changeset
715 if _previous_path is not None:
11
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
716 _budget = _page.budget
7
0359329a1c26 Navigation buttons. Version of the data structure.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 6
diff changeset
717 if _budget.hasPath(_previous_path):
0359329a1c26 Navigation buttons. Version of the data structure.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 6
diff changeset
718 _page.propagateMessageFrom("change_active", (-1,),
0359329a1c26 Navigation buttons. Version of the data structure.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 6
diff changeset
719 _previous_path)
0359329a1c26 Navigation buttons. Version of the data structure.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 6
diff changeset
720
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
721 def _menuitemGoPosterior(self, action, parameter):
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
722 """_menuitemPosterior(action, parameter)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
723
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
724 action: the action where the event is emitted from
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
725 parameter: None
7
0359329a1c26 Navigation buttons. Version of the data structure.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 6
diff changeset
726
0359329a1c26 Navigation buttons. Version of the data structure.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 6
diff changeset
727 Callback to go to posterior record.
0359329a1c26 Navigation buttons. Version of the data structure.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 6
diff changeset
728 """
0359329a1c26 Navigation buttons. Version of the data structure.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 6
diff changeset
729 _page_num = self.__notebook.get_current_page()
0359329a1c26 Navigation buttons. Version of the data structure.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 6
diff changeset
730 if _page_num != -1:
0359329a1c26 Navigation buttons. Version of the data structure.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 6
diff changeset
731 _page = self.__page_list[_page_num]
0359329a1c26 Navigation buttons. Version of the data structure.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 6
diff changeset
732 if isinstance(_page, Page):
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
733 # not loading budget
7
0359329a1c26 Navigation buttons. Version of the data structure.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 6
diff changeset
734 _posterior_path = _page.posteriorPathRecord
0359329a1c26 Navigation buttons. Version of the data structure.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 6
diff changeset
735 if _posterior_path is not None:
11
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
736 _budget = _page.budget
7
0359329a1c26 Navigation buttons. Version of the data structure.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 6
diff changeset
737 if _budget.hasPath(_posterior_path):
0359329a1c26 Navigation buttons. Version of the data structure.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 6
diff changeset
738 _page.propagateMessageFrom("change_active", (-1,),
0359329a1c26 Navigation buttons. Version of the data structure.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 6
diff changeset
739 _posterior_path)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
740
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
741 def _delete_event(self, widget, event):
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
742 """_delete_event(widget, event)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
743
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
744 widget: the widget where the event is emitted from
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
745 event: the "Gdk.Event"
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
746
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
747 Method connected to "delete_event" signal of main window widget
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
748 This signal is emitted when a user press the close titlebar button.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
749 It Returns True so the signal "destroy" is emitted.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
750 """
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
751 for _page in self.__page_list:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
752 _page.clear()
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
753 return False # -> destroy
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
754
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
755
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
756 class FileSelectionWindow(object):
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
757 """gui.FileSelectionWindow:
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
758
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
759 Description:
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
760 Class to show the selection file window
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
761 Constructor:
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
762 FileSelectionWindow(mainWindow, readFileMethod, budget,
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
763 filename, cancelMethod, filetype)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
764 Ancestry:
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
765 +-- object
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
766 +-- FileSelectionWindow
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
767 Atributes:
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
768 No public Atributes
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
769 Methods:
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
770 No public Methods
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
771 """
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
772
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
773 def __init__(self, mainWindow, readFileMethod, budget, filename,
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
774 cancelMethod, filetype):
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
775 """__init__(mainWindow, readFileMethod, budget,
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
776 filename, cancelMethod, filetype)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
777
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
778 mainWindow: MainWindow object
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
779 readFileMethod: Method to read the selected file
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
780 budget: base.Budget object
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
781 filename: "file"
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
782 cancelMethod: Method to cancel the read method
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
783 fileytpe: "budget" or "database".
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
784 Sets the init atributes, creates the file selection window
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
785 Connects the events:
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
786 * clicked ok button: _openFile
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
787 * clicked cancel button: destroy window
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
788 * destroy event: _destroy
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
789 """
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
790 # TODO: Add file filter
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
791 self.__mainWindow = mainWindow
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
792 self.__readFileMethod = readFileMethod
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
793 self.__budget = budget
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
794 self.__filetype = filetype
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
795 self.__cancelMethod = cancelMethod
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
796 self.__file = None
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
797 self.__filename = filename
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
798 if self.__filename == "":
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
799 self.__dialog = Gtk.FileChooserNative.new(_("Open File"),
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
800 mainWindow.window, Gtk.FileChooserAction.OPEN, _("Open File"),
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
801 _("Cancel") )
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
802 self.__dialog.set_current_folder(globalVars.getHomePath("BUDGET"))
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
803 _response = self.__dialog.run()
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
804 if _response in [ Gtk.ResponseType.OK, Gtk.ResponseType.ACCEPT,
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
805 Gtk.ResponseType.YES, Gtk.ResponseType.APPLY]:
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
806 self._openFile(self.__dialog.get_filename())
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
807 elif _response == Gtk.ResponseType.CANCEL:
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
808 self.__dialog.destroy()
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
809 else:
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
810 self.__dialog = None
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
811 self._openFile(self.__filename)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
812
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
813 def _launchProgressWindow(self, file):
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
814 """_launchProgressWindow(file)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
815
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
816 Launch the progress window
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
817 """
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
818 self.__filename = file
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
819 _emptyPage = EmptyPage(self.__mainWindow, self.__readFileMethod,
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
820 self.__budget, self.__filename,
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
821 self.__cancelMethod, self.__filetype)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
822 self.__mainWindow.appendEmptyPage(_emptyPage)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
823 _emptyPage.run()
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
824
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
825 def _openFile(self, filename):
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
826 """_openFile(filename)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
827
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
828 filename: the filename to open
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
829 If the selected file has a bc3 extension
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
830 _launchProgressWindow is called
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
831 """
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
832 _file = filename
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
833 if sys.getfilesystemencoding():
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
834 _file = _file.decode(sys.getfilesystemencoding())
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
835 self.__file = _file
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
836 _filename = os.path.basename(self.__file)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
837 _filename_ext = _filename.split(".")[-1]
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
838 if (self.__filetype == "budget" or self.__filetype == "database") and \
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
839 _filename_ext != "bc3" and _filename_ext != "BC3":
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
840 print(_("The file must have 'bc3' extension") )
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
841 else:
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
842 if self.__dialog is not None:
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
843 self.__dialog.destroy()
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
844 # TODO: the file exits? is it not binary?, can it be readed?
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
845 self._launchProgressWindow(self.__file)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
846
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
847
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
848 class EmptyPage(object):
7
0359329a1c26 Navigation buttons. Version of the data structure.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 6
diff changeset
849 """gui.EmptyPage:
0359329a1c26 Navigation buttons. Version of the data structure.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 6
diff changeset
850
0359329a1c26 Navigation buttons. Version of the data structure.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 6
diff changeset
851 Description:
0359329a1c26 Navigation buttons. Version of the data structure.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 6
diff changeset
852 It creates and shows a page in the notebook while a budget is loaded.
0359329a1c26 Navigation buttons. Version of the data structure.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 6
diff changeset
853 The page show the pyarq logo, loading time and a progress bar.
0359329a1c26 Navigation buttons. Version of the data structure.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 6
diff changeset
854 Constructor:
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
855 EmptyPage(mainWindow, readFileMethod, budget, filename,
7
0359329a1c26 Navigation buttons. Version of the data structure.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 6
diff changeset
856 cancelMethod, filetype):
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
857 mainWindow: Mainwindow object
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
858 readFileMethod: Method to read the selected file
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
859 budget: base.Budget object
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
860 filename: "file"
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
861 cancelMethod: Method to cancel the read method
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
862 filetype: "budget", "database"
7
0359329a1c26 Navigation buttons. Version of the data structure.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 6
diff changeset
863 Ancestry:
0359329a1c26 Navigation buttons. Version of the data structure.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 6
diff changeset
864 +-- object
0359329a1c26 Navigation buttons. Version of the data structure.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 6
diff changeset
865 +-- EmptyPage
0359329a1c26 Navigation buttons. Version of the data structure.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 6
diff changeset
866 Atributes:
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
867 widget: Read. Main widget showed in the pane
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
868 title: Read. Page Title
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
869 filetype: Read. budget or basedata
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
870 endSuccessfully: Read-Write. False/True
7
0359329a1c26 Navigation buttons. Version of the data structure.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 6
diff changeset
871 Methods:
0359329a1c26 Navigation buttons. Version of the data structure.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 6
diff changeset
872 run
21
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 16
diff changeset
873 readFile_progress
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 16
diff changeset
874 readFile_send_message
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 16
diff changeset
875 readFile_set_statistics
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 16
diff changeset
876 readFile_end
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 16
diff changeset
877 readFile_cancel
7
0359329a1c26 Navigation buttons. Version of the data structure.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 6
diff changeset
878 stopLoading
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
879 updateGui
7
0359329a1c26 Navigation buttons. Version of the data structure.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 6
diff changeset
880 threadFinishedSignal
0359329a1c26 Navigation buttons. Version of the data structure.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 6
diff changeset
881 threadCanceled
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
882 on_close_button
7
0359329a1c26 Navigation buttons. Version of the data structure.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 6
diff changeset
883 close
0359329a1c26 Navigation buttons. Version of the data structure.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 6
diff changeset
884 clear
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
885 """
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
886
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
887 def __init__(self, mainWindow, readFileMethod, budget, filename,
4
4e976a99efb9 update ImportPriceDatabase
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 3
diff changeset
888 cancelMethod, filetype):
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
889 """__init__(mainWindow, readFileMethod, budget, filename,
4
4e976a99efb9 update ImportPriceDatabase
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 3
diff changeset
890 cancelMethod, filetype)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
891
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
892 mainWindow: Mainwindow object
7
0359329a1c26 Navigation buttons. Version of the data structure.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 6
diff changeset
893 readFileMethod: Method to read the selected file
0359329a1c26 Navigation buttons. Version of the data structure.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 6
diff changeset
894 budget: base.Budget object
0359329a1c26 Navigation buttons. Version of the data structure.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 6
diff changeset
895 filename: "file"
0359329a1c26 Navigation buttons. Version of the data structure.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 6
diff changeset
896 cancelMethod: Method to cancel the read method
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
897 filetype: "budget" or "database"
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
898
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
899 self.__mainWindow: Mainwindow object
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
900 self.endSuccessfully False/True
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
901 self.__readFileMethod: Method to read the selected file
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
902 self.__budget: base.Budget object
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
903 self.__filename: "file"
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
904 self.__cancelMethod: Method to cancel the read method
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
905 self.__filetype: "budget" or "database"
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
906 self.__children: the read thread
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
907 self.__progress: 0 to 1 progress
21
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 16
diff changeset
908 self.__statistics: record statistics
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
909 self.__widget: main widget, a vertial Gtk.Grid object
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
910 self.__main_item: None
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
911 self.__throbber: Gtk.Spinner()
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
912 self.__budget_icon: Gtk.Image()
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
913 self.__title: a horizontal Gtk.Grid
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
914 self.__statusbar: a Gtk.Statusbar
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
915 self.__statuscontext: the statusbar context
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
916 self.__progress_bar: a Gtk.ProgressBar
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
917 """
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
918 self.__mainWindow = mainWindow
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
919 self.endSuccessfully = False
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
920 self.__readFileMethod = readFileMethod
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
921 self.__budget = budget
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
922 self.__filename = filename
4
4e976a99efb9 update ImportPriceDatabase
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 3
diff changeset
923 self.__filetype = filetype
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
924 self.__cancelMethod = cancelMethod
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
925 self.__children = None
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
926 self.__cancel = [False, False]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
927 self.__progress = 0.0
21
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 16
diff changeset
928 self.__statistics = None
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
929 self.__widget = Gtk.Grid()
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
930 self.__widget.set_orientation(Gtk.Orientation(1)) # 1 Vertical
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
931 self.__main_item = None
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
932 self.__widget.show()
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
933 # Throbber
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
934 self.__throbber = Gtk.Spinner()
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
935 self.__throbber.show()
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
936 self.__budget_icon = Gtk.Image()
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
937 _budget_pixbuf = GdkPixbuf.Pixbuf.new_from_file(
11
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
938 globalVars.getAppPath("BUDGET-ICON"))
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
939 self.__budget_icon.set_from_pixbuf(_budget_pixbuf)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
940 _filename = os.path.basename(filename)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
941 _rootfilename = os.path.splitext(_filename)[0]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
942 if not _rootfilename == "":
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
943 _filename = _rootfilename
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
944 if len(_filename) > 28:
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
945 _titleLabel = Gtk.Label(_filename[:25] + "...")
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
946 _titleLabel.set_tooltip_text(_filename)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
947 else:
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
948 _titleLabel = Gtk.Label(_filename)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
949 _titleLabel.show()
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
950 self.__title = Gtk.Grid()
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
951 self.__title.set_column_spacing(4)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
952 self.__title.set_orientation(Gtk.Orientation(0)) # 0 Horizontal
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
953 self.__title.add(self.__budget_icon)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
954 self.__title.add(self.__throbber)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
955 self.__title.add(_titleLabel)
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
956 # Close tab
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
957 _gtk_image = Gtk.Image()
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
958 _gtk__pixbuf = Gtk.IconTheme.get_default().load_icon(
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
959 "window-close-symbolic", 16, 0)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
960 _gtk_image.set_from_pixbuf(_gtk__pixbuf)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
961 _gtk_image.show()
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
962 self.closeTabButton = Gtk.ToolButton.new(_gtk_image , _("_Close tab"))
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
963 self.closeTabButton.set_tooltip_text(_("Close tab"))
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
964 self.closeTabButton.set_is_important(False) # label not shown
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
965 self.__title.add(self.closeTabButton)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
966 self.closeTabButton.hide()
25
189f8274aecd gui. switch navigation menu on switch page
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 23
diff changeset
967 self.__closeTabId = self.closeTabButton.connect("clicked",
189f8274aecd gui. switch navigation menu on switch page
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 23
diff changeset
968 self.on_close_button)
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
969 # Statusbar
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
970 self.__statusbar = Gtk.Statusbar()
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
971 self.__statuscontext = self.__statusbar.get_context_id("Statusbar")
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
972 self.__statusbar.show()
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
973 _iconVbox = Gtk.Grid()
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
974 _iconVbox.set_orientation(Gtk.Orientation(1)) # 1 Vertical
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
975 _iconVbox.props.halign = Gtk.Align(3) # 3 Center
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
976 _iconVbox.props.valign = Gtk.Align(3) # 3 Center
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
977 _iconVbox.set_property("expand", True) # widget expand all space
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
978 _pyArqIcon = Gtk.Image()
6
2fc6b47dbe70 rename module globals to globalVars
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 5
diff changeset
979 _pyArqIcon.set_from_file(globalVars.getAppPath("PYARQ-ICON"))
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
980 _pyArqIcon.show()
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
981 _iconVbox.add(_pyArqIcon)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
982 _link = Gtk.LinkButton.new("http://pyarq.obraencurso.es")
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
983 _iconVbox.add(_link)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
984 _link.show()
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
985 _iconVbox.show()
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
986 self.__widget.add(_iconVbox)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
987 self.__progress_bar = Gtk.ProgressBar()
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
988 self.__progress_bar.set_show_text(True)
21
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 16
diff changeset
989 self.__progress_bar.show()
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
990 self.__statusbar.pack_start(self.__progress_bar, False, False, 0)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
991 self.__widget.add(self.__statusbar)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
992 self.__main_item = None
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
993
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
994 def run(self):
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
995 """run()
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
996
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
997 Launch clildren and timeouts
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
998 """
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
999 self.__statusbar.push(self.__statuscontext, _("Time: 0s"))
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1000 self.__throbber.start()
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1001 self._launchChildren()
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1002 self._launchTimeout()
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1003
21
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 16
diff changeset
1004 def readFile_progress(self, percent):
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 16
diff changeset
1005 """readFile_progress(percent)
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1006
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1007 percent: Percentage executed.
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1008
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1009 Sets progress
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1010 """
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1011 _progress = str(int(round(100 * percent,0)))
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1012 self.__progress = percent
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1013
21
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 16
diff changeset
1014 def readFile_send_message(self, message):
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 16
diff changeset
1015 """readFile_send_message(message)
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 16
diff changeset
1016
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 16
diff changeset
1017 message: mesage from readFile method
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 16
diff changeset
1018
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1019 print( message )
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1020 """
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1021 print( message )
21
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 16
diff changeset
1022
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 16
diff changeset
1023 def readFile_set_statistics(self, statistics):
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 16
diff changeset
1024 """readFile_set_statistics(statistics)
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 16
diff changeset
1025
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 16
diff changeset
1026 statistics: record statistics from readFile method
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 16
diff changeset
1027
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 16
diff changeset
1028 sets record statistics
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 16
diff changeset
1029 """
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 16
diff changeset
1030 self.__statistics = statistics
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 16
diff changeset
1031
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 16
diff changeset
1032 def readFile_end(self):
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 16
diff changeset
1033 """readFile_end()
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 16
diff changeset
1034
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 16
diff changeset
1035 The readFile method end successfully
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 16
diff changeset
1036 """
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1037 self.endSuccessfully = True
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1038 print( self.__statistics.str() )
21
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 16
diff changeset
1039
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 16
diff changeset
1040 def readFile_cancel(self):
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 16
diff changeset
1041 """readFile_cancel()
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 16
diff changeset
1042
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 16
diff changeset
1043 The readFile method is canceled
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 16
diff changeset
1044 """
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1045 self.endSuccessfully = False
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1046 print(_("Process terminated") )
21
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 16
diff changeset
1047
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1048 def stopLoading(self):
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1049 """stopLoading()
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1050
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1051 Stop progressbar
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1052 """
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1053 self.__throbber.destroy()
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1054 self.__budget_icon.show()
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1055 self.__progress_bar.hide()
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1056 self.__statusbar.pop(self.__statuscontext)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1057
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1058 def _launchChildren(self):
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1059 """_launchChildren()
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1060
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1061 Launch the thread to read the file
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1062 """
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1063 if self.__children is None:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1064 self.__children = importFiebdc.Thread(self, self.__mainWindow,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1065 self.__readFileMethod, self.__budget, self.__filename,
4
4e976a99efb9 update ImportPriceDatabase
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 3
diff changeset
1066 self.__cancelMethod, self.__filetype)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1067 self.__children.start()
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1068
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1069 def _launchTimeout(self):
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1070 """_launchTimeout()
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1071
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1072 Launch the timeouts:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1073 1- update progress bar
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1074 2- update time label
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1075 3- If the other timetouts are stoped the window is closed
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1076 """
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1077 GLib.timeout_add(1000, self._updateLabel, time.time())
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1078 GLib.timeout_add(500, self._updateProgressBar)
21
f7e0cc58737f Default interface in readFile method
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 16
diff changeset
1079 self.__cancel = [False, False]
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1080 GLib.timeout_add(1000, self._autoClose)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1081
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1082 def updateGui(self):
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1083 while Gtk.events_pending():
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1084 Gtk.main_iteration()
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1085
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1086 def _updateProgressBar(self):
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1087 """_updateProgressBar()
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1088
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1089 update progress bar in a timeout
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1090 If the thread end or is canceled the timeout is stoped
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1091 """
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1092 if self.__children is None or self.__children.isCanceled() == True:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1093 self.__cancel[0] = True
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1094 return False
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1095 else:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1096 self.__progress_bar.set_fraction(self.__progress)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1097 _text = "%s%%" %str(int(round(100 * self.__progress,0)))
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1098 self.__progress_bar.set_text(_text)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1099 return True
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1100
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1101 def _updateLabel(self, _time):
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1102 """_updateLabel(_time)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1103
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1104 update time label in a timeout
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1105 If the thread end or is canceled the timeout is stoped
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1106 """
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1107 if self.__children is None or self.__children.isCanceled() == True:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1108 self.__cancel[1] = True
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1109 return False
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1110 else:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1111 _time = time.time() - _time
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1112 _text = utils.mapping(_("Time: $1"), ("%.0f" %_time,))
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1113 self.__statusbar.pop(self.__statuscontext)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1114 self.__statusbar.push(self.__statuscontext, _text)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1115 return True
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1116
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1117 def _autoClose(self):
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1118 """_autoClose()
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1119
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1120 If the time label and progress bar timeouts are stoped the window is
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1121 closed and ist tiemeout is stoped
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1122 """
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1123 #_autoClose timeout do nothig
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1124 if self.__cancel == [ True, True ]:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1125 return False
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1126 else:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1127 return True
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1128
5
6502bfdaa84d update import durus database
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 4
diff changeset
1129 def threadFinishedSignal(self, budget):
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1130 """threadFinishedSignal(budget)
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1131
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1132 Sets the self.__children to None
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1133 This causes that the timeouts is ended.
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1134 This method is called from thread when it finish
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1135 """
5
6502bfdaa84d update import durus database
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 4
diff changeset
1136 self.__budget = budget
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1137 self.__children = None
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1138 self.stopLoading()
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1139 _page = Page(self.__mainWindow, self.__budget, self.closeTabButton)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1140 _children = self.__widget.get_children()
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1141 for _child in _children:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1142 self.__widget.remove(_child)
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1143 self.__widget.add(_page.widget)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1144 self.closeTabButton.disconnect(self.__closeTabId)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1145 self.closeTabButton.connect("clicked", _page.on_close_button)
11
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
1146 self.__mainWindow.updatePage(self, _page)
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1147
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1148 def threadCanceled(self):
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1149 """threadCanceled()
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1150
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1151 Sets the __children atribute to None
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1152 This causes that the timeouts is ended.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1153 This method is called from thread when is canceled
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1154 """
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1155 self.__children = None
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1156 self.stopLoading()
11
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
1157 self.__mainWindow.closePage(self)
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1158
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1159 def on_close_button(self, widget):
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1160 """on_close_button()
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1161
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1162 Call close
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1163 """
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1164 self.close()
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1165
7
0359329a1c26 Navigation buttons. Version of the data structure.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 6
diff changeset
1166 def close(self):
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1167 """close()
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1168
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1169 Close page canceling children
7
0359329a1c26 Navigation buttons. Version of the data structure.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 6
diff changeset
1170 """
0359329a1c26 Navigation buttons. Version of the data structure.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 6
diff changeset
1171 self.__children.cancel()
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1172
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1173 def clear(self):
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1174 """clear()
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1175
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1176 Nothig to do now
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1177 """
7
0359329a1c26 Navigation buttons. Version of the data structure.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 6
diff changeset
1178 pass
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1179
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1180 def _getWidget(self):
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1181 """_getWidget()
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1182
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1183 Return de main widget to show in the page
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1184 """
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1185 return self.__widget
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1186
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1187 def _getTitle(self):
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1188 """_getTitle()
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1189
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1190 Return the title of the page, a Gtk.Label objetc
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1191 """
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1192 return self.__title
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1193
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1194 def _getFiletype(self):
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1195 """_getFiletipe()
5
6502bfdaa84d update import durus database
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 4
diff changeset
1196
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1197 Return the title of the page, a Gtk.Label objetc
5
6502bfdaa84d update import durus database
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 4
diff changeset
1198 """
6502bfdaa84d update import durus database
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 4
diff changeset
1199 return self.__filetype
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1200
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1201 widget = property(_getWidget, None, None,
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1202 "Main widget showed in the pane")
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1203 title = property(_getTitle, None, None,
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1204 "Page Title")
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1205 filetype = property(_getFiletype, None, None,
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1206 "Filetype: budget or basedata")
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1207
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1208
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1209 class Page(object):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1210 """gui.Page:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1211
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1212 Description:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1213 It creates and shows a page in the notebook from a budget object.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1214 The page can show the budget information in several panes ordered
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1215 according to "panes_list" information.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1216 Constructor:
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1217 Page(mainWindow, budget, closeTabButton, active_code=None)
7
0359329a1c26 Navigation buttons. Version of the data structure.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 6
diff changeset
1218 mainwindow: MainWindow object
0359329a1c26 Navigation buttons. Version of the data structure.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 6
diff changeset
1219 budget: base.Budget object
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1220 closeTabButton. button winget to close tab
7
0359329a1c26 Navigation buttons. Version of the data structure.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 6
diff changeset
1221 active_code: Active record code
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1222 Ancestry:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1223 +-- object
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1224 +-- Page
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1225 Atributes:
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1226 widget: Read. Notebook page Widget. (a vertical Gtk.Grid instance)
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1227 budget: Read-Write. Budget to show in the page. (base.obra object)
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1228 panes_list: Read. info list for create the panes
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1229 ej: [ "v", pane1, pane2 ] , [ "h", pane1, pane2 ]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1230 [ "v", [ "h", pane1, pane2 ], [ "h", pane1, pane2 ] ]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1231 pane types:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1232 * "DecompositionList": its creates a "DecompositionList" object
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1233 * "RecordDescription" : its creates a "Description" objetc
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1234 * "Measure": its creates a "Measure" objetc
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1235 * "FileView": its creates a "FileView" objet
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1236 * "CompanyView": its creates a "CompanyView" object
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1237 title: Read. Notebook page title (Gtk.Label object)
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1238 activePathRecord: Read. The active path record
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1239 previousPathRecord: Read. The previous path record
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1240 posteriorPathRecord Read. The posterior path record
11
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
1241 back_menu: back menu to show in menutoolbutton
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
1242 forward_menu: forward menu to show in menutoolbutton
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1243 Methods:
7
0359329a1c26 Navigation buttons. Version of the data structure.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 6
diff changeset
1244 propagateMessageFrom
0359329a1c26 Navigation buttons. Version of the data structure.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 6
diff changeset
1245 sendMessageTo
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1246 on_close_button
7
0359329a1c26 Navigation buttons. Version of the data structure.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 6
diff changeset
1247 close
0359329a1c26 Navigation buttons. Version of the data structure.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 6
diff changeset
1248 clear
0359329a1c26 Navigation buttons. Version of the data structure.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 6
diff changeset
1249 getItem
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1250 """
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1251 # TODO: * The panes can be ordered as the user wishes
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1252 # TODO: * Panes in windows
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1253 # TODO: * pane types
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1254 # TODO: * General budget properties (is better a dialog?)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1255
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1256 def __init__(self, mainWindow, budget, closeTabButton, path_record=None):
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1257 """__init__(mainWindow, budget, closeTabButton, path_record=None)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1258
7
0359329a1c26 Navigation buttons. Version of the data structure.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 6
diff changeset
1259 mainWindow: MainWindow object
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1260 budget: "base.Budget" object
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1261 closeTabButton: Button widget to close tab
7
0359329a1c26 Navigation buttons. Version of the data structure.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 6
diff changeset
1262 path_record: the active path record
11
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
1263
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
1264 self.__mainWindow: MainWindow object
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1265 self.__widget: a Gtk.Grid
11
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
1266 self.__panes_list:
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1267 self.__main_item: Main item in Page. (Paned object or View object)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1268 self.closeTabButton: : Button widget to close tab
11
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
1269 self.__active_path_record:
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
1270 self.__history_back:
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
1271 self.__history_forward:
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1272 self.__back_menu: a Gtk.Menu
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1273 self.__forward_menu: a Gtk.Menu
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1274 """
22
7bd4ca56607d bug fix: Mutable default arguments
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
1275 if path_record is None:
7bd4ca56607d bug fix: Mutable default arguments
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
1276 path_record = (0,)
7
0359329a1c26 Navigation buttons. Version of the data structure.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 6
diff changeset
1277 self.__mainWindow = mainWindow
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1278 self.closeTabButton = closeTabButton
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1279 self.__widget = Gtk.Grid()
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1280 self.__widget.set_orientation(Gtk.Orientation(1)) # 1 Vertical
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1281 self.__widget.props.margin = 5
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1282 #TODO: __panes_list should come from gui config file...
25
189f8274aecd gui. switch navigation menu on switch page
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 23
diff changeset
1283 # "DecompositionList" "RecordDescription" "Measure"
189f8274aecd gui. switch navigation menu on switch page
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 23
diff changeset
1284 # "Sheet of Conditions" "FileView" "CompanyView"
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1285 self.__panes_list = [ "v", "DecompositionList", [ "v", "Measure",
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1286 "RecordDescription" ]]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1287 self.__main_item = None
7
0359329a1c26 Navigation buttons. Version of the data structure.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 6
diff changeset
1288 self.__active_path_record = ()
0359329a1c26 Navigation buttons. Version of the data structure.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 6
diff changeset
1289 self.__history_back = []
0359329a1c26 Navigation buttons. Version of the data structure.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 6
diff changeset
1290 self.__history_forward = []
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1291 self.__back_menu = Gtk.Menu()
11
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
1292 self.__back_menu.show()
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1293 self.__forward_menu = Gtk.Menu()
11
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
1294 self.__forward_menu.show()
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1295 self.budget = budget # Create all items and widgets
7
0359329a1c26 Navigation buttons. Version of the data structure.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 6
diff changeset
1296 self._setActivePathRecord(path_record)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1297 self.__widget.show()
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1298 self.__budget_icon = GdkPixbuf.Pixbuf.new_from_file(
11
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
1299 globalVars.getAppPath("BUDGET-ICON"))
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1300 self.__chapter_icon = GdkPixbuf.Pixbuf.new_from_file(
11
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
1301 globalVars.getAppPath("CHAPTER-ICON"))
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1302 self.__unit_icon = GdkPixbuf.Pixbuf.new_from_file(
11
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
1303 globalVars.getAppPath("UNIT-ICON") )
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1304 self.__material_icon = GdkPixbuf.Pixbuf.new_from_file(
11
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
1305 globalVars.getAppPath("MATERIAL-ICON") )
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1306 self.__machinery_icon = GdkPixbuf.Pixbuf.new_from_file(
11
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
1307 globalVars.getAppPath("MACHINERY-ICON"))
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1308 self.__labourforce_icon = GdkPixbuf.Pixbuf.new_from_file(
11
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
1309 globalVars.getAppPath("LABOURFORCE-ICON"))
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1310
7
0359329a1c26 Navigation buttons. Version of the data structure.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 6
diff changeset
1311 def propagateMessageFrom(self, message, pane_path, arg=None):
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1312 """propagateMessageFrom(message, pane_path, arg=None)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1313
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1314 message: string message
7
0359329a1c26 Navigation buttons. Version of the data structure.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 6
diff changeset
1315 * "change_active": change active code
0359329a1c26 Navigation buttons. Version of the data structure.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 6
diff changeset
1316 * "autoclose"
0359329a1c26 Navigation buttons. Version of the data structure.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 6
diff changeset
1317 * "split h"
0359329a1c26 Navigation buttons. Version of the data structure.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 6
diff changeset
1318 * "split v"
0359329a1c26 Navigation buttons. Version of the data structure.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 6
diff changeset
1319 pane_path: tuple that represents the pane path which emits the message
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1320 arg: arguments for the message
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1321 if message is "change_active" arg is the path record
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1322
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1323 The panes are connectted to this method to send messages to other panes
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1324 """
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1325 _budget = self.__budget
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1326 if message == "change_active" and _budget.hasPath(arg):
7
0359329a1c26 Navigation buttons. Version of the data structure.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 6
diff changeset
1327 self.sendMessageTo(self.__main_item, message, pane_path, arg)
0359329a1c26 Navigation buttons. Version of the data structure.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 6
diff changeset
1328 self._setActivePathRecord(arg)
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1329 self.__mainWindow.changeActiveSignal() # Check sensitive buttons
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1330 elif message == "autoclose":
7
0359329a1c26 Navigation buttons. Version of the data structure.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 6
diff changeset
1331 self._closeItem(pane_path)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1332 elif message == "split h":
7
0359329a1c26 Navigation buttons. Version of the data structure.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 6
diff changeset
1333 self._splitItem(pane_path, "h")
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1334 elif message == "split v":
7
0359329a1c26 Navigation buttons. Version of the data structure.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 6
diff changeset
1335 self._splitItem(pane_path, "v")
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1336
7
0359329a1c26 Navigation buttons. Version of the data structure.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 6
diff changeset
1337 def sendMessageTo(self, pane, message, pane_path, arg=None):
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1338 """sendMessageTo(pane, message, pane_path, arg=None)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1339 pane: the receiver pane
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1340 message: string message
25
189f8274aecd gui. switch navigation menu on switch page
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 23
diff changeset
1341 pane_path: tuple that represents the pane pane_path which emits
189f8274aecd gui. switch navigation menu on switch page
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 23
diff changeset
1342 the message
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1343 arg: arguments for the message
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1344
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1345 Sends a message to a pane
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1346 """
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1347 pane.runMessage(message, pane_path, arg)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1348
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1349 def on_close_button(self, widget):
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1350 self.close()
7
0359329a1c26 Navigation buttons. Version of the data structure.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 6
diff changeset
1351
0359329a1c26 Navigation buttons. Version of the data structure.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 6
diff changeset
1352 def close(self):
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1353 """close()
7
0359329a1c26 Navigation buttons. Version of the data structure.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 6
diff changeset
1354
0359329a1c26 Navigation buttons. Version of the data structure.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 6
diff changeset
1355 Close Page
0359329a1c26 Navigation buttons. Version of the data structure.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 6
diff changeset
1356 """
11
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
1357 self.__mainWindow.closePage(self)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1358
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1359 def clear(self):
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1360 """clear()
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1361
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1362 Clear atributes
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1363 """
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1364 self.propagateMessageFrom("clear", (0,))
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1365 del self.__budget
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1366 del self.__panes_list
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1367 del self.__widget
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1368 del self.__title
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1369 del self.__active_path_record
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1370 del self.__main_item
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1371
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1372 def getItem(self, pane_path):
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1373 """getItem(pane_path)
7
0359329a1c26 Navigation buttons. Version of the data structure.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 6
diff changeset
1374
0359329a1c26 Navigation buttons. Version of the data structure.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 6
diff changeset
1375 Return the item whith the path "pane_path", it can return a Paned
0359329a1c26 Navigation buttons. Version of the data structure.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 6
diff changeset
1376 instance or a View instance
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1377 """
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1378 _item = self.__main_item
7
0359329a1c26 Navigation buttons. Version of the data structure.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 6
diff changeset
1379 if len(pane_path) == 1:
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1380 return _item
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1381 else:
7
0359329a1c26 Navigation buttons. Version of the data structure.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 6
diff changeset
1382 return _item.getItem(pane_path[1:])
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1383
7
0359329a1c26 Navigation buttons. Version of the data structure.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 6
diff changeset
1384 def _setMainItem(self, item):
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1385 """_setMainItem(item)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1386
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1387 Sets a new main item in the page
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1388 """
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1389 if not self.__main_item is None:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1390 _old_main_widget = self.__main_item.widget
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1391 self.__widget.remove(_old_main_widget)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1392 self.__main_item = item
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1393 _main_widget = self.__main_item.widget
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1394 _main_widget.show()
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1395 self.__widget.add(_main_widget)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1396
7
0359329a1c26 Navigation buttons. Version of the data structure.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 6
diff changeset
1397 def _splitItem(self, pane_path, orientation):
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1398 """_splitItem(pane_path, orientation)
7
0359329a1c26 Navigation buttons. Version of the data structure.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 6
diff changeset
1399
0359329a1c26 Navigation buttons. Version of the data structure.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 6
diff changeset
1400 Splits the item that is identifies by the pane_path and the orientation
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1401 """
7
0359329a1c26 Navigation buttons. Version of the data structure.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 6
diff changeset
1402 _item = self.getItem(pane_path)
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1403 _item.pane_path = pane_path + (0,)
7
0359329a1c26 Navigation buttons. Version of the data structure.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 6
diff changeset
1404 _item_clone0 = _item.getClone(pane_path + (0,))
0359329a1c26 Navigation buttons. Version of the data structure.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 6
diff changeset
1405 _item_clone1 = _item.getClone(pane_path + (1,))
0359329a1c26 Navigation buttons. Version of the data structure.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 6
diff changeset
1406 _paned = Paned(orientation, pane_path, _item_clone0, _item_clone1)
0359329a1c26 Navigation buttons. Version of the data structure.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 6
diff changeset
1407 if len(pane_path) > 1:
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1408 _parent = self.getItem(pane_path[:-1])
7
0359329a1c26 Navigation buttons. Version of the data structure.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 6
diff changeset
1409 _parent.setItem(pane_path[-1], [_paned])
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1410 else:
7
0359329a1c26 Navigation buttons. Version of the data structure.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 6
diff changeset
1411 self._setMainItem(_paned)
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1412
7
0359329a1c26 Navigation buttons. Version of the data structure.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 6
diff changeset
1413 def _closeItem(self, pane_path):
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1414 """_closeItem(pane_path)
7
0359329a1c26 Navigation buttons. Version of the data structure.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 6
diff changeset
1415
0359329a1c26 Navigation buttons. Version of the data structure.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 6
diff changeset
1416 Closes the item that is identifies by the pane_path
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1417 """
7
0359329a1c26 Navigation buttons. Version of the data structure.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 6
diff changeset
1418 _item = self.getItem(pane_path)
0359329a1c26 Navigation buttons. Version of the data structure.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 6
diff changeset
1419 if len(pane_path) > 1:
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1420 # There are more than one item
7
0359329a1c26 Navigation buttons. Version of the data structure.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 6
diff changeset
1421 _parent = self.getItem(pane_path[:-1])
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1422 _brothers = [ _brother for _brother in _parent]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1423 _brothers.remove(_item)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1424 _brother = _brothers[0]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1425
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1426 _parent.widget.remove(_brother.widget)
7
0359329a1c26 Navigation buttons. Version of the data structure.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 6
diff changeset
1427 _brother.pane_path = pane_path[:-1]
0359329a1c26 Navigation buttons. Version of the data structure.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 6
diff changeset
1428 if len(pane_path) > 2:
0359329a1c26 Navigation buttons. Version of the data structure.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 6
diff changeset
1429 _grandparent = self.getItem(pane_path[:-2])
0359329a1c26 Navigation buttons. Version of the data structure.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 6
diff changeset
1430 _grandparent.setItem(pane_path[-2], [_brother])
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1431 _parent.widget.destroy()
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1432 _parent.clear()
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1433 _item.clear()
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1434 else:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1435 _grandparent = self
7
0359329a1c26 Navigation buttons. Version of the data structure.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 6
diff changeset
1436 _grandparent._setMainItem(_brother)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1437 _parent.widget.destroy()
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1438 _parent.clear()
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1439 _item.clear()
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1440 else:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1441 # Thre is only one item in the page, it can not be closed
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1442 pass
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1443
22
7bd4ca56607d bug fix: Mutable default arguments
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
1444 def _itemsFactory(self, list_paned, pane_path=None):
7bd4ca56607d bug fix: Mutable default arguments
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
1445 """_itemsFactory(list_paned, pane_path=None)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1446
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1447 list_paned: list in "__panes_list" format
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1448 [ "v" or "h", panel1_type, panel2_type]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1449 which contains the info for create the widgets.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1450 panel types:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1451 * "DecompositionList"
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1452 * "RecordDescription"
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1453 * "Measure"
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1454 * "Sheet of Conditions"
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1455 * "FileView"
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1456 * "CompanyView"
7
0359329a1c26 Navigation buttons. Version of the data structure.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 6
diff changeset
1457 pane_path: tuple that represents the item path in the page
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1458
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1459 Creates the items and widgets and returns the main item
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1460 """
22
7bd4ca56607d bug fix: Mutable default arguments
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
1461 if pane_path is None:
7bd4ca56607d bug fix: Mutable default arguments
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
1462 pane_path = (0,)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1463 if not isinstance(list_paned , list):
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1464 raise ValueError( _("The value must be a list") )
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1465 if list_paned[0] == "v" or list_paned[0] == "h":
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1466 if len(list_paned) != 3:
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1467 raise ValueError( _("Incorrect len") )
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1468 if not isinstance(list_paned[1],list):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1469 list_paned[1] = [list_paned[1]]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1470 if not isinstance(list_paned[2],list):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1471 list_paned[2] = [list_paned[2]]
7
0359329a1c26 Navigation buttons. Version of the data structure.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 6
diff changeset
1472 _item1 = self._itemsFactory(list_paned[1],pane_path + (0,))
0359329a1c26 Navigation buttons. Version of the data structure.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 6
diff changeset
1473 _item2 = self._itemsFactory(list_paned[2],pane_path + (1,))
0359329a1c26 Navigation buttons. Version of the data structure.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 6
diff changeset
1474 _item = Paned(list_paned[0], pane_path, _item1, _item2)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1475 elif list_paned[0] == "DecompositionList":
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1476 _item = View( "DecompositionList", self.__budget,
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1477 weakref.ref(self), pane_path, self.__active_path_record, True)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1478 elif list_paned[0] == "RecordDescription":
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1479 _item = View( "RecordDescription", self.__budget,weakref.ref(self),
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1480 pane_path, self.__active_path_record, True)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1481 elif list_paned[0] == "Measure":
25
189f8274aecd gui. switch navigation menu on switch page
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 23
diff changeset
1482 _item = View("Measure", self.__budget, weakref.ref(self),
189f8274aecd gui. switch navigation menu on switch page
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 23
diff changeset
1483 pane_path, self.__active_path_record, True)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1484 elif list_paned[0] == "Sheet of Conditions":
25
189f8274aecd gui. switch navigation menu on switch page
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 23
diff changeset
1485 _item = View("Sheet of Conditions",
189f8274aecd gui. switch navigation menu on switch page
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 23
diff changeset
1486 self.__budget, weakref.ref(self), pane_path,
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1487 self.__active_path_record)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1488 elif list_paned[0] == "FileView":
25
189f8274aecd gui. switch navigation menu on switch page
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 23
diff changeset
1489 _item = View("FileView", self.__budget, weakref.ref(self),
189f8274aecd gui. switch navigation menu on switch page
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 23
diff changeset
1490 pane_path, self.__active_path_record)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1491 elif list_paned[0] == "CompanyView":
25
189f8274aecd gui. switch navigation menu on switch page
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 23
diff changeset
1492 _item = View("CompanyView", self.__budget, weakref.ref(self),
189f8274aecd gui. switch navigation menu on switch page
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 23
diff changeset
1493 pane_path, self.__active_path_record)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1494 else:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1495 _item = None
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1496 raise ValueError( utils.mapping(_("Incorrect item $1"),
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1497 (str(list_paned[0]),)) )
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1498 return _item
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1499
7
0359329a1c26 Navigation buttons. Version of the data structure.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 6
diff changeset
1500 def _setActivePathRecord(self, path_record):
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1501 """_setActivePathRecord(path_record)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1502
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1503 path_record: the active record path
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1504
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1505 Sets the active record path
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1506 """
7
0359329a1c26 Navigation buttons. Version of the data structure.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 6
diff changeset
1507 if path_record != self.__active_path_record:
0359329a1c26 Navigation buttons. Version of the data structure.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 6
diff changeset
1508 if self.__budget.hasPath(path_record):
0359329a1c26 Navigation buttons. Version of the data structure.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 6
diff changeset
1509 self.__active_path_record = path_record
0359329a1c26 Navigation buttons. Version of the data structure.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 6
diff changeset
1510 self._appendHistory(path_record)
0359329a1c26 Navigation buttons. Version of the data structure.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 6
diff changeset
1511 else:
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1512 raise ValueError( utils.mapping(_("The budget does not have "\
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1513 "the path record: $1"), (str(path_record),)) )
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1514
7
0359329a1c26 Navigation buttons. Version of the data structure.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 6
diff changeset
1515 def _appendHistory(self, path):
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1516 """_appendHistory(path))
7
0359329a1c26 Navigation buttons. Version of the data structure.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 6
diff changeset
1517
11
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
1518 path: the new active path record
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
1519
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
1520 Append the new active path record to history lists and update menus
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
1521 """
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
1522 if len(self.__history_back) > 1 and path in self.__history_back[:-1]:
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
1523 # the new active record is in back history list
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
1524 # then append forward history and pop back history
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
1525 _items_num = len(self.__history_back) - \
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
1526 self.__history_back.index(path) -1
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
1527 for _item in range(_items_num):
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
1528 _record_path = self.__history_back.pop()
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
1529 _first_menuitem = self.__back_menu.get_children()[0]
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
1530 self.__back_menu.remove(_first_menuitem)
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
1531 self.__history_forward.append(_record_path)
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
1532 _menuitem = self._menuItemFactory(_record_path)
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
1533 _menuitem.connect_object("activate", self._menuHistoryForward,
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
1534 _record_path, _menuitem)
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
1535 self.__forward_menu.prepend(_menuitem)
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
1536 while len(self.__history_forward) > 100:
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
1537 # list too long
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
1538 self.__history_forward.pop(0)
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
1539 _last_menuitem = self.__forward_menu.get_children()[-1]
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
1540 self.__forward_menu.remove(_last_menuitem)
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
1541 else:
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
1542 # the new active record not is in back history list
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
1543 if len(self.__history_forward) > 1 and \
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
1544 path in self.__history_forward:
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
1545 # the new active record is in history forward list
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
1546 # then append back history and pop forward history
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
1547 _items_num = len(self.__history_forward) - \
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
1548 self.__history_forward.index(path)
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
1549 for _item in range(_items_num):
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
1550 _record_path = self.__history_forward.pop()
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
1551 _first_menuitem = self.__forward_menu.get_children()[0]
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
1552 self.__forward_menu.remove(_first_menuitem)
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
1553 self.__history_back.append(_record_path)
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
1554 if len(self.__history_back) > 1:
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
1555 _menuitem = self._menuItemFactory(
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
1556 self.__history_back[-2])
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
1557 _menuitem.connect_object("activate",
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
1558 self._menuHistoryBack, self.__history_back[-2],
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
1559 _menuitem)
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
1560 self.__back_menu.prepend(_menuitem)
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
1561 else:
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
1562 # the new active record not is in history forward list
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
1563 # then append back history and clear forward history
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
1564 self.__history_forward[:] = []
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
1565 for _child in self.__forward_menu.get_children():
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
1566 self.__forward_menu.remove(_child)
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
1567 self.__history_back.append(path)
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
1568 if len(self.__history_back) > 1:
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
1569 _menuitem = self._menuItemFactory(self.__history_back[-2])
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
1570 _menuitem.connect_object("activate", self._menuHistoryBack,
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
1571 self.__history_back[-2], _menuitem)
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
1572 self.__back_menu.prepend(_menuitem)
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
1573 while len(self.__history_back) > 100:
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
1574 # list too long
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
1575 self.__history_back.pop(0)
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
1576 _last_menuitem = self.__back_menu.get_children()[-1]
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
1577 self.__back_menu.remove(_last_menuitem)
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
1578 self.__mainWindow.changeHistorySignal()
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
1579
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
1580 def _getImage(self, record):
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
1581 """_getImage(record)
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
1582
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
1583 record: record object
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
1584
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
1585 Returns an image depending on the type of record
7
0359329a1c26 Navigation buttons. Version of the data structure.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 6
diff changeset
1586 """
11
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
1587 _hierarchy = record.recordType.hierarchy
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
1588 _type = record.recordType.type
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
1589 _subtype = record.recordType.subtype
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
1590 if _hierarchy == 0:
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
1591 _icon = self.__budget_icon
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
1592 elif _hierarchy == 1:
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
1593 _icon = self.__chapter_icon
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1594 else:
11
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
1595 if _type == 0:
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
1596 _icon = self.__unit_icon
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
1597 elif _type == 1:
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
1598 _icon = self.__labourforce_icon
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
1599 elif _type == 2:
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
1600 _icon = self.__machinery_icon
7
0359329a1c26 Navigation buttons. Version of the data structure.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 6
diff changeset
1601 else:
11
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
1602 _icon = self.__material_icon
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1603 _image = Gtk.Image()
11
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
1604 _image.set_from_pixbuf(_icon)
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
1605 return _image
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
1606
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
1607 def _menuFactory(self):
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
1608 """_menuFactory()
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
1609
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
1610 record: record object
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
1611
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
1612 Creates menus for history back an history forward tool buttons
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
1613 """
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
1614 # Back Menu
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
1615 # clear menu
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
1616 for _child in self.__back_menu.get_children():
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
1617 self.__back_menu.remove(_child)
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
1618 # pupulate menu
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
1619 if len(self.__history_back) > 1:
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
1620 for _record_path in self.__history_back[:-1]:
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
1621 _menuitem = self._menuItemFactory(_record_path)
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1622 _menuitem.connect("activate", self._menuHistoryBack,
11
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
1623 _record_path, _menuitem)
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
1624 self.__back_menu.prepend(_menuitem)
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
1625 # Forward Menu
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
1626 # clear menu
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
1627 for _child in self.__forward_menu.get_children():
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
1628 self.__forward_menu.remove(_child)
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
1629 # pupulate menu
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
1630 if len(self.__history_forward) > 0:
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
1631 for _record_path in self.__history_forward[:]:
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
1632 _menuitem = self._menuItemFactory(_record_path)
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1633 _menuitem.connect("activate", self._menuHistoryForward,
11
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
1634 _record_path, _menuitem)
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
1635 self.__forward_menu.prepend(_menuitem)
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
1636
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
1637 def _menuItemFactory(self, record_path):
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
1638 """_menuItemFactory(record_path):
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
1639
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
1640 record_path: record path
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
1641
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
1642 Creates and return a menuItem to go to the record
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
1643 """
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
1644 _code = self.budget.getCode(record_path)
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
1645 _record = self.budget.getRecord(_code)
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
1646 _summary = _record.summary
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1647 _text = _code.decode("utf8") + " " + _summary.decode("utf8")
11
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
1648 if len(_text) > 30:
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
1649 _text = _text[:27] + "..."
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1650 _icon = self._getImage(_record)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1651 _grid = Gtk.Grid()
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1652 _grid.set_orientation(Gtk.Orientation(0)) # 0 Horizontal
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1653 _grid.set_column_spacing(6)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1654 _label = Gtk.Label(_text)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1655 _menuitem = Gtk.MenuItem.new()
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1656 _grid.add(_icon)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1657 _grid.add(_label)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1658 _menuitem.add(_grid)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1659 _menuitem.show_all()
11
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
1660 return _menuitem
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
1661
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
1662 def _menuHistoryBack(self, record_path, menu_item):
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
1663 """_menuHistoryBack(record_path, menu_item)
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
1664
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
1665 Go to the record selected in History Back menu
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
1666 """
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
1667 if self.budget.hasPath(record_path):
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
1668 self.propagateMessageFrom("change_active", (-1,), record_path)
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
1669
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
1670 def _menuHistoryForward(self, record_path, menu_item):
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
1671 """_menuHistoryForward(record_path, menu_item)
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
1672
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
1673 Go to the record selected in History Forward menu
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
1674 """
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
1675 if self.budget.hasPath(record_path):
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
1676 self.propagateMessageFrom("change_active", (-1,), record_path)
7
0359329a1c26 Navigation buttons. Version of the data structure.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 6
diff changeset
1677
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1678 def _getActivePathRecord(self):
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1679 """_getActivePathRecord()
7
0359329a1c26 Navigation buttons. Version of the data structure.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 6
diff changeset
1680
0359329a1c26 Navigation buttons. Version of the data structure.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 6
diff changeset
1681 Return the Active Path Record
0359329a1c26 Navigation buttons. Version of the data structure.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 6
diff changeset
1682 """
0359329a1c26 Navigation buttons. Version of the data structure.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 6
diff changeset
1683 return self.__active_path_record
0359329a1c26 Navigation buttons. Version of the data structure.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 6
diff changeset
1684
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1685 def _getPreviousPathRecord(self):
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1686 """_getPreviousPathRecord()
7
0359329a1c26 Navigation buttons. Version of the data structure.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 6
diff changeset
1687
0359329a1c26 Navigation buttons. Version of the data structure.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 6
diff changeset
1688 Return the Previous Path Record
0359329a1c26 Navigation buttons. Version of the data structure.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 6
diff changeset
1689 """
0359329a1c26 Navigation buttons. Version of the data structure.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 6
diff changeset
1690 if len(self.__history_back) > 1:
0359329a1c26 Navigation buttons. Version of the data structure.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 6
diff changeset
1691 return self.__history_back[-2]
0359329a1c26 Navigation buttons. Version of the data structure.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 6
diff changeset
1692 else:
0359329a1c26 Navigation buttons. Version of the data structure.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 6
diff changeset
1693 return None
0359329a1c26 Navigation buttons. Version of the data structure.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 6
diff changeset
1694
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1695 def _getPosteriorPathRecord(self):
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1696 """_getPosteriorPathRecord()
7
0359329a1c26 Navigation buttons. Version of the data structure.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 6
diff changeset
1697
0359329a1c26 Navigation buttons. Version of the data structure.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 6
diff changeset
1698 Return the Posterior Path Record
0359329a1c26 Navigation buttons. Version of the data structure.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 6
diff changeset
1699 """
0359329a1c26 Navigation buttons. Version of the data structure.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 6
diff changeset
1700 if len(self.__history_forward) > 0:
0359329a1c26 Navigation buttons. Version of the data structure.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 6
diff changeset
1701 return self.__history_forward[-1]
0359329a1c26 Navigation buttons. Version of the data structure.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 6
diff changeset
1702 else:
0359329a1c26 Navigation buttons. Version of the data structure.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 6
diff changeset
1703 return None
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1704
11
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
1705 def _getBackMenu(self):
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
1706 """_getBackMenu()
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
1707
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
1708 Return the Back Menu
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
1709 """
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
1710 return self.__back_menu
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
1711
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
1712 def _getForwardMenu(self):
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
1713 """_getForwardMenu()
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
1714
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
1715 Return the Forward Menu
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
1716 """
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
1717 return self.__forward_menu
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
1718
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1719 def _getTitle(self):
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1720 """_getTitle()
7
0359329a1c26 Navigation buttons. Version of the data structure.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 6
diff changeset
1721
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1722 Return the page title, a Gtk.Label objetc
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1723 """
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1724 return self.__title
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1725
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1726 def _getWidget(self):
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1727 """_getWidget()
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1728
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1729 Return de main widget to show in the pane
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1730 """
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1731 return self.__widget
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1732
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1733 def _setBudget(self, budget):
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1734 """_setBudget(budget)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1735
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1736 budget: a base.Budget object
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1737
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1738 Sets the budget and the active code atributes,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1739 creates the page title and the widgets in the pane and
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1740 shows the main widget.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1741 """
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1742 if budget is None:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1743 self.clear()
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1744 return
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1745 self.__budget = budget
7
0359329a1c26 Navigation buttons. Version of the data structure.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 6
diff changeset
1746 self._setActivePathRecord((0,))
0359329a1c26 Navigation buttons. Version of the data structure.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 6
diff changeset
1747 # Todo: change page title
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1748 self.__title = Gtk.Label(self.__budget.getCode(
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1749 self.__active_path_record))
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1750 _panes_list = self.__panes_list
7
0359329a1c26 Navigation buttons. Version of the data structure.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 6
diff changeset
1751 self.__main_item = self._itemsFactory(_panes_list)
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1752 _main_widget = self.__main_item.widget
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1753 _main_widget.show()
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1754 self.__widget.add(_main_widget)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1755
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1756 def _getBudget(self):
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1757 """_getBudget()
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1758
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1759 Return de budget, a "base.Budget" object.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1760 """
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1761 return self.__budget
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1762
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1763 def _getPanesList(self):
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1764 """_getPanesList()
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1765
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1766 Return the panes list, info list for create the panes.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1767 """
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1768 return self.__panes_list
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1769
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1770 budget = property(_getBudget, _setBudget, None,
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1771 "Budget to show, base.Budget object")
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1772 widget = property(_getWidget, None, None,
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1773 "Main widget showed in the pane")
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1774 title = property(_getTitle, None, None,
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1775 "Page Title")
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1776 panes_list = property(_getPanesList, None, None,
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1777 "Info list for create the panes")
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1778 activePathRecord = property(_getActivePathRecord, None, None,
7
0359329a1c26 Navigation buttons. Version of the data structure.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 6
diff changeset
1779 "Active Path Record")
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1780 previousPathRecord = property(_getPreviousPathRecord, None, None,
7
0359329a1c26 Navigation buttons. Version of the data structure.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 6
diff changeset
1781 "Previous Active Path Record")
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1782 posteriorPathRecord = property(_getPosteriorPathRecord, None, None,
7
0359329a1c26 Navigation buttons. Version of the data structure.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 6
diff changeset
1783 "Posterior Active Path Record")
11
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
1784 back_menu = property(_getBackMenu, None, None,
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
1785 "Back Menu")
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
1786 forward_menu = property(_getForwardMenu, None, None,
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
1787 "Forward Menu")
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1788
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1789 class View(object):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1790 """gui.View:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1791
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1792 Description:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1793 It creates a view to show the budget info
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1794 Constructor:
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1795 View(view_type, budget, wr_page, pane_path, active_path_record,
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1796 connected)
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1797 view_type: the object type to show
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1798 * DecompositionList
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1799 * Description
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1800 * Measure
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1801 * Sheet
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1802 * FileView
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1803 * CompanyView
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1804 budget: the budget to show
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1805 wr_page: weak reference to the page where the view must be showed
10
d2cbc0278b30 bug fix: A except is raised when a user splits a pane, closes one of the new panes and splits again.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 9
diff changeset
1806 pane_path: the position or path of the view in the page notebook
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1807 active_path_record: the record path that must be showed
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1808 connected: boolean value, True means that the View object sends
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1809 and receives signals from/to others views.
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1810 Ancestry:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1811 +-- object
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1812 +-- View
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1813 Atributes:
10
d2cbc0278b30 bug fix: A except is raised when a user splits a pane, closes one of the new panes and splits again.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 9
diff changeset
1814 pane_path: Read-Write. The tuple that identifies the view in the main
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1815 notebook page
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1816 widget: Read. the main Gtk widget to show in a view object,
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1817 a Gtk.Grid object
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1818 Methods:
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1819 getItem
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1820 propagateMessgeFrom
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1821 runMessage
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1822 getClone
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1823 clear
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1824 """
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1825
10
d2cbc0278b30 bug fix: A except is raised when a user splits a pane, closes one of the new panes and splits again.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 9
diff changeset
1826 def __init__(self, view_type, budget, wr_page, pane_path,
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1827 active_path_record, connected=True):
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1828 """__init__(view_type, budget, wr_page, pane_path, active_path_record,
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1829 connected )
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1830 view_type: the object type to show
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1831 * DecompositionList
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1832 * Description
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1833 * Measure
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1834 * Sheet
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1835 * FileView
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1836 * CompanyView
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1837 budget: the budget to show
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1838 wr_page: weak reference to the page where the view must be showed
10
d2cbc0278b30 bug fix: A except is raised when a user splits a pane, closes one of the new panes and splits again.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 9
diff changeset
1839 pane_path: the position or path of the view in the page notebook
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1840 active_path_record: the record path that must be showed
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1841
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1842 self.__view_type: the object type to show
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1843 * DecompositionList
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1844 * Description
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1845 * Measure
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1846 * Sheet of conditions
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1847 * FileView
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1848 * CompanyView
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1849 self.__wr_page: weak reference to the page where the view must be
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1850 showed
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1851 self.__budget: the budget to show
10
d2cbc0278b30 bug fix: A except is raised when a user splits a pane, closes one of the new panes and splits again.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 9
diff changeset
1852 self.__pane_path: the position or path of the view in the page notebook
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1853 self.__connected: boolean value, True means that the View object sends
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1854 and receives signals from/to others views
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1855 self.__widget: main widget. a Gtk.Grid
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1856 self.__view: the object to show:
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1857 * DecompositionList object
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1858 * Description object
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1859 * Measure object
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1860 * Sheet object
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1861 * FileView object
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1862 * Comapany View
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1863 self.__connected_button: a button to switch self.__connected True or
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1864 False
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1865
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1866 Creates and shows a new view
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1867 """
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1868 self.__view_type = view_type
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1869 self.__wr_page = wr_page
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1870 self.__budget = budget
10
d2cbc0278b30 bug fix: A except is raised when a user splits a pane, closes one of the new panes and splits again.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 9
diff changeset
1871 self.__pane_path = pane_path
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1872 self.__connected = connected
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1873 # view_type liststore
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1874 _liststore = Gtk.ListStore(str)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1875 _liststore.append([_("Decomposition")]) #0
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1876 _liststore.append([_("Description")]) #1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1877 _liststore.append([_("Measure")]) #2
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1878 _liststore.append([_("Sheet of Conditions")]) #3
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1879 _liststore.append([_("Files")]) #4
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1880 _liststore.append([_("Companies")]) #5
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1881 _combobox = Gtk.ComboBox.new_with_model(_liststore)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1882 _cell = Gtk.CellRendererText()
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1883 _combobox.pack_start(_cell, True)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1884 _combobox.add_attribute(_cell, 'text', 0)
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1885 self.__widget = Gtk.Grid()
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1886 self.__widget.set_orientation(Gtk.Orientation(1)) # 1 Vertical
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1887 _hbox = Gtk.Grid()
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1888 _hbox.set_orientation(Gtk.Orientation(0)) # 0 Horizontal
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1889 if view_type == "DecompositionList":
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1890 self.__view = DecompositionList(budget, weakref.ref(self),
10
d2cbc0278b30 bug fix: A except is raised when a user splits a pane, closes one of the new panes and splits again.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 9
diff changeset
1891 pane_path, active_path_record)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1892 _combobox.set_active(0)
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1893 _view_icon = Gtk.Image()
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1894 _view_icon.set_from_file(globalVars.getAppPath(
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1895 "DECOMPOSITION-ICON"))
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1896 elif view_type == "RecordDescription":
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1897 self.__view = Description(budget, weakref.ref(self),
10
d2cbc0278b30 bug fix: A except is raised when a user splits a pane, closes one of the new panes and splits again.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 9
diff changeset
1898 pane_path, active_path_record)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1899 _combobox.set_active(1)
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1900 _view_icon = Gtk.Image()
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1901 _view_icon.set_from_file(globalVars.getAppPath(
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
1902 "DESCRIPTION-ICON"))
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1903 elif view_type == "Measure":
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1904 self.__view = Measure(budget, weakref.ref(self),
10
d2cbc0278b30 bug fix: A except is raised when a user splits a pane, closes one of the new panes and splits again.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 9
diff changeset
1905 pane_path, active_path_record)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1906 _combobox.set_active(2)
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1907 _view_icon = Gtk.Image()
6
2fc6b47dbe70 rename module globals to globalVars
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 5
diff changeset
1908 _view_icon.set_from_file(globalVars.getAppPath("MEASURE-ICON"))
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1909 elif view_type == "Sheet of Conditions":
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1910 self.__view = Sheet(budget, weakref.ref(self),
10
d2cbc0278b30 bug fix: A except is raised when a user splits a pane, closes one of the new panes and splits again.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 9
diff changeset
1911 pane_path, active_path_record)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1912 _combobox.set_active(3)
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1913 _view_icon = Gtk.Image()
6
2fc6b47dbe70 rename module globals to globalVars
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 5
diff changeset
1914 _view_icon.set_from_file(globalVars.getAppPath("SHEET-ICON"))
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1915 elif view_type == "FileView":
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1916 self.__view = FileView(budget, weakref.ref(self),
10
d2cbc0278b30 bug fix: A except is raised when a user splits a pane, closes one of the new panes and splits again.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 9
diff changeset
1917 pane_path, active_path_record)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1918 _combobox.set_active(4)
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1919 _view_icon = Gtk.Image()
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1920 _view_icon.set_from_file(globalVars.getAppPath("FILEVIEW-ICON"))
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1921 elif view_type == "CompanyView":
10
d2cbc0278b30 bug fix: A except is raised when a user splits a pane, closes one of the new panes and splits again.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 9
diff changeset
1922 self.__view = CompanyView(budget, weakref.ref(self), pane_path,
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1923 active_path_record)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1924 _combobox.set_active(5)
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1925 _view_icon = Gtk.Image()
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1926 _view_icon.set_from_file(globalVars.getAppPath("COMPANY-ICON"))
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1927 else:
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1928 raise ValueError( _(utils.mapping("Invalid type of View: $1",
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1929 view_type)) )
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1930 _view_icon.show()
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1931 _combobox.connect("changed", self._change_combo)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1932 _combobox.show()
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1933 self.__widget.add(_hbox)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1934 self.__widget.add(self.__view.widget)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1935 _hbox.add(_view_icon)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1936 _hbox.add(_combobox)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1937 _invisible = Gtk.Grid()
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1938 _invisible.set_orientation(Gtk.Orientation(0)) # 0 Horizontal
25
189f8274aecd gui. switch navigation menu on switch page
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 23
diff changeset
1939 _invisible.set_property("hexpand", True) # expand horizontal space
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1940 _invisible.show()
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1941 _hbox.add(_invisible)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1942 # TODO : Set thist with config
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1943 add_menu = False
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1944 if add_menu:
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1945 _icon_menu = Gtk.Image()
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1946 _icon_menu.set_from_file(globalVars.getAppPath("MENU-ICON"))
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1947 _icon_menu.show()
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1948 _menu_button = Gtk.ToolButton()
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1949 _menu_button.set_icon_widget(_icon_menu)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1950 _menu_button.connect("clicked", self._menu_view)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1951 _menu_button.show()
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1952 _hbox.add(_menu_button)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1953
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1954 _icon_horizontal = Gtk.Image()
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1955 _icon_horizontal.set_from_file(globalVars.getAppPath("HORIZONTAL"))
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1956 _icon_horizontal.show()
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1957 _horizontal_button = Gtk.ToolButton()
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1958 _horizontal_button.set_icon_widget(_icon_horizontal)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1959 _horizontal_button.connect("clicked", self._split_view, "h")
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1960 _horizontal_button.set_tooltip_text(_("Split View Left/Right"))
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1961 _horizontal_button.show()
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1962 _hbox.add(_horizontal_button)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1963
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1964 _icon_vertical = Gtk.Image()
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1965 _icon_vertical.set_from_file(globalVars.getAppPath("VERTICAL"))
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1966 _icon_vertical.show()
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1967 _vertical_button = Gtk.ToolButton()
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1968 _vertical_button.set_icon_widget(_icon_vertical)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1969 _vertical_button.connect("clicked", self._split_view, "v")
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1970 _vertical_button.set_tooltip_text(_("Split View Top/Bottom"))
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1971 _vertical_button.show()
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1972 _hbox.add(_vertical_button)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1973
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1974 self.__connected_button = Gtk.ToolButton()
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1975 _icon_connected = Gtk.Image()
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1976 if self.__connected:
25
189f8274aecd gui. switch navigation menu on switch page
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 23
diff changeset
1977 _icon_path = globalVars.getAppPath("CONNECTED-ICON")
189f8274aecd gui. switch navigation menu on switch page
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 23
diff changeset
1978 _icon_connected.set_from_file(_icon_path)
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1979 self.__connected_button.set_tooltip_text(_("Disconnect view"))
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1980 else:
25
189f8274aecd gui. switch navigation menu on switch page
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 23
diff changeset
1981 _icon_path = globalVars.getAppPath("DISCONNECTED-ICON")
189f8274aecd gui. switch navigation menu on switch page
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 23
diff changeset
1982 _icon_connected.set_from_file(_icon_path)
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1983 self.__connected_button.set_tooltip_text(_("Connect view"))
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1984 _icon_connected.show()
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1985 self.__connected_button.set_icon_widget(_icon_connected)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1986 self.__connected_button.connect("clicked", self._connected)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1987 self.__connected_button.show()
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1988 _hbox.add(self.__connected_button)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1989
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1990 _icon_close = Gtk.Image()
6
2fc6b47dbe70 rename module globals to globalVars
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 5
diff changeset
1991 _icon_close.set_from_file(globalVars.getAppPath("CLOSE-ICON"))
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1992 _icon_close.show()
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1993 _close_button = Gtk.ToolButton()
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1994 _close_button.set_icon_widget(_icon_close)
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1995 _close_button.connect("clicked", self._closeItem_from_button)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1996 _close_button.set_tooltip_text(_("Close view"))
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1997 _close_button.show()
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
1998 _hbox.add(_close_button)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
1999 _hbox.show()
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2000 self.__widget.show()
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2001
10
d2cbc0278b30 bug fix: A except is raised when a user splits a pane, closes one of the new panes and splits again.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 9
diff changeset
2002 def getItem(self, pane_path):
d2cbc0278b30 bug fix: A except is raised when a user splits a pane, closes one of the new panes and splits again.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 9
diff changeset
2003 """getItem(pane_path)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2004
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2005 Return itself.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2006 """
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2007 return self
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2008
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2009 def _closeItem_from_menu(self, close_menuitem):
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2010 """_closeItem_from_menu(close_menuitem)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2011
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2012 Method connected to the "clicked" signal of the _close_button widget
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2013 Send the "autoclose" message to the page to close this view
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2014 """
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2015 self.propagateMessageFrom("autoclose", self.__pane_path)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2016
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2017 def _closeItem_from_button(self, close_button):
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2018 """_closeItem_from_button(close_button)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2019
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2020 Method connected to the "clicked" signal of the _close_button widget
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2021 Send the "autoclose" message to the page to close this view
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2022 """
10
d2cbc0278b30 bug fix: A except is raised when a user splits a pane, closes one of the new panes and splits again.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 9
diff changeset
2023 self.propagateMessageFrom("autoclose", self.__pane_path)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2024
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2025 def _change_combo(self, combobox):
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
2026 """_change_combo(combobox)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2027
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2028 Method connected to the "changed" signal of the _combobox widget
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2029 It changes the view type to the type selected in the combobox
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2030 """
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2031 _index = combobox.get_active()
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2032 _budget = self.__view.budget
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2033 _wr_page = self.__view.wr_page
10
d2cbc0278b30 bug fix: A except is raised when a user splits a pane, closes one of the new panes and splits again.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 9
diff changeset
2034 _pane_path = self.__view.pane_path
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2035 _path_record = self.__view.active_path_record
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2036 _hbox = self.__widget.get_children()[1]
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2037 _view_icon = _hbox.get_child_at(0, 0)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2038 _hbox.remove(_view_icon)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2039 _view_icon.destroy()
9
229986217a3d bug fix: view is not displayed when it splits the view Left/Right
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 8
diff changeset
2040 self.__widget.remove(self.__view.widget)
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2041 _view_icon = Gtk.Image()
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2042 if _index == 0:
10
d2cbc0278b30 bug fix: A except is raised when a user splits a pane, closes one of the new panes and splits again.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 9
diff changeset
2043 self.__view = DecompositionList(_budget, _wr_page, _pane_path,
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2044 _path_record)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2045
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
2046 _view_icon.set_from_file(globalVars.getAppPath(
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
2047 "DECOMPOSITION-ICON"))
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2048 self.__view_type = "DecompositionList"
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2049 elif _index == 1:
10
d2cbc0278b30 bug fix: A except is raised when a user splits a pane, closes one of the new panes and splits again.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 9
diff changeset
2050 self.__view = Description(_budget, _wr_page, _pane_path,
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2051 _path_record)
6
2fc6b47dbe70 rename module globals to globalVars
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 5
diff changeset
2052 _view_icon.set_from_file(globalVars.getAppPath("DESCRIPTION-ICON"))
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2053 self.__view_type = "RecordDescription"
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2054 elif _index == 2:
10
d2cbc0278b30 bug fix: A except is raised when a user splits a pane, closes one of the new panes and splits again.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 9
diff changeset
2055 self.__view = Measure(_budget, _wr_page, _pane_path,
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2056 _path_record)
6
2fc6b47dbe70 rename module globals to globalVars
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 5
diff changeset
2057 _view_icon.set_from_file(globalVars.getAppPath("MEASURE-ICON"))
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2058 self.__view_type = "Measure"
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2059 elif _index == 3:
10
d2cbc0278b30 bug fix: A except is raised when a user splits a pane, closes one of the new panes and splits again.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 9
diff changeset
2060 self.__view = Sheet(_budget, _wr_page, _pane_path,
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2061 _path_record)
6
2fc6b47dbe70 rename module globals to globalVars
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 5
diff changeset
2062 _view_icon.set_from_file(globalVars.getAppPath("SHEET-ICON"))
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2063 self.__view_type = "Sheet of Conditions"
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2064 elif _index == 4:
10
d2cbc0278b30 bug fix: A except is raised when a user splits a pane, closes one of the new panes and splits again.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 9
diff changeset
2065 self.__view = FileView(_budget, _wr_page, _pane_path,
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2066 _path_record)
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2067 _view_icon.set_from_file(globalVars.getAppPath("FILEVIEW-ICON"))
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2068 self.__view_type = "FileView"
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2069 elif _index == 5:
10
d2cbc0278b30 bug fix: A except is raised when a user splits a pane, closes one of the new panes and splits again.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 9
diff changeset
2070 self.__view = CompanyView(_budget, _wr_page, _pane_path,
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2071 _path_record)
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2072 _view_icon.set_from_file(globalVars.getAppPath("COMPANY-ICON"))
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2073 self.__view_type = "CompanyView"
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2074 _view_icon.show()
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2075 _hbox.attach(_view_icon, 0, 0, 1, 1)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2076 self.__widget.add(self.__view.widget)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2077
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2078 def _menu_view(self, widget):
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
2079 """_menu_view(widget)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2080
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2081 Method connected to the "clicked" signal of the __connected_button
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2082 It shows a popup menu with some options
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2083 """
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2084 _menu_view = Gtk.Menu()
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2085 _item_leftright = Gtk.MenuItem(_("Split view Left/Right"))
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2086 _menu_view.append(_item_leftright)
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2087 _item_leftright.connect("activate", self._split_view, "h")
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2088 _item_leftright.show()
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2089 _item_topbottom = Gtk.MenuItem(_("Split view Top/Bottom"))
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2090 _menu_view.append(_item_topbottom)
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2091 _item_topbottom.connect("activate", self._split_view, "v")
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2092 _item_topbottom.show()
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2093 _item_close = Gtk.MenuItem(_("Close view"))
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2094 _menu_view.append(_item_close)
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2095 _item_close.connect("activate",self._closeItem_from_menu)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2096 _item_close.show()
25
189f8274aecd gui. switch navigation menu on switch page
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 23
diff changeset
2097 _menu_view.popup_at_widget(widget, Gdk.Gravity(7), Gdk.Gravity(1),
189f8274aecd gui. switch navigation menu on switch page
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 23
diff changeset
2098 Gtk.get_current_event())
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2099
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2100 def _split_view(self, widget, orientation):
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
2101 """_menu_view(orientation)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2102
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2103 orientation: orientation split, "h" or "v"
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2104
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2105 Method connected to the "activate" signal of the _item_leftright and
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2106 _item_topbottom menu items.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2107 It sends the "split" message to the page to splits the view in the
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2108 specified orientation
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2109 """
10
d2cbc0278b30 bug fix: A except is raised when a user splits a pane, closes one of the new panes and splits again.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 9
diff changeset
2110 self.propagateMessageFrom( "split " + orientation, self.__pane_path)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2111
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2112 def _connected(self, widget):
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
2113 """_connected(widget)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2114
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2115 Method connected to the "clicked" signal of the _menu_button
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2116 It changes the __connected atribute to True or False, if the
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2117 _connected atribute is False the view do not send and receive messages
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2118 to/from others views
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2119 """
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2120 if self.__connected:
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2121 _icon = Gtk.Image()
6
2fc6b47dbe70 rename module globals to globalVars
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 5
diff changeset
2122 _icon.set_from_file(globalVars.getAppPath("DISCONNECTED-ICON"))
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2123 _icon.show()
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2124 self.__connected_button.set_icon_widget(_icon)
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2125 self.__connected_button.set_tooltip_text(_("Connect View"))
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2126 self.__connected = False
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2127 else:
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2128 _icon = Gtk.Image()
6
2fc6b47dbe70 rename module globals to globalVars
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 5
diff changeset
2129 _icon.set_from_file(globalVars.getAppPath("CONNECTED-ICON"))
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2130 _icon.show()
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2131 self.__connected_button.set_tooltip_text(_("Disconnect View"))
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2132 self.__connected_button.set_icon_widget(_icon)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2133 self.__connected = True
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2134
10
d2cbc0278b30 bug fix: A except is raised when a user splits a pane, closes one of the new panes and splits again.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 9
diff changeset
2135 def propagateMessageFrom(self, message, pane_path, arg=None):
d2cbc0278b30 bug fix: A except is raised when a user splits a pane, closes one of the new panes and splits again.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 9
diff changeset
2136 """propagateMessageFrom(message, pane_path, arg=None)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2137
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2138 message: string message
10
d2cbc0278b30 bug fix: A except is raised when a user splits a pane, closes one of the new panes and splits again.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 9
diff changeset
2139 pane_path: tuple that represents the pane path which emits the message
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2140 arg: arguments for the message
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2141 The panes are connectted to this method to send messages to other panes
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2142 """
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2143 if self.__connected or message == "autoclose" or \
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2144 message == "split h" or message == "split v":
10
d2cbc0278b30 bug fix: A except is raised when a user splits a pane, closes one of the new panes and splits again.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 9
diff changeset
2145 self.__wr_page().propagateMessageFrom(message, pane_path, arg)
d2cbc0278b30 bug fix: A except is raised when a user splits a pane, closes one of the new panes and splits again.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 9
diff changeset
2146
d2cbc0278b30 bug fix: A except is raised when a user splits a pane, closes one of the new panes and splits again.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 9
diff changeset
2147 def runMessage(self, message, pane_path, arg=None):
d2cbc0278b30 bug fix: A except is raised when a user splits a pane, closes one of the new panes and splits again.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 9
diff changeset
2148 """runMessage(message, pane_path, arg=None)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2149
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2150 message: the message type
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2151 "change_active": change the active record
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2152 "clear": clear instance
10
d2cbc0278b30 bug fix: A except is raised when a user splits a pane, closes one of the new panes and splits again.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 9
diff changeset
2153 pane_path: tuple that identifies the pane in the notebook page
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2154 arg: tuple whit two items:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2155 0: record path in the budget
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2156 1: record code
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2157 This method receives a message and executes its corresponding action
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2158 """
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2159 if self.__connected:
10
d2cbc0278b30 bug fix: A except is raised when a user splits a pane, closes one of the new panes and splits again.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 9
diff changeset
2160 self.__view.runMessage(message, pane_path, arg)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2161
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
2162 def _getWidget(self):
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
2163 """_getWidget()
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2164
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2165 Return de pane widget
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2166 """
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2167 return self.__widget
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2168
10
d2cbc0278b30 bug fix: A except is raised when a user splits a pane, closes one of the new panes and splits again.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 9
diff changeset
2169 def _getPanePath(self):
d2cbc0278b30 bug fix: A except is raised when a user splits a pane, closes one of the new panes and splits again.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 9
diff changeset
2170 """_getPanePath()
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2171
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2172 return the tuple that identifies the pane in the notebook page
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2173 """
10
d2cbc0278b30 bug fix: A except is raised when a user splits a pane, closes one of the new panes and splits again.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 9
diff changeset
2174 return self.__view.pane_path
d2cbc0278b30 bug fix: A except is raised when a user splits a pane, closes one of the new panes and splits again.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 9
diff changeset
2175
d2cbc0278b30 bug fix: A except is raised when a user splits a pane, closes one of the new panes and splits again.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 9
diff changeset
2176 def _setPanePath(self, pane_path):
d2cbc0278b30 bug fix: A except is raised when a user splits a pane, closes one of the new panes and splits again.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 9
diff changeset
2177 """_setPanePath()
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2178
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2179 set the tuple that identifies the pane in the notebook page
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2180 """
10
d2cbc0278b30 bug fix: A except is raised when a user splits a pane, closes one of the new panes and splits again.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 9
diff changeset
2181 self.__pane_path = pane_path
d2cbc0278b30 bug fix: A except is raised when a user splits a pane, closes one of the new panes and splits again.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 9
diff changeset
2182 self.__view.pane_path = pane_path
d2cbc0278b30 bug fix: A except is raised when a user splits a pane, closes one of the new panes and splits again.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 9
diff changeset
2183
d2cbc0278b30 bug fix: A except is raised when a user splits a pane, closes one of the new panes and splits again.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 9
diff changeset
2184 def getClone(self, new_pane_path):
d2cbc0278b30 bug fix: A except is raised when a user splits a pane, closes one of the new panes and splits again.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 9
diff changeset
2185 """getClone(new_pane_path)
d2cbc0278b30 bug fix: A except is raised when a user splits a pane, closes one of the new panes and splits again.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 9
diff changeset
2186
d2cbc0278b30 bug fix: A except is raised when a user splits a pane, closes one of the new panes and splits again.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 9
diff changeset
2187 new_pane_path: the path that identifies the clone view in the page
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2188
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2189 return a clone of itself
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2190 """
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2191 return View(self.__view_type, self.__budget, self.__wr_page,
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2192 new_pane_path, self.__view.active_path_record,
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2193 self.__connected)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2194
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2195 def clear(self):
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
2196 """clear()
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2197
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2198 Clear the intance atributes
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2199 """
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2200 del self.__wr_page
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2201 del self.__budget
10
d2cbc0278b30 bug fix: A except is raised when a user splits a pane, closes one of the new panes and splits again.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 9
diff changeset
2202 del self.__pane_path
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2203 del self.__widget
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2204 del self.__view
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2205 del self.__connected
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2206 del self.__connected_button
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
2207
10
d2cbc0278b30 bug fix: A except is raised when a user splits a pane, closes one of the new panes and splits again.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 9
diff changeset
2208 pane_path = property(_getPanePath, _setPanePath, None,
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2209 "path that identifies the item in the notebook page")
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
2210 widget = property(_getWidget, None, None, "View widget")
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
2211
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2212
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2213 class Paned(object):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2214 """gui.Paned:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2215
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2216 Description:
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2217 It creates and shows Gtk.Paned to show in page budget
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2218 Constructor:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2219 Paned(orientation, widget1, widget2)
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
2220 orientation: The orientation of the pane separator, can be "v" or
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
2221 "h"
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
2222 widget1: the top or left pane widget
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
2223 widget2: the botton or right pane widget
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2224 Ancestry:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2225 +-- object
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2226 +-- Paned
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2227 Atributes:
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2228 widget: Read. Pane widget("Gtk.Paned" object)
10
d2cbc0278b30 bug fix: A except is raised when a user splits a pane, closes one of the new panes and splits again.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 9
diff changeset
2229 pane_path: Read-Write. The paned path in the page
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2230 Methods:
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
2231 getClone
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
2232 getItem
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
2233 setItem
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
2234 runMessage
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2235 clear(self)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2236 """
9
229986217a3d bug fix: view is not displayed when it splits the view Left/Right
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 8
diff changeset
2237 # TODO: *control the position paned separator. Now is always in the middle
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2238 # TODO: can be with a float(0.0-1.0) aspect ratio
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2239 # TODO: 0.0 no space for widget1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2240 # TODO: 1.0 all the space for widget1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2241
10
d2cbc0278b30 bug fix: A except is raised when a user splits a pane, closes one of the new panes and splits again.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 9
diff changeset
2242 def __init__(self, orientation, pane_path, item1, item2):
d2cbc0278b30 bug fix: A except is raised when a user splits a pane, closes one of the new panes and splits again.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 9
diff changeset
2243 """__init__(oritentation, pane_path, item1, item2)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2244
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2245 orientation: The orientation of de Gtk.Paned, can be "v" or "h"
10
d2cbc0278b30 bug fix: A except is raised when a user splits a pane, closes one of the new panes and splits again.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 9
diff changeset
2246 pane_path: the paned path in the page
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2247 item1: the top or left pane object
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2248 item2: the bottom or right pane object
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2249
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2250 self.__orientation: The orientation of de Gtk.Paned, can be "v" or "h"
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2251 self.__widget: Main widget, a Gtk.Paned
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
2252 self.__items: list of items showed in the paned, its can be View or
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
2253 Paned instances
10
d2cbc0278b30 bug fix: A except is raised when a user splits a pane, closes one of the new panes and splits again.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 9
diff changeset
2254 self.__pane_path: the paned path in the page
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
2255
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2256 Creates and shows a new Gtk.Paned
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2257 """
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2258 self.__orientation = orientation
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2259 if not isinstance(item1.widget, Gtk.Widget) or \
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2260 not isinstance(item2.widget, Gtk.Widget):
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2261 raise ValueError( _("The item must be a widget object.") )
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2262 if orientation == "v":
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2263 self.__widget = Gtk.Paned.new(Gtk.Orientation(1))
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2264 self.__widget.set_wide_handle(True)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2265 elif orientation == "h":
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2266 self.__widget = Gtk.Paned.new(Gtk.Orientation(0))
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2267 self.__widget.set_wide_handle(True)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2268 else:
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2269 raise ValueError( _("Invalid orientation.") )
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2270 self.__widget.pack1(item1.widget,True,False)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2271 self.__widget.pack2(item2.widget,True,False)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2272 self.__widget.show()
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2273 self.__items = [item1, item2]
10
d2cbc0278b30 bug fix: A except is raised when a user splits a pane, closes one of the new panes and splits again.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 9
diff changeset
2274 self.__pane_path = pane_path
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2275
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2276 def __getitem__(self, item):
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
2277 """__getitem__(item)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2278
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2279 Called to implement evaluation of self[key].
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2280 The accepted keys should be integers 0 or 1.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2281 """
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2282 return self.__items[item]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2283
10
d2cbc0278b30 bug fix: A except is raised when a user splits a pane, closes one of the new panes and splits again.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 9
diff changeset
2284 def getClone(self, new_pane_path):
d2cbc0278b30 bug fix: A except is raised when a user splits a pane, closes one of the new panes and splits again.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 9
diff changeset
2285 """getClone(new_pane_path)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2286
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2287 Return a clone Paned instance with the path new_path
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2288 """
10
d2cbc0278b30 bug fix: A except is raised when a user splits a pane, closes one of the new panes and splits again.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 9
diff changeset
2289 return Paned(self.__orientation, new_pane_path,
d2cbc0278b30 bug fix: A except is raised when a user splits a pane, closes one of the new panes and splits again.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 9
diff changeset
2290 self.__items[0].getClone(new_pane_path + (0,)),
d2cbc0278b30 bug fix: A except is raised when a user splits a pane, closes one of the new panes and splits again.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 9
diff changeset
2291 self.__items[1].getClone(new_pane_path + (1,)))
d2cbc0278b30 bug fix: A except is raised when a user splits a pane, closes one of the new panes and splits again.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 9
diff changeset
2292
d2cbc0278b30 bug fix: A except is raised when a user splits a pane, closes one of the new panes and splits again.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 9
diff changeset
2293 def getItem(self,pane_path):
d2cbc0278b30 bug fix: A except is raised when a user splits a pane, closes one of the new panes and splits again.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 9
diff changeset
2294 """getItem(pane_path)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2295
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2296 Return the item whith the specified path.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2297 """
10
d2cbc0278b30 bug fix: A except is raised when a user splits a pane, closes one of the new panes and splits again.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 9
diff changeset
2298 _item = self.__items[pane_path[0]]
d2cbc0278b30 bug fix: A except is raised when a user splits a pane, closes one of the new panes and splits again.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 9
diff changeset
2299 if len(pane_path) == 1:
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2300 return _item
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2301 else:
10
d2cbc0278b30 bug fix: A except is raised when a user splits a pane, closes one of the new panes and splits again.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 9
diff changeset
2302 return _item.getItem(pane_path[1:])
d2cbc0278b30 bug fix: A except is raised when a user splits a pane, closes one of the new panes and splits again.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 9
diff changeset
2303
d2cbc0278b30 bug fix: A except is raised when a user splits a pane, closes one of the new panes and splits again.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 9
diff changeset
2304 def setItem(self, pane_path, item_list):
d2cbc0278b30 bug fix: A except is raised when a user splits a pane, closes one of the new panes and splits again.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 9
diff changeset
2305 """setItem(pane_path, item_list)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2306
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2307 Sets the first item in the item_list whith the especified path and
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2308 remove the old item in this position.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2309 """
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2310 item = item_list[0]
10
d2cbc0278b30 bug fix: A except is raised when a user splits a pane, closes one of the new panes and splits again.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 9
diff changeset
2311 if pane_path == 0 or pane_path == 1:
d2cbc0278b30 bug fix: A except is raised when a user splits a pane, closes one of the new panes and splits again.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 9
diff changeset
2312 _old_item = self.__items[pane_path]
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2313 self.__widget.remove(_old_item.widget)
10
d2cbc0278b30 bug fix: A except is raised when a user splits a pane, closes one of the new panes and splits again.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 9
diff changeset
2314 self.__items[pane_path] = item
d2cbc0278b30 bug fix: A except is raised when a user splits a pane, closes one of the new panes and splits again.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 9
diff changeset
2315 if pane_path == 0:
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2316 self.__widget.pack1(item.widget,True,False)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2317 else:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2318 self.__widget.pack2(item.widget,True,False)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2319 return True
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2320 return False
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2321
10
d2cbc0278b30 bug fix: A except is raised when a user splits a pane, closes one of the new panes and splits again.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 9
diff changeset
2322 def runMessage(self, message, pane_path, arg=None):
d2cbc0278b30 bug fix: A except is raised when a user splits a pane, closes one of the new panes and splits again.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 9
diff changeset
2323 """runMessage(message, pane_path, arg=None)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2324
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2325 message: the message type
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2326 "change_active": change the active record
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2327 "clear": clear instance
10
d2cbc0278b30 bug fix: A except is raised when a user splits a pane, closes one of the new panes and splits again.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 9
diff changeset
2328 pane_path: tuple that identifies the pane in the notebook page
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2329 arg: arguments
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2330
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2331 This method receives a message and send this to the items of the paned
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2332 """
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2333 for _item in self.__items:
10
d2cbc0278b30 bug fix: A except is raised when a user splits a pane, closes one of the new panes and splits again.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 9
diff changeset
2334 if not _item.pane_path == pane_path:
d2cbc0278b30 bug fix: A except is raised when a user splits a pane, closes one of the new panes and splits again.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 9
diff changeset
2335 _item.runMessage(message, pane_path, arg)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2336
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
2337 def _getWidget(self):
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
2338 """_getWidget()
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2339
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2340 Return de Gtk.Paned widget
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2341 """
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2342 return self.__widget
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2343
10
d2cbc0278b30 bug fix: A except is raised when a user splits a pane, closes one of the new panes and splits again.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 9
diff changeset
2344 def _getPanePath(self):
d2cbc0278b30 bug fix: A except is raised when a user splits a pane, closes one of the new panes and splits again.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 9
diff changeset
2345 """_getPanePath()
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2346
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2347 Return de Paned path in the notebook page
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2348 """
10
d2cbc0278b30 bug fix: A except is raised when a user splits a pane, closes one of the new panes and splits again.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 9
diff changeset
2349 return self.__pane_path
d2cbc0278b30 bug fix: A except is raised when a user splits a pane, closes one of the new panes and splits again.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 9
diff changeset
2350
d2cbc0278b30 bug fix: A except is raised when a user splits a pane, closes one of the new panes and splits again.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 9
diff changeset
2351 def _setPanePath(self, pane_path):
d2cbc0278b30 bug fix: A except is raised when a user splits a pane, closes one of the new panes and splits again.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 9
diff changeset
2352 """_setPanePath()
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2353
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2354 sets the tuple that identifies the pane in the notebook page
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2355 """
10
d2cbc0278b30 bug fix: A except is raised when a user splits a pane, closes one of the new panes and splits again.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 9
diff changeset
2356 self.__pane_path = pane_path
d2cbc0278b30 bug fix: A except is raised when a user splits a pane, closes one of the new panes and splits again.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 9
diff changeset
2357 self.__items[0].pane_path = pane_path + (0,)
d2cbc0278b30 bug fix: A except is raised when a user splits a pane, closes one of the new panes and splits again.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 9
diff changeset
2358 self.__items[1].pane_path = pane_path + (1,)
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
2359
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2360 def clear(self):
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
2361 """clear()
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
2362
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
2363 Delete atributes
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
2364 """
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2365 del self.__widget
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2366 del self.__orientation
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2367 del self.__items
10
d2cbc0278b30 bug fix: A except is raised when a user splits a pane, closes one of the new panes and splits again.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 9
diff changeset
2368 del self.__pane_path
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2369
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2370 widget = property(_getWidget, None, None, "Gtk.Paned widget")
10
d2cbc0278b30 bug fix: A except is raised when a user splits a pane, closes one of the new panes and splits again.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 9
diff changeset
2371 pane_path = property(_getPanePath, _setPanePath, None,
d2cbc0278b30 bug fix: A except is raised when a user splits a pane, closes one of the new panes and splits again.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 9
diff changeset
2372 "Pane path in the notebook page")
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
2373
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2374
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2375 class TreeView(object):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2376 """gui.Treeviev:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2377
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2378 Description:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2379 It creates the columns in a treeview, is the base class for
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2380 DescompositionList and Measure classes
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2381 Constructor:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2382 TreView(args)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2383 args: list of tuples, the tuple items are:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2384 0.type:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2385 * index column
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2386 * float column
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2387 * text column
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2388 * calculated column
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2389 * calculated text
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2390 * type column
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2391 1. clicked method
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2392 2. width
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2393 3. text color
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2394 4. backgruound colors
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2395 5. model column index
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2396 Ancestry:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2397 +-- object
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2398 +-- TreeView
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2399 Atributes:
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2400 columns: list of columns (Gtk.TreeViewColumn objects)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2401 Methods:
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
2402 createColumn
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
2403 createTextBaseColumn
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
2404 createBaseColumn
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2405 """
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2406
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2407 def __init__(self, args):
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
2408 """__init__(args)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2409
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2410 args: list of tuples, the tuple items are:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2411 0.type:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2412 * index column
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2413 * float column
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2414 * text column
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2415 * calculated column
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2416 * Calculated text
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2417 * type column
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2418 1. clicked method
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2419 2. width
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2420 3. text color
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2421 4. backgruound colors
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2422 5. model column index
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2423
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2424 Create the columns form the args info calling creatheColumn to create
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2425 each column
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2426 """
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2427 self.columns = [ self.createColumn(arg) for arg in args ]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2428 self.columns.append(self.createColumn(("END",)))
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2429
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2430 def createColumn(self, args):
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
2431 """createColumn(args)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2432
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2433 args: tuple with the args
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2434 0.type:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2435 * index column
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2436 * float column
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2437 * text column
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2438 * calculated column
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2439 * calculated text
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2440 * type column
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2441 1. clicked method
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2442 2. width
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2443 3. text color
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2444 4. backgruound colors
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2445 5. model column index
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2446
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2447 Return a column created whith the arg info
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2448 """
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2449 if args[0] == "INDEX":
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2450 _index_column = self.createBaseColumn(args)
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2451 _text_index_cell = Gtk.CellRendererText()
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2452 _text_index_cell.set_property('foreground',
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2453 globalVars.color["TEXT"])
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2454 _pixbuf_index_cell = Gtk.CellRendererPixbuf()
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2455 _arrow_icon = GdkPixbuf.Pixbuf.new_from_file(
6
2fc6b47dbe70 rename module globals to globalVars
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 5
diff changeset
2456 globalVars.getAppPath("ARROW-ICON"))
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2457 _pixbuf_index_cell.set_property("pixbuf", _arrow_icon)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2458 _index_column.pack_start(_text_index_cell, True)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2459 _index_column.pack_start(_pixbuf_index_cell, True)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2460 _index_column.set_cell_data_func(_text_index_cell,
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
2461 self._colorCell,
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2462 [globalVars.color["INDEX-UNEVEN"],
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2463 globalVars.color["INDEX-EVEN"]])
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2464 return _index_column
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2465 elif args[0] == "TEXT":
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2466 _column, _cell = self.createTextBaseColumn(args)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2467 _column.add_attribute(_cell, 'text', args[5])
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2468 return _column
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2469 elif args[0] == "FLOAT":
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2470 _column, _cell = self.createTextBaseColumn(args)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2471 _column.add_attribute(_cell, 'text', args[5])
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2472 _column.get_cells()[0].set_property('xalign', 1.0)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2473 return _column
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2474 elif args[0] == "CALCULATED":
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2475 _column, cell = self.createTextBaseColumn(args)
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2476 _column.get_cells()[0].set_property('xalign', 1.0)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2477 return _column
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2478 elif args[0] == "CALCULATEDTEXT":
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2479 _column, cell = self.createTextBaseColumn(args)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2480 return _column
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2481 elif args[0] == "TYPE":
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2482 _column = self.createBaseColumn(args)
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2483 _type_cell1 = Gtk.CellRendererPixbuf()
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2484 _type_cell2 = Gtk.CellRendererText()
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2485 _type_cell2.set_property('foreground', args[3])
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2486 _column.pack_start(_type_cell1, True)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2487 _column.pack_start(_type_cell2, True)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2488 _column.add_attribute(_type_cell2, 'text', args[5])
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2489 _column.set_cell_data_func(_type_cell1,
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
2490 self._colorCell, args[4])
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2491 _column.set_cell_data_func(_type_cell2,
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
2492 self._colorCell, args[4])
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2493 return _column
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2494 elif args[0] == "PIXBUF":
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2495 _column = self.createBaseColumn(args)
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2496 _type_cell1 = Gtk.CellRendererPixbuf()
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2497 _column.pack_start(_type_cell1, True)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2498 _column.set_cell_data_func(_type_cell1,
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
2499 self._colorCell, args[4])
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2500 return _column
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2501 elif args[0] == "END":
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2502 _end_column = Gtk.TreeViewColumn()
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2503 _end_column.set_clickable(False)
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2504 _end_cell = Gtk.CellRendererText()
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2505 _end_cell.set_property('background',
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2506 globalVars.color["UNEVEN"])
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2507 _end_column.pack_start(_end_cell, True)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2508 return _end_column
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2509 return None
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2510
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
2511 def createTextBaseColumn(self, args):
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
2512 """createTextBaseColumn(args)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2513
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2514 args: tuple with the args
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2515 0.type:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2516 * float column
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2517 * text column
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2518 * calculated column
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2519 * calculated text
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2520 1. clicked method
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2521 2. width
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2522 3. text color
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2523 4. backgruound colors
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2524 5. model column index
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2525
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2526 Return a column and its CellREndererText
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2527 """
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2528 _column = self.createBaseColumn(args)
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2529 _cell = Gtk.CellRendererText()
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2530 _cell.set_property('foreground', args[3])
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2531 _column.pack_start(_cell, True)
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
2532 _column.set_cell_data_func(_cell, self._colorCell, args[4])
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2533 return _column, _cell
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2534
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
2535 def createBaseColumn(self, args):
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
2536 """createBaseColumn(args)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2537
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2538 args: tuple with the args
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2539 0.type:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2540 * index column
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2541 * float column
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2542 * text column
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2543 * calculated column
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2544 * calculated text column
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2545 * type column
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2546 1. clicked method
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2547 2. width
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2548 3. text color
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2549 4. backgruound colors
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2550 5. model column index
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2551
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2552 Return a column
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2553 """
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2554 _column = Gtk.TreeViewColumn()
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2555 _column.set_clickable(True)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2556 _column.connect("clicked", args[1])
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2557 _column.set_sizing(Gtk.TreeViewColumnSizing(2)) # 2 Fixed
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2558 _column.set_fixed_width(args[2])
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2559 _column.set_resizable(True)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2560 return _column
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2561
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
2562
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2563 class DecompositionList(TreeView):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2564 """gui.DecompositionList:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2565
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2566 Description:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2567 Class to show a budget Decomposition List
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2568 Constructor:
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2569 DecompositionList(budget, page, pane_path, path_record=None)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2570 budget: budget showed ("base.Budget" object)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2571 page: weak reference from Page instance which creates this class
10
d2cbc0278b30 bug fix: A except is raised when a user splits a pane, closes one of the new panes and splits again.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 9
diff changeset
2572 pane_path: tuple that represents the view path in the Page
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
2573 path_record: the record path that must be showed
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2574 Returns the newly created DecompositionList instance
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2575 Ancestry:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2576 +-- object
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2577 +-- TreeView
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2578 +-- DecompositionList
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2579 Atributes:
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
2580 budget: Read. Budget to show, base.obra object.
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2581 widget: Read. Window that contains the table, Gtk.ScrolledWindow
10
d2cbc0278b30 bug fix: A except is raised when a user splits a pane, closes one of the new panes and splits again.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 9
diff changeset
2582 pane_path: Read-Write. Pane page identifier
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2583 wr_page: Read-Write. weak ref from Page object which creates this class
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
2584 active_path_record: Read. Active path record
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2585 Methods:
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
2586 runMessage
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2587 """
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2588
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2589 def __init__(self, budget, wr_page, pane_path, path_record=None):
22
7bd4ca56607d bug fix: Mutable default arguments
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
2590 """__init__(budget, page, pane_path, path_record=None)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2591
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2592 budget: budget showed ("base.Budget" object)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2593 page: weak reference from Page instance which creates this class
10
d2cbc0278b30 bug fix: A except is raised when a user splits a pane, closes one of the new panes and splits again.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 9
diff changeset
2594 pane_path: tuple that represents the path of the List in the Page
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
2595 path_record: the record path that must be showed
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
2596
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
2597 self.__budget: budget showed ("base.Budget" object)
25
189f8274aecd gui. switch navigation menu on switch page
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 23
diff changeset
2598 self.__wr_page: weak reference from Page instance which creates self
10
d2cbc0278b30 bug fix: A except is raised when a user splits a pane, closes one of the new panes and splits again.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 9
diff changeset
2599 self.__pane_path: tuple that represents the path of the List in the Page
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
2600 self.__liststore: list model which store the list data
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2601 (Gtk.ListStore object)
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
2602 self.__active_path_record: the record path that must be showed
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
2603 self.__treeview: widget for displaying decomposition lists
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2604 (Gtk.TreeView)
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
2605 self.__scrolled_window: widget to contain the treeview object
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
2606 self.__chapter_background_colors: background colors of the Code
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
2607 column cells when there is a chapter record,
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2608 list of color [even cell, uneven cell]
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
2609 self.__chapter_background_colors
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2610 self.__index_column: Index column (Gtk.TreeViewColumn object)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2611 self.__code_column: Record code column (Gtk.TreeViewColumn)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2612 self.__type_column: Record Type column (Gtk.TreeViewColumn)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2613 self.__unit_column: Unit of measure column (Gtk.TreeViewColumn)
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
2614 self.__description_column: record's short description column
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2615 (Gtk.TreeViewColumn)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2616 self.__measure_column: Measure column (Gtk.TreeViewColumn)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2617 self.__price_column: Price column (Gtk.TreeViewColumn)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2618 self.__amount_column: Amount column(Gtk.TreeViewColumn)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2619 self.__end_column: End empty column (Gtk.TreeViewColumn)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2620 self.__chapter_icon: a GdkPixbuf.Pixbuf
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2621 self.__unit_icon: a GdkPixbuf.Pixbuf
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2622 self.__material_icon: a GdkPixbuf.Pixbuf
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2623 self.__machinery_icon: a GdkPixbuf.Pixbuf
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2624 self.__labourforce_icon: a GdkPixbuf.Pixbuf
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
2625 self.__treeselection: active selection
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
2626 self.__selection_control: state of the selection control (True/False)
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
2627 self.__cursor: cursor position in the table
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2628
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2629 Sets the init atributes
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2630 Creates the init list values in self.__liststore from the budget
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2631 showing the top record descomposition
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2632 Creates the list in self.__treeview
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2633 * Creates the columns and cell
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2634 * Sets te the column headers values
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2635 * Sets the selection properties
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2636 * Connects the events
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2637 """
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2638 # TODO: to group all columns in a dicctionary
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2639 # Budget
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2640 if not isinstance(budget, base.Budget):
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2641 raise ValueError( _("Argument must be a Budget object") )
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2642 self.__budget = budget
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2643 self.__wr_page = wr_page
10
d2cbc0278b30 bug fix: A except is raised when a user splits a pane, closes one of the new panes and splits again.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 9
diff changeset
2644 self.__pane_path = pane_path
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2645 # ListStore
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2646 self.__liststore = Gtk.ListStore(object
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2647 #, int, int, str, str, str, str, str,str
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2648 )
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2649 if path_record is None:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2650 path_record = (0,)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2651 self.__active_path_record = path_record
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
2652 self._setListstoreValues(self.__active_path_record)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2653 # Treeview
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2654 self.__treeview = Gtk.TreeView(self.__liststore)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2655 self.__treeview.set_enable_search(False)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2656 self.__treeview.set_reorderable(False)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2657 self.__treeview.set_headers_clickable(True)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2658 self.__treeview.show()
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2659 # Scrolled_window
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2660 self.__scrolled_window = Gtk.ScrolledWindow()
25
189f8274aecd gui. switch navigation menu on switch page
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 23
diff changeset
2661 # widget expand all space
189f8274aecd gui. switch navigation menu on switch page
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 23
diff changeset
2662 self.__scrolled_window.set_property("expand", True)
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2663 self.__scrolled_window.set_policy(Gtk.PolicyType(1),
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2664 Gtk.PolicyType(1)) # 1 Automatic
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2665 self.__scrolled_window.add(self.__treeview)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2666 # colors
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2667 _text_color = globalVars.color["TEXT"]
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2668 _background_color = [
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2669 globalVars.color["UNEVEN"],
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2670 globalVars.color["EVEN"]]
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2671 self.__chapter_background_colors = [
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2672 globalVars.color["CHAPTER-UNEVEN"],
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2673 globalVars.color["CHAPTER-EVEN"]]
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2674 super(DecompositionList,self).__init__(
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
2675 [("INDEX",self._selectAll,42),
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
2676 ("CALCULATEDTEXT", self._showParentRecord,
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2677 100, _text_color, _background_color),
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
2678 ("PIXBUF", self._showParentRecord, 26, _text_color,
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2679 _background_color),
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
2680 ("CALCULATEDTEXT", self._showParentRecord,
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2681 52, _text_color, _background_color),
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
2682 ("CALCULATEDTEXT", self._showParentRecord,
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2683 245, _text_color, _background_color),
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
2684 ("CALCULATED", self._showParentRecord,
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2685 90, _text_color, _background_color),
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
2686 ("CALCULATED", self._showParentRecord,
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2687 90, _text_color, _background_color),
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
2688 ("CALCULATED", self._showParentRecord,
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2689 90, globalVars.color["CALCULATED-TEXT"],
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2690 _background_color),
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2691 ])
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2692 self.__index_column = self.columns[0]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2693 self.__code_column = self.columns[1]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2694 self.__type_column = self.columns[2]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2695 self.__unit_column = self.columns[3]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2696 self.__description_column = self.columns[4]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2697 self.__measure_column = self.columns[5]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2698 self.__price_column = self.columns[6]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2699 self.__amount_column = self.columns[7]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2700 self.__end_column = self.columns[8]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2701 # Index column
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2702 self.__treeview.append_column(self.__index_column)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2703 # Code column
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2704 self.__treeview.append_column(self.__code_column)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2705 # Type column
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2706 self.__treeview.append_column(self.__type_column)
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2707 self.__chapter_icon = GdkPixbuf.Pixbuf.new_from_file(
6
2fc6b47dbe70 rename module globals to globalVars
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 5
diff changeset
2708 globalVars.getAppPath("CHAPTER-ICON"))
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2709 self.__unit_icon = GdkPixbuf.Pixbuf.new_from_file(
6
2fc6b47dbe70 rename module globals to globalVars
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 5
diff changeset
2710 globalVars.getAppPath("UNIT-ICON") )
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2711 self.__material_icon = GdkPixbuf.Pixbuf.new_from_file(
6
2fc6b47dbe70 rename module globals to globalVars
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 5
diff changeset
2712 globalVars.getAppPath("MATERIAL-ICON") )
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2713 self.__machinery_icon = GdkPixbuf.Pixbuf.new_from_file(
6
2fc6b47dbe70 rename module globals to globalVars
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 5
diff changeset
2714 globalVars.getAppPath("MACHINERY-ICON"))
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2715 self.__labourforce_icon = GdkPixbuf.Pixbuf.new_from_file(
6
2fc6b47dbe70 rename module globals to globalVars
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 5
diff changeset
2716 globalVars.getAppPath("LABOURFORCE-ICON"))
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2717 self.__type_column.get_cells()[0].set_property("pixbuf",
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
2718 self.__labourforce_icon)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2719 # Unit column
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2720 self.__treeview.append_column(self.__unit_column)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2721 # Description column
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2722 self.__treeview.append_column(self.__description_column)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2723 # Measure Column
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2724 self.__treeview.append_column(self.__measure_column)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2725 # Price column
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2726 self.__treeview.append_column(self.__price_column)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2727 # Amount column
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2728 self.__treeview.append_column(self.__amount_column)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2729 # End Column
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2730 self.__treeview.append_column(self.__end_column)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2731 # Connect
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
2732 self.__treeview.connect("row-activated", self._showRowRecord)
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
2733 self.__treeview.connect("move-cursor", self._moveCursor)
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
2734 self.__treeview.connect("key-press-event", self._treeviewKeyPressEvent)
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
2735 self.__treeview.connect("button-press-event",
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
2736 self._treeviewClickedEvent)
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
2737 self.__treeview.connect("cursor-changed", self._treeviewCursorChanged)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2738 # control selection
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2739 self.__treeselection = self.__treeview.get_selection()
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2740 self.__treeselection.set_mode(Gtk.SelectionMode(3)) # 3 MULTIPLE
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
2741 self.__treeselection.set_select_function(self._controlSelection)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2742 self.__selection_control = True
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2743 if len(self.__liststore) > 0:
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2744 _tree_path = Gtk.TreePath.new_from_indices((0,))
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2745 self.__treeview.set_cursor_on_cell(_tree_path ,self.__unit_column,
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2746 self.__unit_column.get_cells()[0],True)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2747 self.__treeview.grab_focus()
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2748 self.__cursor = self.__treeview.get_cursor()
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2749 # Show
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
2750 self._setColumnsHeaders()
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2751 self.__scrolled_window.show()
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2752
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
2753 def _treeviewCursorChanged(self, treeview):
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
2754 """_treeviewCursorChanged(treeview)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2755
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2756 treeview: treewiew widget
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2757 Method connected to "cursor-changed" signal
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2758 The "cursor-changed" signal is emitted when the cursor moves or is set
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2759 Sets the new cursor position in self.__cursor, it is used to avoid
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2760 unnecessary changes in cursor position.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2761 """
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2762 event = Gtk.get_current_event()
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2763 (_cursor_path, _column) = treeview.get_cursor()
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2764 if event is None or event.type != Gdk.EventType(7): # 7 BUTTON_RELEASE
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2765 if not _column is self.__index_column:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2766 self.__cursor = treeview.get_cursor()
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
2767
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
2768 def _treeviewClickedEvent(self, widget, event):
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
2769 """_treeviewClickedEvent(widget, event)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2770
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2771 widget: treewiew widget
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2772 event: clicked event
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2773 Method connected to "button-press-event" signal
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2774 The "button-press-event" signal is emitted when a mouse button is
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2775 pressed.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2776 Returns TRUE to stop other handlers from being invoked for the event.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2777 Returns FALSE to propagate the event further.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2778
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2779 The events in end column are ignored.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2780 If the user click in a row of the index column the cursor is moved to
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2781 this row but not to the index column
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2782 """
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2783 if event.button == 1:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2784 path_at_pos = self.__treeview.get_path_at_pos(int(event.x),
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2785 int(event.y))
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2786 if not path_at_pos is None:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2787 _path_cursor, _column, _x, _y = path_at_pos
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2788 if _column == self.columns[-1]:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2789 return True
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2790 if _column is self.columns[0]:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2791 self.__cursor[0] == _path_cursor
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2792 return False
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2793
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
2794 def _treeviewKeyPressEvent(self, widget, event):
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
2795 """_treeviewKeyPressEvent(widget, event)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2796
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2797 widget: treewiew widget
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2798 event: Key Press event
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2799 Method connected to "key-press-event" signal
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2800 The "key-press-event" signal is emitted when the user presses a key
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2801 on the keyboard.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2802 Returns :TRUE to stop other handlers from being invoked for the event.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2803 Returns :FALSE to propagate the event further.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2804
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2805 If the user press the right cursor button and the cursor is in the
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2806 amount column or pres the left cursor button and the cursor is
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2807 in the code column the event is estoped, else the event is propagated.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2808 """
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2809 (_cursor_path, _column) = self.__treeview.get_cursor()
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2810 if (event.keyval in [Gdk.keyval_from_name("Right"),
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2811 Gdk.keyval_from_name("KP_Right")] \
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2812 and _column == self.columns[-2]) \
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2813 or (event.keyval in [Gdk.keyval_from_name("Left"),
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2814 Gdk.keyval_from_name("KP_Left")] \
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2815 and _column == self.columns[1]):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2816 return True
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2817 return False
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2818
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
2819 def _moveCursor(self, treeview, step, count):
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
2820 """_moveCursor(treeview, step, count)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2821
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2822 treeview: the treeview that received the signal
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2823 step: the movement step size
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2824 count: the number of steps to take
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2825
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2826 Method connected to "move-cursor" signal
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2827 The "move-cursor" signal is emitted when the user moves the cursor
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2828 using the Right, Left, Up or Down arrow keys or the Page Up,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2829 Page Down, Home and End keys.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2830
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2831 Returns :TRUE if the signal was handled.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2832 """
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2833 return False
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2834
25
189f8274aecd gui. switch navigation menu on switch page
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 23
diff changeset
2835 def _controlSelection(self, selection, model, path,
189f8274aecd gui. switch navigation menu on switch page
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 23
diff changeset
2836 path_currently_selected, *data):
189f8274aecd gui. switch navigation menu on switch page
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 23
diff changeset
2837 """_controlSelection(selection, model, path,
189f8274aecd gui. switch navigation menu on switch page
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 23
diff changeset
2838 path_currently_selected, *data)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2839
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2840 selection: treeselection
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2841
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2842 Method connected to set_selection_function()
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2843 This method is called before any node is selected or unselected,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2844 giving some control over which nodes are selected.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2845 The selection function should return TRUE if the state
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2846 of the node may be toggled, and FALSE if the state of the node should
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2847 be left unchanged.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2848
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2849 The selection only run if the user click in the index column, else
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2850 the previous selection is erased.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2851 """
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2852 _column = self.__treeview.get_cursor()[1]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2853 if _column is self.columns[0] \
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2854 or self.__selection_control == False:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2855 return True
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2856 else:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2857 self.__selection_control = False
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2858 self.__treeselection.unselect_all()
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2859 self.__selection_control = True
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2860 return False
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2861
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
2862 def _selectAll(self, column):
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
2863 """_selectAll(column)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2864
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2865 column: index column
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2866 Method connected to "clicked" event in the index column
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2867 If the user clickes in the index column header selecs or deselects
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2868 all rows
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2869 """
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2870 (_model, _pathlist) = self.__treeselection.get_selected_rows()
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2871 # it avoid to set cursor in the index column
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2872 if isinstance(self.__cursor[0],Gtk.TreePath):
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2873 self.__treeview.set_cursor(self.__cursor[0], self.__cursor[1])
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2874 self.__selection_control = False
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2875 if len(_pathlist) == 0:
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2876 # select all
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2877 self.__treeselection.select_all()
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2878 else:
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2879 # unselect all
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2880 self.__treeselection.unselect_all()
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2881 self.__selection_control = True
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2882
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
2883 def _setColumnsHeaders(self):
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
2884 """_setColumnsHeaders()
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2885
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2886 Sets the headers column values
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2887 """
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2888 _path_record = self.__active_path_record
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2889 _number = _path_record[-1]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2890 _budget = self.__budget
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2891 _code = _budget.getCode(_path_record)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2892 _decomposition = _budget.getDecomposition(_path_record)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2893 _stryield = _budget.getStrYield(_decomposition.budgetMeasures[0],
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2894 _budget.getRecord(_code).recordType)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2895 _record = _budget.getRecord(_code)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2896 _unit = _record.unit
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2897 _description = _record.summary
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2898 _price = _budget.getStrPriceFromRecord(self.budget.getActiveTitle(),
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2899 _record, _path_record)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2900 # TODO: round to decimal places in amount
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2901 _amount = float(_stryield) * float(_price)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2902 if len(_path_record) == 1: # root record
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2903 _amount = _price
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2904 else:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2905 _parent_code = self.budget.getCode(self.__active_path_record[:-1])
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2906 _parent_record = self.__budget.getRecord(_parent_code)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2907 _amount = _budget.getStrAmount(self.__active_path_record)
25
189f8274aecd gui. switch navigation menu on switch page
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 23
diff changeset
2908 _str = _("Code") + chr(10) + "[" + _code.decode("utf8") + "]"
189f8274aecd gui. switch navigation menu on switch page
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 23
diff changeset
2909 self.__code_column.set_title(_str)
189f8274aecd gui. switch navigation menu on switch page
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 23
diff changeset
2910 _str = _("Unit") + chr(10) + "[" + _unit.decode("utf8") + "]"
189f8274aecd gui. switch navigation menu on switch page
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 23
diff changeset
2911 self.__unit_column.set_title(_str)
189f8274aecd gui. switch navigation menu on switch page
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 23
diff changeset
2912 _str = _("Description") + chr(10) + "[" + \
189f8274aecd gui. switch navigation menu on switch page
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 23
diff changeset
2913 _description.decode("utf8") + "]"
189f8274aecd gui. switch navigation menu on switch page
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 23
diff changeset
2914 self.__description_column.set_title(_str)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2915 self.__measure_column.set_title(
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2916 _("Measure") + chr(10) + "[" + _stryield + "]")
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2917 self.__price_column.set_title(
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2918 _("Price") + chr(10) + "[" + _price + "]")
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2919 self.__amount_column.set_title(
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2920 _("Amount") + chr(10) + "[" + str(_amount) + "]")
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2921
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
2922 def _setListstoreValues(self, path_record):
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
2923 """_setListstoreValues(path_record)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2924
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2925 path_record: Record path in the budget
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2926 Sets the liststore record values from a path record
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2927 """
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2928 self.__liststore.clear()
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2929 _budget = self.__budget
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2930 if not _budget.hasPath(path_record):
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2931 raise ValueError( _("Invalid path") )
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2932 else:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2933 _parent_code = _budget.getCode(path_record)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2934 for N,_code in enumerate(_budget.getchildren(_parent_code)):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2935 _decomposition = _budget.getNDecomposition(_parent_code, N)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2936 _record = _budget.getRecord(_code)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2937 _values = [_record,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2938 #_record.hierarchy,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2939 #_record.type,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2940 #_record.subtype,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2941 #_code,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2942 #_record.unit,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2943 #_record.summary,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2944 #_decomposition.yield_,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2945 #_decomposition.budget[0].yield_,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2946 #_record.prices[_budget.getActiveTitle()].prices]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2947 #_record.getPrice(_budget.getActiveTitle())
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2948 ]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2949 _treeiter = self.__liststore.append(_values)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2950
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
2951 def _colorCell(self, column, cell_renderer, tree_model, iter, lcolor):
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
2952 """_colorCell(column, cell_renderer, tree_model, iter, lcolor)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2953
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2954 column: the Gtk.TreeViewColumn in the treeview
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2955 cell_renderer: a Gtk.CellRenderer
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2956 tree_model: the Gtk.TreeModel
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2957 iter: Gtk.TreeIter pointing at the row
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2958 lcolor: list with 2 Gtk colors for even and uneven record
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2959
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2960 Method connected to "set_cell_data_func" of many column
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2961 The set_cell_data_func() method sets the data function (or method)
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2962 to use for the column Gtk.CellRenderer specified by cell_renderer.
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2963 This function (or method) is used instead of the standard attribute
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2964 mappings for setting the column values, and should set the attributes
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2965 of the cell renderer as appropriate. func may be None to remove the
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2966 current data function. The signature of func is:
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2967 -def celldatafunction(column, cell_renderer, tree_model, iter, lcolor)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2968 -def celldatamethod(self,column,cell_renderer,tree_model, iter, lcolor)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2969 where column is the Gtk.TreeViewColumn in the treeview, cell is the
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2970 Gtk.CellRenderer for column, model is the Gtk.TreeModel for the
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2971 treeview and iter is the Gtk.TreeIter pointing at the row.
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2972
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2973 The method sets cell background color and text for all columns.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2974 """
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2975 _row_path = tree_model.get_path(iter)
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2976 _global_row_path = self.__active_path_record + (_row_path[0],)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2977 _number = _row_path[-1]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2978 _record = tree_model[_row_path][0]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2979 if column is self.__index_column:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2980 cell_renderer.set_property('text', str(_number + 1))
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2981 self.__index_column.get_cells()[1].set_property(
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
2982 'cell-background', lcolor[_number % 2])
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2983 elif column is self.__code_column:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2984 # if the record is a chapter
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2985 if tree_model.get_value(iter, 0).recordType.hierarchy == 1:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2986 lcolor = self.__chapter_background_colors
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2987 _code = _record.code
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2988 cell_renderer.set_property('text', _code)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2989 elif column is self.__unit_column:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2990 _unit = _record.unit
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2991 cell_renderer.set_property('text', _unit)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2992 elif column is self.__description_column:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2993 _summary = _record.summary
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2994 cell_renderer.set_property('text', _summary)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2995 elif column is self.__measure_column:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2996 _parent_code = self.budget.getCode(self.__active_path_record)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2997 _parent_record = self.__budget.getRecord(_parent_code)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2998 _decomposition = _parent_record.children[_number]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
2999 _stryield = self.__budget.getStrYield(
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3000 _decomposition.budgetMeasures[0], _parent_record.recordType)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3001 cell_renderer.set_property('text', _stryield)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3002 elif column is self.__price_column:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3003 _price = self.budget.getStrPriceFromRecord(
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3004 self.budget.getActiveTitle(), _record, _global_row_path)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3005 cell_renderer.set_property('text', _price)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3006 elif column is self.__amount_column:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3007 _parent_code = self.budget.getCode(self.__active_path_record)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3008 _parent_record = self.__budget.getRecord(_parent_code)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3009 _amount = self.budget.getStrAmount(
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3010 self.__active_path_record + (_number,))
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3011 cell_renderer.set_property('text', str(_amount))
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3012 elif column is self.__type_column:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3013 _hierarchy = tree_model[_row_path][0].recordType.hierarchy
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3014 _type = tree_model[_row_path][0].recordType.type
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3015 _subtype = tree_model[_row_path][0].recordType.subtype
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3016 if _hierarchy == 1:
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
3017 cell_renderer.set_property("pixbuf",self.__chapter_icon)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3018 else:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3019 if _type == 0:
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
3020 cell_renderer.set_property("pixbuf",self.__unit_icon)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3021 elif _type == 1:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3022 cell_renderer.set_property("pixbuf",
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
3023 self.__labourforce_icon)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3024 elif _type == 2:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3025 cell_renderer.set_property("pixbuf",
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
3026 self.__machinery_icon)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3027 else:
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
3028 cell_renderer.set_property("pixbuf",self.__material_icon)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3029 if self.__treeview.get_cursor() == (_row_path,column):
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3030 cell_renderer.set_property('cell-background',
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3031 globalVars.color["ACTIVE"])
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3032 else:
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3033 cell_renderer.set_property('cell-background',
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3034 lcolor[_number % 2])
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3035
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
3036 def _showParentRecord(self, column):
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
3037 """_showParentRecord(column)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3038
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3039 column: the column that is clicked
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3040 Method connected to "clicked" event of many columns
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3041 Show the parent record
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3042 """
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3043 _budget = self.__budget
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3044 if len(self.__active_path_record) == 1:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3045 # The active record is the root record
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3046 # This avoid to move the cursor to the clicked column
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3047 if isinstance(self.__cursor[0],Gtk.TreePath):
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3048 self.__treeview.set_cursor(self.__cursor[0], self.__cursor[1])
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3049 else:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3050 _path_record = self.__active_path_record[:-1]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3051 _parent = self.__active_path_record[-1]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3052 self.__active_path_record = _path_record
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
3053 self._setColumnsHeaders()
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
3054 self._setListstoreValues(self.__active_path_record)
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3055 arg = _path_record
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3056 _page = self.__wr_page()
10
d2cbc0278b30 bug fix: A except is raised when a user splits a pane, closes one of the new panes and splits again.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 9
diff changeset
3057 _page.propagateMessageFrom("change_active", self.__pane_path, arg)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3058 self.__treeview.set_cursor(_parent, self.__cursor[1])
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3059 self.__cursor = self.__treeview.get_cursor()
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3060
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
3061 def _showMessageRecord(self, record_path):
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
3062 """_showMessageRecord(record_path)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3063
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3064 record_path: the path of the record to show
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3065 Method connected to "change_active" message
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3066 Show the record especified in the "change_active" message
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3067 """
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3068 _budget = self.__budget
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3069 self.__active_path_record = record_path
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
3070 self._setColumnsHeaders()
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
3071 self._setListstoreValues(self.__active_path_record)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3072 self.__treeview.set_cursor((0,))
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3073
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
3074 def _showRowRecord(self, treeview, treeview_path, column):
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
3075 """_showRowRecord(treeview, treeview_path, column)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3076
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3077 treeview: treview to show
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3078 treeview_path: the path of the record to show
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3079 code: the code of the record to show
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3080
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3081 Method connected to "row-activated" event
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3082 The "row-activated" signal is emitted when the row_activated() method
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3083 is called or the user double clicks a treeview row.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3084 "row-activated" is also emitted when a non-editable row is selected
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3085 and one of the keys: Space, Shift+Space, Return or Enter is pressed.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3086 Show the especified record
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3087 """
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3088 if not (column is self.__end_column) and \
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3089 not (column is self.__index_column):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3090 _budget = self.__budget
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3091 _model = treeview.get_model()
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3092 _iter = _model.get_iter(treeview_path)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3093 _code = _model.get_value(_iter, 0).code
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3094 _path_record = self.__active_path_record
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3095 for _indice in treeview_path.get_indices():
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3096 _path_record = _path_record + (_indice,)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3097 if self.__budget.hasPath(_path_record):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3098 # if this record path is valid
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3099 self.__active_path_record = _path_record
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
3100 self._setColumnsHeaders()
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
3101 self._setListstoreValues(self.__active_path_record)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3102 self.__treeview.set_cursor((0,))
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3103 _arg = _path_record
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3104 _page = self.__wr_page()
10
d2cbc0278b30 bug fix: A except is raised when a user splits a pane, closes one of the new panes and splits again.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 9
diff changeset
3105 _page.propagateMessageFrom("change_active", self.__pane_path,
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3106 _arg )
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3107
10
d2cbc0278b30 bug fix: A except is raised when a user splits a pane, closes one of the new panes and splits again.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 9
diff changeset
3108 def runMessage(self, message, pane_path, arg=None):
d2cbc0278b30 bug fix: A except is raised when a user splits a pane, closes one of the new panes and splits again.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 9
diff changeset
3109 """runMessage(message, pane_path, arg=None)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3110
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3111 message: the message type
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3112 "change_active": change the active record
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3113 "clear": clear instance
10
d2cbc0278b30 bug fix: A except is raised when a user splits a pane, closes one of the new panes and splits again.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 9
diff changeset
3114 pane_path: tuple that identifies the pane in the notebook page
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3115 arg: tuple whit two items:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3116 0: record path in the budget
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3117 1: record code
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3118 This method receives a message and executes its corresponding action
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3119 """
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3120 _budget = self.__budget
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3121 if message == "change_active":
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3122 if _budget.hasPath(arg):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3123 _path_record = arg
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
3124 self._showMessageRecord( _path_record)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3125 elif message == "clear":
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3126 self._clear()
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3127
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3128 def _clear(self):
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
3129 """_clear()
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
3130
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
3131 it deletes the __budget reference
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3132 """
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3133 del self.__budget
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3134
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
3135 def _getWidget(self):
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
3136 """_getWidget()
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3137
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3138 return the main widget (Gtk.ScrolledWindow)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3139 """
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3140 return self.__scrolled_window
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3141
10
d2cbc0278b30 bug fix: A except is raised when a user splits a pane, closes one of the new panes and splits again.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 9
diff changeset
3142 def _getPanePath(self):
d2cbc0278b30 bug fix: A except is raised when a user splits a pane, closes one of the new panes and splits again.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 9
diff changeset
3143 """_getPanePath()
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3144
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3145 return the tuple that identifies the pane in the notebook page
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3146 """
10
d2cbc0278b30 bug fix: A except is raised when a user splits a pane, closes one of the new panes and splits again.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 9
diff changeset
3147 return self.__pane_path
d2cbc0278b30 bug fix: A except is raised when a user splits a pane, closes one of the new panes and splits again.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 9
diff changeset
3148
d2cbc0278b30 bug fix: A except is raised when a user splits a pane, closes one of the new panes and splits again.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 9
diff changeset
3149 def _setPanePath(self, pane_path):
d2cbc0278b30 bug fix: A except is raised when a user splits a pane, closes one of the new panes and splits again.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 9
diff changeset
3150 """_setPanePath()
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3151
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3152 sets the tuple that identifies the pane in the notebook page
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3153 """
10
d2cbc0278b30 bug fix: A except is raised when a user splits a pane, closes one of the new panes and splits again.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 9
diff changeset
3154 self.__pane_path = pane_path
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3155
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3156 def _getWrPage(self):
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
3157 """_getPage()
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3158
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3159 return the Page
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3160 """
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3161 return self.__wr_page
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3162
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3163 def _setWrPage(self,wr_page):
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3164 """_setWrPage()
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3165
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3166 set the wr_Page
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3167 """
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3168 self.__wr_page = wr_page
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3169
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
3170 def _getBudget(self):
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
3171 """_getBudget()
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3172
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3173 return the Budget objet
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3174 """
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3175 return self.__budget
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3176
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
3177 def _getActivePathRecord(self):
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
3178 """_getActivePathRecord()
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3179
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3180 return the Active Path Record
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3181 """
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3182 return self.__active_path_record
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3183
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
3184 widget = property(_getWidget, None, None,
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3185 "Pane configuration list")
10
d2cbc0278b30 bug fix: A except is raised when a user splits a pane, closes one of the new panes and splits again.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 9
diff changeset
3186 pane_path = property(_getPanePath, _setPanePath, None,
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3187 "path that identifie the item in the page notebook")
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3188 wr_page = property(_getWrPage, _setWrPage, None,
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3189 "weak reference from Page instance which creates this class")
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
3190 budget = property(_getBudget, None, None,
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3191 "Budget object")
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
3192 active_path_record = property(_getActivePathRecord, None, None,
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3193 "Active path record")
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3194
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
3195
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3196 class Measure(TreeView):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3197 """gui.Measure:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3198
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3199 Description:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3200 Class to show a Measure List
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3201 Constructor:
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3202 Measure(budget, page, pane_path, path_record=None)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3203 budget: budget showed ("base.Budget" object)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3204 page: weak reference from Page instance which creates this class
10
d2cbc0278b30 bug fix: A except is raised when a user splits a pane, closes one of the new panes and splits again.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 9
diff changeset
3205 pane_path: tuple that represents the path of the List in the Page
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
3206 path_record: path of the active record in the budget
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3207 Ancestry:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3208 +-- object
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3209 +-- TreeView
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3210 +-- DecompositionList
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3211 Atributes:
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
3212 budget: Read. Budget to show, base.obra instance.
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3213 widget: Read. Window that contains the table, Gtk.ScrolledWindow
10
d2cbc0278b30 bug fix: A except is raised when a user splits a pane, closes one of the new panes and splits again.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 9
diff changeset
3214 pane_path: Read-Write. Pane page identifier
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3215 wr_page: Read-Write. weak reference from Page instance which creates
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
3216 this class
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
3217 active_path_record: Read. Path of the active record in the budget
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3218 Methods:
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
3219 runMessage
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3220 """
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3221
22
7bd4ca56607d bug fix: Mutable default arguments
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
3222 def __init__(self, budget, page, pane_path, path_record=None):
7bd4ca56607d bug fix: Mutable default arguments
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
3223 """__init__(budget, page, pane_path, path_record=None)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3224
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3225 budget: budget: budget showed ("base.Budget" object)
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3226 wr_page: weak reference from Page instance which creates this class
10
d2cbc0278b30 bug fix: A except is raised when a user splits a pane, closes one of the new panes and splits again.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 9
diff changeset
3227 pane_path: tuple that represents the path of the List in the Page
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3228 path_record: path of the active record in the budget
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3229
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
3230 self.__budget: budget showed ("base.Budget" object)
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
3231 self.__page: weak reference from Page instance which creates this class
10
d2cbc0278b30 bug fix: A except is raised when a user splits a pane, closes one of the new panes and splits again.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 9
diff changeset
3232 self.__pane_path: tuple that represents the path of the List in the Page
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
3233 self.__active_path_record: path of the active record in the budget
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
3234 self.__liststore: list model which store the list data
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3235 (Gtk.ListStore object)
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
3236 self.__treeview: widget to display decomposition lists
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3237 (Gtk.TreeView)
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
3238 self.__scrolled_window: widget to scroll the treeview
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3239 Gtk.ScrolledWindow()
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
3240 self.__chapter_background_colors: The background colors of the Code
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
3241 column cells when there is a chapter record
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3242 as a list of color [even cell, uneven cell]
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3243 self.__index_column: Index column (Gtk.TreeViewColumn object)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3244 self.__linetype_column: Linetype column (Gtk.TreeViewColumn object)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3245 self.__comment_column: Comment column (Gtk.TreeViewColumn)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3246 self.__unit_column: Unit column (Gtk.TreeViewColumn)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3247 self.__length_column: Legth column (Gtk.TreeViewColumn)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3248 self.__width_column: With column (Gtk.TreeViewColumn)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3249 self.__height_column: Height column (Gtk.TreeViewColumn)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3250 self.__formula_column: Formula column (Gtk.TreeViewColumn)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3251 self.__parcial_column: Parcial column (Gtk.TreeViewColumn)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3252 self.__subtotal_column: Subtotal column (Gtk.TreeViewColumn)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3253 self.__end_column: End empty column (Gtk.TreeViewColumn
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3254 self.__calculatedline_icon: GdkPixbuf.Pixbuf
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3255 self.__normalline_icon: GdkPixbuf.Pixbuf
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3256 self.__parcialline_icon: GdkPixbuf.Pixbuf
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3257 self.__acumulatedline_icon: GdkPixbuf.Pixbuf
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
3258 self.__treeselection: active selection
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
3259 self.__selection_control: state of the selection control (True/False)
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
3260 self.__cursor: Situation of the cursor in the table
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
3261
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3262 Sets the init atributes
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3263 Creates the init list values in self.__liststore from the budget
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3264 showing the top record from the record with path path_record
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3265 Creates the list in self.__treeview
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3266 * Creates the columns and cell
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3267 * Sets te the column headers values
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3268 * Sets the selection properties
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3269 * Connects the events
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3270 """
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3271 # Seting init args
22
7bd4ca56607d bug fix: Mutable default arguments
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
3272 if path_record is None:
7bd4ca56607d bug fix: Mutable default arguments
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
3273 path_record = (0,)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3274 if not isinstance(budget, base.Budget):
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3275 raise ValueError( _("Argument must be a Budget object") )
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3276 self.__budget = budget
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3277 self.__wr_page = page
10
d2cbc0278b30 bug fix: A except is raised when a user splits a pane, closes one of the new panes and splits again.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 9
diff changeset
3278 self.__pane_path = pane_path
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3279 if not isinstance(path_record, tuple):
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3280 print(_("Record path must be a tuple") )
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3281 path_record = (0,)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3282 self.__active_path_record = path_record
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3283 # ListStore
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3284 self.__liststore = Gtk.ListStore(object)
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
3285 self._setListstoreValues(self.__active_path_record)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3286 # Treeview
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3287 self.__treeview = Gtk.TreeView(self.__liststore)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3288 self.__treeview.set_enable_search(False)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3289 self.__treeview.set_reorderable(False)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3290 self.__treeview.set_headers_clickable(True)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3291 self.__treeview.show()
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3292 # Scrolled_window
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3293 self.__scrolled_window = Gtk.ScrolledWindow()
25
189f8274aecd gui. switch navigation menu on switch page
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 23
diff changeset
3294 # widget expand all space
189f8274aecd gui. switch navigation menu on switch page
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 23
diff changeset
3295 self.__scrolled_window.set_property("expand", True)
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3296 self.__scrolled_window.set_policy(Gtk.PolicyType(1),
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3297 Gtk.PolicyType(1)) # 1 Automatic
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3298 self.__scrolled_window.add(self.__treeview)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3299 # colors
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3300 _text_color = globalVars.color["TEXT"]
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3301 _calculated_text = globalVars.color["CALCULATED-TEXT"]
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3302 _background_color = [
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3303 globalVars.color["UNEVEN"],
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3304 globalVars.color["EVEN"]]
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3305 self.__chapter_background_colors = [
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3306 globalVars.color["CHAPTER-UNEVEN"],
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3307 globalVars.color["CHAPTER-EVEN"]]
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3308 super(Measure,self).__init__(
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
3309 [("INDEX",self._selectAll,42),
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3310 ("PIXBUF", self._passMethod, 40,
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3311 _text_color, _background_color),
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3312 ("CALCULATEDTEXT", self._passMethod, 128,
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3313 _text_color, _background_color),
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3314 ("CALCULATED", self._passMethod, 55,
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3315 _text_color, _background_color),
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3316 ("CALCULATED", self._passMethod, 70,
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3317 _text_color, _background_color),
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3318 ("CALCULATED", self._passMethod, 70,
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3319 _text_color, _background_color),
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3320 ("CALCULATED", self._passMethod, 70,
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3321 _text_color, _background_color),
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3322 ("CALCULATEDTEXT", self._passMethod, 120,
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3323 _text_color, _background_color),
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3324 ("CALCULATED", self._passMethod, 70,
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3325 _calculated_text, _background_color),
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3326 ("CALCULATED", self._passMethod, 70,
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3327 _calculated_text, _background_color),
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3328 ])
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
3329 # Colums
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3330 self.__index_column = self.columns[0]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3331 self.__linetype_column = self.columns[1]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3332 self.__comment_column = self.columns[2]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3333 self.__units_column = self.columns[3]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3334 self.__length_column = self.columns[4]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3335 self.__width_column = self.columns[5]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3336 self.__height_column = self.columns[6]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3337 self.__formula_column = self.columns[7]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3338 self.__parcial_column = self.columns[8]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3339 self.__subtotal_column = self.columns[9]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3340 self.__end_column = self.columns[10]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3341 # Index column
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3342 self.__treeview.append_column(self.__index_column)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3343 # Linetype column
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3344 self.__treeview.append_column(self.__linetype_column)
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3345 self.__calculatedline_icon = GdkPixbuf.Pixbuf.new_from_file(
6
2fc6b47dbe70 rename module globals to globalVars
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 5
diff changeset
3346 globalVars.getAppPath("CALCULATEDLINE-ICON"))
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3347 self.__normalline_icon = GdkPixbuf.Pixbuf.new_from_file(
6
2fc6b47dbe70 rename module globals to globalVars
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 5
diff changeset
3348 globalVars.getAppPath("NORMALLINE-ICON") )
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3349 self.__parcialline_icon = GdkPixbuf.Pixbuf.new_from_file(
6
2fc6b47dbe70 rename module globals to globalVars
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 5
diff changeset
3350 globalVars.getAppPath("PARCIALLINE-ICON") )
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3351 self.__acumulatedline_icon = GdkPixbuf.Pixbuf.new_from_file(
6
2fc6b47dbe70 rename module globals to globalVars
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 5
diff changeset
3352 globalVars.getAppPath("ACUMULATEDLINE-ICON"))
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3353 # Comment column
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3354 self.__treeview.append_column(self.__comment_column)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3355 # Units column
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3356 self.__treeview.append_column(self.__units_column)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3357 # Length column
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3358 self.__treeview.append_column(self.__length_column)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3359 # Width_column
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3360 self.__treeview.append_column(self.__width_column)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3361 # Height column
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3362 self.__treeview.append_column(self.__height_column)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3363 # Formula column
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3364 self.__treeview.append_column(self.__formula_column)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3365 # Parcial column
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3366 self.__treeview.append_column(self.__parcial_column)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3367 # Subtotal column
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3368 self.__treeview.append_column(self.__subtotal_column)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3369 # End Column
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3370 self.__treeview.append_column(self.__end_column)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3371 # Connect
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
3372 self.__treeview.connect("move-cursor", self._moveCursor)
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
3373 self.__treeview.connect("key-press-event", self._treeviewKeyPressEvent)
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
3374 self.__treeview.connect("button-press-event",
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
3375 self._treeviewClickedEvent)
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
3376 self.__treeview.connect("cursor-changed", self._treeviewCursorChanged)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3377 # control selection
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3378 self.__treeselection = self.__treeview.get_selection()
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3379 self.__treeselection.set_mode(Gtk.SelectionMode(3)) # 3 MULTIPLE
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
3380 self.__treeselection.set_select_function(self._controlSelection)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3381 self.__selection_control = True
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3382 if len(self.__liststore) > 0:
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3383 _tree_path = Gtk.TreePath.new_from_indices((1,))
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3384 self.__treeview.set_cursor_on_cell(_tree_path, self.columns[1],
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3385 self.columns[1].get_cells()[0],True)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3386 self.__treeview.grab_focus()
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3387 self.__cursor = self.__treeview.get_cursor()
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3388 # Show
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
3389 self._setColumnsHeaders()
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3390 self.__scrolled_window.show()
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
3391
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
3392 def _treeviewCursorChanged(self, treeview):
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
3393 """_treeviewCursorChanged(treeview)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3394
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3395 treeview: treewiew widget
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3396 Method connected to "cursor-changed" signal
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3397 The "cursor-changed" signal is emitted when the cursor moves or is set
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3398 Sets the new cursor position in self.__cursor, it is used to avoid
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3399 unnecessary changes in cursor position.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3400 """
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3401 event = Gtk.get_current_event()
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3402 (_cursor_path, _column) = treeview.get_cursor()
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3403 if event is None or event.type != Gdk.EventType(7): # 7 BUTTON_RELEASE
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3404 if not _column is self.__index_column:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3405 self.__cursor = treeview.get_cursor()
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3406
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
3407 def _treeviewClickedEvent(self, widget, event):
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
3408 """_treeviewClickedEvent(widget, event)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3409
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3410 widget: treewiew widget
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3411 event: clicked event
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3412 Method connected to "button-press-event" signal
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3413 The "button-press-event" signal is emitted when a mouse button is
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3414 pressed.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3415 Returns TRUE to stop other handlers from being invoked for the event.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3416 Returns FALSE to propagate the event further.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3417
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3418 The events in end column are ignored.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3419 If the user click in a row of the index column the cursor is moved to
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3420 this row but not to the index column
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3421 """
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3422 if event.button == 1:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3423 path_at_pos = self.__treeview.get_path_at_pos(int(event.x),
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3424 int(event.y))
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3425 if not path_at_pos is None:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3426 _path_cursor, _column, _x, _y = path_at_pos
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3427 if _column == self.columns[-1]:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3428 return True
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3429 if _column is self.columns[0]:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3430 self.__cursor[0] == _path_cursor
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3431 return False
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3432
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
3433 def _treeviewKeyPressEvent(self, widget, event):
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
3434 """_treeviewKeyPressEvent(widget, event)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3435
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3436 widget: treewiew widget
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3437 event: Key Press event
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3438 Method connected to "key-press-event" signal
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3439 The "key-press-event" signal is emitted when the user presses a key
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3440 on the keyboard.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3441 Returns :TRUE to stop other handlers from being invoked for the event.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3442 Returns :FALSE to propagate the event further.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3443
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3444 If the user press the right cursor button and the cursor is in the
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3445 amount column or pres the left cursor button and the cursor is
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3446 in the code column the event is estoped, else the event is propagated.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3447 """
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3448 (_cursor_path, _column) = self.__treeview.get_cursor()
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3449 if (event.keyval in [Gdk.keyval_from_name("Right"),
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3450 Gdk.keyval_from_name("KP_Right")] \
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3451 and _column == self.columns[-2]) \
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3452 or (event.keyval in [Gdk.keyval_from_name("Left"),
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3453 Gdk.keyval_from_name("KP_Left")] \
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3454 and _column == self.columns[1]):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3455 return True
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3456 return False
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3457
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3458 def _moveCursor(self, treeview, step, count):
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3459 """moveCursor(treeview, step, count)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3460
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3461 treeview: the treeview that received the signal
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3462 step: the movement step size
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3463 count: the number of steps to take
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3464
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3465 Method connected to "move-cursor" signal
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3466 The "move-cursor" signal is emitted when the user moves the cursor
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3467 using the Right, Left, Up or Down arrow keys or the Page Up,
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3468 Page Down, Home and End keys.
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3469
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3470 Returns :TRUE if the signal was handled.
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3471 """
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3472 return False
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3473
25
189f8274aecd gui. switch navigation menu on switch page
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 23
diff changeset
3474 def _controlSelection(self, selection, model, path,
189f8274aecd gui. switch navigation menu on switch page
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 23
diff changeset
3475 path_currently_selected, *data):
189f8274aecd gui. switch navigation menu on switch page
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 23
diff changeset
3476 """_controlSelection(selection, model, path,
189f8274aecd gui. switch navigation menu on switch page
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 23
diff changeset
3477 path_currently_selected, *data)
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3478
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3479 selection: treeselection
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3480
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3481 Method connected to set_selection_function()
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3482 This method is called before any node is selected or unselected,
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3483 giving some control over which nodes are selected.
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3484 The selection function should return TRUE if the state
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3485 of the node may be toggled, and FALSE if the state of the node should
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3486 be left unchanged.
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3487
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3488 The selection only run if the user click in the index column, else
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3489 the previous selection is erased.
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3490 """
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3491 _column = self.__treeview.get_cursor()[1]
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3492 if _column is self.columns[0] \
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3493 or self.__selection_control == False:
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3494 return True
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3495 else:
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3496 self.__selection_control = False
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3497 self.__treeselection.unselect_all()
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3498 self.__selection_control = True
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3499 return False
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3500
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3501 def _selectAll(self, column):
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3502 """_selectAll(column)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3503
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3504 column: index column
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3505 Method connected to "clicked" event in the index column
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3506 If the user clickes in the index column header selecs or deselects
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3507 all rows
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3508 """
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3509 (_model, _pathlist) = self.__treeselection.get_selected_rows()
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3510 # it avoid to set cursor in the index column
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3511 if isinstance(self.__cursor[0],Gtk.TreePath):
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3512 self.__treeview.set_cursor(self.__cursor[0], self.__cursor[1])
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3513 self.__selection_control = False
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3514 if len(_pathlist) == 0:
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3515 # select all
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3516 self.__treeselection.select_all()
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3517 else:
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3518 # unselect all
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3519 self.__treeselection.unselect_all()
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3520 self.__selection_control = True
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3521
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3522 def _setColumnsHeaders(self):
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3523 """_setColumnsHeaders()
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3524
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3525 Sets the headers column values
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3526 """
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3527 _measure = self.__budget.getMeasure(self.__active_path_record)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3528 _DS = self.__budget.getDecimals("DS")
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3529 _total = _measure.measure
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3530 _total_str = ("%." + str(abs(_DS)) + "f" ) % _total
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3531 self.columns[1].set_title(_("Type")) # Σ parcial Σ total
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3532 self.columns[2].set_title(_("Comment"))
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3533 self.columns[3].set_title(_("N\n(a)"))
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3534 self.columns[4].set_title(_("Length\n(b)"))
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3535 self.columns[5].set_title(_("Width\n(c)"))
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3536 self.columns[6].set_title(_("Height\n(d)"))
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3537 self.columns[7].set_title(_("Formula"))
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3538 self.columns[8].set_title(_("Parcial\n[%s]" % _total_str))
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3539 self.columns[9].set_title(_("Subtotal"))
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3540
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3541 def _setListstoreValues(self, path_record):
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3542 """_setListstoreValues(path_record)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3543
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3544 path_record: Record path in the budget
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3545 Sets the liststore record values from a path record
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3546 """
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3547 self.__liststore.clear()
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3548 _budget = self.__budget
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3549 if not _budget.hasPath(path_record):
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3550 raise ValueError( _("Invalid path") )
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3551 else:
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3552 _measure = _budget.getMeasure(path_record)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3553 if isinstance(_measure, base.Measure):
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3554 _lines = _measure.lines
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3555 for _line in _lines:
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3556 _values = [ _line ]
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3557 _treeiter = self.__liststore.append(_values)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3558 else:
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3559 raise ValueError( utils.mapping(_("measure must be a Measure "\
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3560 "object. Type: $1"), (str(type(_measure)),)) )
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3561
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3562 def _colorCell(self, column, cell_renderer, tree_model, iter, lcolor):
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3563 """_colorCell(column, cell_renderer, tree_model, iter, lcolor)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3564
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3565 column: the Gtk.TreeViewColumn in the treeview
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3566 cell_renderer: a Gtk.CellRenderer
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3567 tree_model: the Gtk.TreeModel
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3568 iter: Gtk.TreeIter pointing at the row
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3569 lcolor: list with 2 colors for even and uneven record
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3570
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3571 Method connected to "set_cell_data_func" of many column
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3572 The set_cell_data_func() method sets the data function (or method)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3573 to use for the column Gtk.CellRenderer specified by cell_renderer.
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3574 This function (or method) is used instead of the standard attribute
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3575 mappings for setting the column values, and should set the attributes
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3576 of the cell renderer as appropriate. func may be None to remove the
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3577 current data function. The signature of func is:
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3578 -def celldatafunction(column, cell, model, iter, user_data)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3579 -def celldatamethod(self, column, cell, model, iter, user_data)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3580 where column is the Gtk.TreeViewColumn in the treeview, cell is the
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3581 Gtk.CellRenderer for column, model is the Gtk.TreeModel for the
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3582 treeview and iter is the Gtk.TreeIter pointing at the row.
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3583
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3584 The method sets cell background color for all columns
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3585 and text for index and amount columns.
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3586 """
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3587 _row_path = tree_model.get_path(iter)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3588 _number = _row_path[-1]
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3589 if column is self.__index_column:
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3590 cell_renderer.set_property('text', str(_number + 1))
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3591 self.__index_column.get_cells()[1].set_property(
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3592 'cell-background', lcolor[_number % 2])
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3593 elif column is self.__linetype_column:
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3594 _measure = tree_model[_row_path][0]
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3595 _type = _measure.lineType
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3596 if _type == 0:
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3597 cell_renderer.set_property("pixbuf",self.__normalline_icon)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3598 elif _type == 1:
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3599 cell_renderer.set_property("pixbuf",self.__parcialline_icon)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3600 elif _type == 2:
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3601 cell_renderer.set_property("pixbuf",
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3602 self.__acumulatedline_icon)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3603 else: #elif _type == 3:
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3604 cell_renderer.set_property("pixbuf",
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3605 self.__calculatedline_icon)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3606 elif column is self.__comment_column:
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3607 _measure = tree_model[_row_path][0]
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3608 _comment = str(_measure.comment)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3609 cell_renderer.set_property('text', _comment)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3610 elif column is self.__units_column:
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3611 _measure = tree_model[_row_path][0]
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3612 _units = _measure.units
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3613 if isinstance(_units, float):
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3614 _DN = self.__budget.getDecimals("DN")
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3615 _units = ("%." + str(abs(_DN)) + "f" ) % _units
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3616 cell_renderer.set_property('text', _units)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3617 elif column is self.__length_column:
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3618 _measure = tree_model[_row_path][0]
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3619 _length = _measure.length
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3620 if isinstance(_length, float):
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3621 _DD = self.__budget.getDecimals("DD")
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3622 _length = ("%." + str(abs(_DD)) + "f" ) % _length
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3623 cell_renderer.set_property('text', _length)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3624 elif column is self.__width_column:
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3625 _measure = tree_model[_row_path][0]
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3626 _width = _measure.width
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3627 if isinstance(_width, float):
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3628 _DD = self.__budget.getDecimals("DD")
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3629 _width = ("%." + str(abs(_DD)) + "f" ) % _width
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3630 cell_renderer.set_property('text', _width)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3631 elif column is self.__height_column:
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3632 _measure = tree_model[_row_path][0]
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3633 _height = _measure.height
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3634 if isinstance(_height, float):
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3635 _DD = self.__budget.getDecimals("DD")
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3636 _height = ("%." + str(abs(_DD)) + "f" ) % _height
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3637 cell_renderer.set_property('text', _height)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3638 elif column is self.__formula_column:
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3639 _measure = tree_model[_row_path][0]
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3640 _formula = _measure.formula
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3641 cell_renderer.set_property('text', _formula)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3642 elif column is self.__parcial_column:
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3643 _measure_line = tree_model[_row_path][0]
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3644 _parcial = _measure_line.parcial
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3645 _type = _measure_line.lineType
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3646 if _type == 1 or _type == 2:
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3647 _parcial = ""
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3648 else:
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3649 if isinstance(_parcial, float):
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3650 _DS = self.__budget.getDecimals("DS")
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3651 _parcial = ("%." + str(abs(_DS)) + "f" ) % _parcial
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3652 cell_renderer.set_property('text', _parcial)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3653 elif column is self.__subtotal_column:
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3654 _measure_line = tree_model[_row_path][0]
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3655 _type = _measure_line.lineType
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3656 if _type == 1 or _type == 2:
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3657 if _type == 1:
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3658 _color = globalVars.color["SUBTOTAL-PARCIAL"]
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3659 _subtotal = _measure_line.parcial_subtotal
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3660 else: #elif _type == 2:
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3661 _color = globalVars.color["SUBTOTAL"]
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3662 _subtotal = _measure_line.acumulated_subtotal
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3663 lcolor = [_color, _color]
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3664 if isinstance(_subtotal, float):
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3665 _DS = self.__budget.getDecimals("DS")
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3666 _subtotal= ("%." + str(abs(_DS)) + "f" ) % _subtotal
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3667 cell_renderer.set_property('text', _subtotal)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3668 else:
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3669 cell_renderer.set_property('text', "")
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3670
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3671 if self.__treeview.get_cursor() == (_row_path,column):
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3672 cell_renderer.set_property('cell-background',
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3673 globalVars.color["ACTIVE"])
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3674 else:
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3675 cell_renderer.set_property('cell-background',
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3676 lcolor[_number % 2])
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3677
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3678 def _passMethod(self, column):
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3679 """_passMethod(column)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3680
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3681 column: the column that is clicked
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3682 Method connected to "clicked" event of many columns
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3683 Do nothing
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3684 """
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3685 pass
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3686
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3687 def _showMessageRecord(self, record_path):
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3688 """_showMessageRecord(record_path)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3689
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3690 record_path: the path of the record to show
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3691 Method connected to "change_active" message
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3692 Show the record especified in the "change_active" message
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3693 """
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3694 _budget = self.__budget
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3695 self.__active_path_record = record_path
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3696 self._setColumnsHeaders()
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3697 self._setListstoreValues(self.__active_path_record)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3698 self.__treeview.set_cursor((0,))
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3699
10
d2cbc0278b30 bug fix: A except is raised when a user splits a pane, closes one of the new panes and splits again.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 9
diff changeset
3700 def runMessage(self, message, pane_path, arg=None):
d2cbc0278b30 bug fix: A except is raised when a user splits a pane, closes one of the new panes and splits again.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 9
diff changeset
3701 """runMessage(message, pane_path, arg=None)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3702
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3703 message: the message type
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3704 "change_active": change the active record
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3705 "clear": clear instance
10
d2cbc0278b30 bug fix: A except is raised when a user splits a pane, closes one of the new panes and splits again.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 9
diff changeset
3706 pane_path: tuple that identifies the pane in the notebook page
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3707 arg: tuple whit two items:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3708 0: record path in the budget
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3709 1: record code
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3710 This method receives a message and executes its corresponding action
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3711 """
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3712 _budget = self.__budget
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3713 if message == "change_active":
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3714 if _budget.hasPath(arg):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3715 _path_record = arg
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
3716 self._showMessageRecord( _path_record)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3717 elif message == "clear":
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3718 self._clear()
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3719
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3720 def _clear(self):
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
3721 """_clear()
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3722
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3723 it deletes the __budget value
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3724 """
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3725 del self.__budget
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3726
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
3727 def _getWidget(self):
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
3728 """_getWidget()
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3729
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3730 return the main widget (Gtk.ScrolledWindow)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3731 """
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3732 return self.__scrolled_window
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3733
10
d2cbc0278b30 bug fix: A except is raised when a user splits a pane, closes one of the new panes and splits again.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 9
diff changeset
3734 def _getPanePath(self):
d2cbc0278b30 bug fix: A except is raised when a user splits a pane, closes one of the new panes and splits again.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 9
diff changeset
3735 """_getPanePath()
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3736
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3737 return the tuple that identifies the pane in the notebook page
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3738 """
10
d2cbc0278b30 bug fix: A except is raised when a user splits a pane, closes one of the new panes and splits again.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 9
diff changeset
3739 return self.__pane_path
d2cbc0278b30 bug fix: A except is raised when a user splits a pane, closes one of the new panes and splits again.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 9
diff changeset
3740
d2cbc0278b30 bug fix: A except is raised when a user splits a pane, closes one of the new panes and splits again.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 9
diff changeset
3741 def _setPanePath(self, pane_path):
d2cbc0278b30 bug fix: A except is raised when a user splits a pane, closes one of the new panes and splits again.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 9
diff changeset
3742 """_setPanePath()
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3743
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3744 sets the tuple that identifies the pane in the notebook page
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3745 """
10
d2cbc0278b30 bug fix: A except is raised when a user splits a pane, closes one of the new panes and splits again.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 9
diff changeset
3746 self.__pane_path = pane_path
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
3747
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3748 def _getWrPage(self):
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
3749 """_getPage()
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3750
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3751 return the Page
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3752 """
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3753 return self.__wr_page
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3754
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3755 def _setWrPage(self,wr_page):
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
3756 """_setPage()
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3757
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3758 set the Page
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3759 """
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3760 self.__wr_page = wr_page
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3761
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
3762 def _getBudget(self):
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
3763 """_getBudget()
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3764
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3765 return the Budget objet
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3766 """
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3767 return self.__budget
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3768
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
3769 def _getActivePathRecord(self):
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
3770 """getActivePathRecord()
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3771
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3772 return the Active Path Record
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3773 """
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3774 return self.__active_path_record
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3775
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
3776 widget = property(_getWidget, None, None,
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3777 "Pane configuration list")
10
d2cbc0278b30 bug fix: A except is raised when a user splits a pane, closes one of the new panes and splits again.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 9
diff changeset
3778 pane_path = property(_getPanePath, _setPanePath, None,
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3779 "Path that identifies the item in the page notebook")
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3780 wr_page = property(_getWrPage, _setWrPage, None,
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3781 "Weak reference from Page instance which creates this class")
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
3782 budget = property(_getBudget, None, None,
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3783 "Budget object")
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
3784 active_path_record = property(_getActivePathRecord, None, None,
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3785 "Active Code")
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3786
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
3787
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3788 class Description(object):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3789 """gui.Description
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3790
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3791 Description:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3792 Class to show a description text of a record in a pane
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3793 Constructor:
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3794 budget: budget showed ("base.Budget" object)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3795 page: weak reference from Page instance which creates this class
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3796 pane_path: tuple that represents the view path in the Page
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3797 path_record: the record path that must be showed
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3798 Returns the newly created DecompositionList instance
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3799 Ancestry:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3800 +-- object
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3801 +-- Description
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3802 Atributes:
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3803 budget: Read. Budget to show, base.obra object.
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3804 widget: the main widget (Gtk.ScrolledWindow object)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3805 pane_path: Read-Write. Pane page identifier
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3806 wr_page: Read-Write. weak ref from Page object which creates this class
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3807 active_path_record: Read. Active path record
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3808 Methods:
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
3809 runMessage
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3810 """
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3811 # TODO: make standard: "DecompositonList and Description"
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3812
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3813 def __init__(self, budget, wr_page, pane_path, path_record=None):
22
7bd4ca56607d bug fix: Mutable default arguments
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
3814 """__init__(budget, page, pane_path, path_record=None)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3815
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3816 budget: the budget (base.obra object)
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3817 wr_page: weak reference from Page instance which creates this class
10
d2cbc0278b30 bug fix: A except is raised when a user splits a pane, closes one of the new panes and splits again.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 9
diff changeset
3818 pane_path: the path position of the description in the page
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3819 path_record: the path of the active record
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3820
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
3821 self.__budget: the budget (base.obra object)
25
189f8274aecd gui. switch navigation menu on switch page
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 23
diff changeset
3822 self.__wr_page: weak reference from Page instance which creates self
10
d2cbc0278b30 bug fix: A except is raised when a user splits a pane, closes one of the new panes and splits again.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 9
diff changeset
3823 self.__pane_path: the path position of the description in the page
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
3824 self.__active_path_recordthe path of the active record
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
3825
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
3826 self.__textbuffer: The textbuffer of the textview that contain
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
3827 the record text.
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3828 self.__label: The Gtk.label with the title of the pane
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3829 self.__widget: the main pane widget, a Gtk.ScrolledWindow()
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
3830
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3831 Creates an shows the scroledwindow that contain the description text
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3832 of the record to be showed in a pane.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3833 """
22
7bd4ca56607d bug fix: Mutable default arguments
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
3834 if path_record is None:
7bd4ca56607d bug fix: Mutable default arguments
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
3835 path_record = (0,)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3836 self.__budget = budget
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3837 self.__wr_page = wr_page
10
d2cbc0278b30 bug fix: A except is raised when a user splits a pane, closes one of the new panes and splits again.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 9
diff changeset
3838 self.__pane_path = pane_path
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3839 self.__active_path_record = path_record
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3840 _budget = budget
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3841 _text = _budget.getRecord(self.__budget.getCode(
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3842 self.__active_path_record)).text
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3843 _scrollwindow = Gtk.ScrolledWindow()
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3844 _scrollwindow.set_property("expand", True) # widget expand all space
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3845 _scrollwindow.set_policy(Gtk.PolicyType(1),
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3846 Gtk.PolicyType(1)) # 1 Automatic
25
189f8274aecd gui. switch navigation menu on switch page
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 23
diff changeset
3847 _scrollwindow.set_shadow_type(1) # IN 1
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3848 _textview = Gtk.TextView()
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3849 _textview.set_wrap_mode(2) # 2 Word
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3850 _textview.set_hexpand(True)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3851 _textview.set_vexpand(True)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3852 self.__textbuffer = _textview.get_buffer()
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3853 self.__textbuffer.set_text(_text)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3854 _textview.show()
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3855 _vbox = Gtk.Grid()
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3856 _vbox.set_orientation(Gtk.Orientation(1)) # 1 Vertical
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3857 self.__label = Gtk.Label(utils.mapping(_("Description text of the "\
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3858 "record $1"), (str(self.__budget.getCode(
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3859 self.__active_path_record)),)))
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3860 self.__label.set_alignment(0, 0)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3861 self.__label.show()
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3862 _vbox.add(self.__label)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3863 _vbox.add(_textview)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3864 _vbox.show()
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3865 _scrollwindow.add(_vbox)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3866 _scrollwindow.show()
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3867 self.__widget = _scrollwindow
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3868
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
3869 def _setActivePathRecord(self, path_record):
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
3870 """_setActivePathRecord(path_record))
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3871
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3872 path_record: active path record
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3873 Set the new path code to show its description text.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3874 """
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3875 _budget = self.__budget
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3876 self.__active_path_record = path_record
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3877 _code = _budget.getCode(self.__active_path_record)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3878 self.__label.set_text(utils.mapping(_("Description text of the record "\
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3879 "$1"), (_code.decode("utf8"),)))
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3880 _text = _budget.getRecord(_code).text
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3881 self.__textbuffer.set_text(_text)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3882
10
d2cbc0278b30 bug fix: A except is raised when a user splits a pane, closes one of the new panes and splits again.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 9
diff changeset
3883 def runMessage(self, message, pane_path, arg=None):
d2cbc0278b30 bug fix: A except is raised when a user splits a pane, closes one of the new panes and splits again.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 9
diff changeset
3884 """runMessage(message, pane_path, arg=None)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3885
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3886 message: the message type
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3887 "change_active": change the active record
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3888 "clear": clear instance
10
d2cbc0278b30 bug fix: A except is raised when a user splits a pane, closes one of the new panes and splits again.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 9
diff changeset
3889 pane_path: tuple that identifies the pane in the notebook page
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3890 arg: tuple whit two items:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3891 0: record path in the budget
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3892 1: record code
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3893 This method receives a message and executes its corresponding action
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3894 """
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3895 _budget = self.__budget
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3896 if message == "change_active":
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3897 if _budget.hasPath(arg):
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
3898 self._setActivePathRecord(arg)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3899 elif message == "clear":
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3900 self._clear()
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3901
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3902 def _clear(self):
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
3903 """_clear()
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3904
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3905 Delete all instance atributes
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3906 """
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3907 del self.__widget
10
d2cbc0278b30 bug fix: A except is raised when a user splits a pane, closes one of the new panes and splits again.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 9
diff changeset
3908 del self.__pane_path
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3909 del self.__budget
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3910 del self.__active_code
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3911 del self.__textbuffer
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3912 del self.__label
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3913
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
3914 def _getWidget(self):
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
3915 """_getWidget()
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3916
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3917 return the main widget (Gtk.ScrolledWindow)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3918 """
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3919 return self.__widget
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3920
10
d2cbc0278b30 bug fix: A except is raised when a user splits a pane, closes one of the new panes and splits again.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 9
diff changeset
3921 def _getPanePath(self):
d2cbc0278b30 bug fix: A except is raised when a user splits a pane, closes one of the new panes and splits again.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 9
diff changeset
3922 """_getPanePath()
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3923
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3924 return the tuple that identifies the pane in the notebook page
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3925 """
10
d2cbc0278b30 bug fix: A except is raised when a user splits a pane, closes one of the new panes and splits again.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 9
diff changeset
3926 return self.__pane_path
d2cbc0278b30 bug fix: A except is raised when a user splits a pane, closes one of the new panes and splits again.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 9
diff changeset
3927
d2cbc0278b30 bug fix: A except is raised when a user splits a pane, closes one of the new panes and splits again.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 9
diff changeset
3928 def _setPanePath(self, pane_path):
d2cbc0278b30 bug fix: A except is raised when a user splits a pane, closes one of the new panes and splits again.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 9
diff changeset
3929 """_setPanePath()
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3930
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3931 sets the tuple that identifies the pane in the notebook page
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3932 """
10
d2cbc0278b30 bug fix: A except is raised when a user splits a pane, closes one of the new panes and splits again.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 9
diff changeset
3933 self.__pane_path = pane_path
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3934
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3935 def _getWrPage(self):
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3936 """_getWrPage()
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3937
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3938 return the weak reference from Page instance
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3939 """
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3940 return self.__wr_page
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3941
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3942 def _setWrPage(self, wr_page):
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3943 """_setWrPage()
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3944
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3945 set the weak reference from Page instance
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3946 """
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3947 self.__wr_page = wr_page
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3948
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
3949 def _getBudget(self):
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
3950 """_getBudget()
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3951
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3952 return the budget object
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3953 """
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3954 return self.__budget
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3955
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
3956 def _getActivePathRecord(self):
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
3957 """_getActivePathRecord()
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3958
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3959 return the Active Path Record
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3960 """
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3961 return self.__active_path_record
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3962
10
d2cbc0278b30 bug fix: A except is raised when a user splits a pane, closes one of the new panes and splits again.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 9
diff changeset
3963 pane_path = property(_getPanePath, _setPanePath, None,
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3964 "Path that identifie the item in the page notebook")
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
3965 widget = property(_getWidget, None, None,
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3966 "The main widget (Gtk.ScrolledWindow)")
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3967 wr_page = property(_getWrPage, _setWrPage, None,
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3968 "Weak reference from Page instance which creates this class")
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
3969 budget = property(_getBudget, None, None,
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3970 "Budget object")
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
3971 active_path_record = property(_getActivePathRecord, None, None,
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3972 "Active Path Record")
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3973
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
3974
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3975 class Sheet(object):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3976 """gui.Sheet
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3977
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3978 Description:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3979 Class to show a sheeet of conditions text of a record in a pane
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3980 Constructor:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3981 Sheet(budget, code)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3982 budget: budget object
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3983 code: code record
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3984 Ancestry:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3985 +-- object
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3986 +-- Sheet
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3987 Atributes:
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3988 budget: The budget (base.obra objetc)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3989 widget: the main widget (Gtk.Grid object)
10
d2cbc0278b30 bug fix: A except is raised when a user splits a pane, closes one of the new panes and splits again.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 9
diff changeset
3990 pane_path: the tuple that identifies the pane in the notebook page
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3991 wr_page: weak reference from Page instance which creates this class
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
3992 active_path_record: The active path record
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3993 Methods:
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
3994 runMessage
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3995 """
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
3996
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3997 def __init__(self, budget, wr_page, pane_path, path_record=None):
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
3998 """__init__(budget, wr_page, pane_path, path_record=None)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
3999
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4000 budget: the budget (base.obra object)
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4001 wr_page: weak reference from Page instance which creates this class
10
d2cbc0278b30 bug fix: A except is raised when a user splits a pane, closes one of the new panes and splits again.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 9
diff changeset
4002 pane_path: the path position of the description in the page
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4003 path_record: the path of the active record
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
4004
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
4005 self.__budget: the budget (base.obra object)
25
189f8274aecd gui. switch navigation menu on switch page
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 23
diff changeset
4006 self.__wr_page: weak reference from Page instance which creates self
10
d2cbc0278b30 bug fix: A except is raised when a user splits a pane, closes one of the new panes and splits again.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 9
diff changeset
4007 self.__pane_path: the path position of the description in the page
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
4008 self.__active_path_record: the path of the active record
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4009 self.__label: The Gtk.label with the title of the pane
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
4010 self.__field_liststore: the field liststore
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
4011 self.__field_treeview: the field treeview
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
4012 self.__field_selection: the field selected in field treview
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
4013 self.__section_liststore: the section liststore
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
4014 self.__section_treeview: the section treeview
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
4015 self.__section_selection: the section selected in the section treeview
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
4016 self.__textbuffer: The textbuffer of the textview that contain
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
4017 the record text.
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4018 self.__widget: main widget, a Gtk.Grid()
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
4019
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4020 Creates an shows the scroledwindow that contain the description text
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4021 of the record to be showed in a pane.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4022 """
22
7bd4ca56607d bug fix: Mutable default arguments
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
4023 if path_record is None:
7bd4ca56607d bug fix: Mutable default arguments
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
4024 path_record = (0,)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4025 self.__budget = budget
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4026 self.__wr_page = wr_page
10
d2cbc0278b30 bug fix: A except is raised when a user splits a pane, closes one of the new panes and splits again.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 9
diff changeset
4027 self.__pane_path = pane_path
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4028 self.__active_path_record = path_record
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4029 _budget = budget
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4030 _main_box = Gtk.Grid()
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4031 _main_box.set_orientation(Gtk.Orientation(1)) # 1 Vertical
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4032 self.__label = Gtk.Label(utils.mapping(_("Sheet of Conditions of the "\
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4033 "record $1"), (self.__budget.getCode(
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4034 self.__active_path_record),)))
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4035 self.__label.set_xalign(0)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4036 self.__label.set_yalign(0)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4037 self.__label.show()
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4038 _frame = Gtk.Frame()
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4039 _frame.set_shadow_type(Gtk.ShadowType(1)) # 1 In
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4040 _frame_box = Gtk.Grid()
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4041 _frame_box.set_orientation(Gtk.Orientation(1)) # 1 Vertical
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4042 _list_box = Gtk.Grid()
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4043 _list_box.set_orientation(Gtk.Orientation(0)) # 0 Horizontal
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4044 self.__field_liststore = Gtk.ListStore(str, str)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4045 self.__field_treeview = Gtk.TreeView(self.__field_liststore)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4046 _field_treeselection = self.__field_treeview.get_selection()
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4047 _field_treeselection.set_mode(Gtk.SelectionMode(1)) # 1 SINGLE
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4048 self.__field_selection = None
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4049 _field_treeselection.set_select_function(
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
4050 self._field_controlSelection)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4051 self.__field_treeview.show()
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4052 _fieldcode_cell = Gtk.CellRendererText()
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4053 _field_column = Gtk.TreeViewColumn(_("Field"))
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4054 _field_column.pack_start(_fieldcode_cell, False)
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4055 _field_cell = Gtk.CellRendererText()
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4056 _field_column.pack_end(_field_cell, True)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4057 _field_column.add_attribute(_fieldcode_cell, "text", 0)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4058 _field_column.add_attribute(_field_cell, "text", 1)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4059 self.__field_treeview.append_column(_field_column)
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4060 _field_scrollwindow = Gtk.ScrolledWindow()
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4061 _field_scrollwindow.set_policy(Gtk.PolicyType(1),
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4062 Gtk.PolicyType(1)) # 1 Automatic
25
189f8274aecd gui. switch navigation menu on switch page
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 23
diff changeset
4063 # widget expand all space
189f8274aecd gui. switch navigation menu on switch page
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 23
diff changeset
4064 _field_scrollwindow.set_property("hexpand", True)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4065 _field_scrollwindow.add(self.__field_treeview)
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4066 _field_scrollwindow.set_size_request(-1, 80)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4067 _field_scrollwindow.show()
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4068 self.__section_liststore = Gtk.ListStore(str, str)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4069 self.__section_treeview = Gtk.TreeView(self.__section_liststore)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4070 _section_treeselection = self.__section_treeview.get_selection()
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4071 _section_treeselection.set_mode(Gtk.SelectionMode(1)) # 1 SINGLE
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4072 self.__section_selection = None
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4073 _section_treeselection.set_select_function(
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
4074 self._section_controlSelection)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4075 self.__section_treeview.show()
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4076 _sectioncode_cell = Gtk.CellRendererText()
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4077 _section_column = Gtk.TreeViewColumn(_("Section"))
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4078 _section_column.pack_start(_sectioncode_cell, False)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4079 _section_column.add_attribute(_sectioncode_cell, "text", 0)
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4080 _section_cell = Gtk.CellRendererText()
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4081 _section_column.pack_end(_section_cell, True)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4082 _section_column.add_attribute(_section_cell, "text", 1)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4083 self.__section_treeview.append_column(_section_column)
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4084 _section_scrollwindow = Gtk.ScrolledWindow()
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4085 _section_scrollwindow.set_policy(Gtk.PolicyType(1),
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4086 Gtk.PolicyType(1)) # 1 Automatic
25
189f8274aecd gui. switch navigation menu on switch page
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 23
diff changeset
4087 # widget expand all space
189f8274aecd gui. switch navigation menu on switch page
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 23
diff changeset
4088 _section_scrollwindow.set_property("hexpand", True)
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4089 _section_scrollwindow.set_size_request(-1, 90)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4090 _section_scrollwindow.add(self.__section_treeview)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4091 _section_scrollwindow.show()
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4092
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4093 _list_box.add(_field_scrollwindow)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4094 _list_box.add(_section_scrollwindow)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4095 _list_box.show()
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4096
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4097 _scrollwindow = Gtk.ScrolledWindow()
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4098 _scrollwindow.set_policy(Gtk.PolicyType(1),
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4099 Gtk.PolicyType(1)) # 1 Automatic
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4100 _scrollwindow.set_property("expand", True) # widget expand all space
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4101 _textview = Gtk.TextView()
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4102 _textview.set_wrap_mode(2) # 2 Word
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4103 _textview.set_property("expand", True) # widget expand all space
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4104 self.__textbuffer = _textview.get_buffer()
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4105 _textview.show()
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4106 _hbox = Gtk.Grid()
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4107 _hbox.set_orientation(Gtk.Orientation(0)) # 0 Horizontal
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4108 _hbox.add(_textview)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4109 _hbox.show()
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4110 _frame_box.add(self.__label)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4111 _frame_box.add(_list_box)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4112 _frame_box.show()
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4113 _frame.add(_frame_box)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4114 _frame.show()
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4115 _main_box.add(_frame)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4116 _vbox = Gtk.Grid()
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4117 _vbox.set_orientation(Gtk.Orientation(1)) # 1 Vertical
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4118 _vbox.add(_hbox)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4119 _vbox.show()
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4120 _main_box.add(_scrollwindow)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4121 _main_box.show()
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4122 _scrollwindow.add(_vbox)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4123 _scrollwindow.show()
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4124 self.__widget = _main_box
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
4125 self._setFields()
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
4126
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
4127 def _setFields(self):
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
4128 """_setFields()
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4129
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4130 Set the fields items in the field treeview
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4131 """
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4132 _record = self.__budget.getRecord(self.__budget.getCode(
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4133 self.__active_path_record))
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4134 _sheet = _record.getSheet()
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4135 _field_list = _sheet.getFields()
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4136 self.__field_liststore.clear()
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4137 for _field in _field_list:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4138 _field_text = self.__budget.getSheetField(_field)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4139 _iter = self.__field_liststore.append([_field, _field_text])
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4140 _treeselection = self.__field_treeview.get_selection()
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4141 _treeselection.select_path(0)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4142
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
4143 def _setSection(self):
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
4144 """_setSection()
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4145
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4146 Set the section items in the section treeview
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4147 """
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4148 self.__section_liststore.clear()
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4149 if not self.__field_selection is None:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4150 _record = self.__budget.getRecord(self.__budget.getCode(
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4151 self.__active_path_record))
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4152 _sheet = _record.getSheet()
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4153 _section_list = _sheet.getSections(self.__field_selection)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4154 for _section in _section_list:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4155 _section_text = self.__budget.getSheetSection(_section)
25
189f8274aecd gui. switch navigation menu on switch page
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 23
diff changeset
4156 _iter = self.__section_liststore.append([_section,
189f8274aecd gui. switch navigation menu on switch page
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 23
diff changeset
4157 _section_text])
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4158 _treeselection = self.__section_treeview.get_selection()
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4159 _treeselection.select_path(0)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4160
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
4161 def _setText(self):
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
4162 """_setText()
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4163
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4164 Set the text in the textview
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4165 """
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4166 if not self.__section_selection is None and\
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4167 not self.__field_selection is None:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4168 _record = self.__budget.getRecord(self.__budget.getCode(
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4169 self.__active_path_record))
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4170 _sheet = _record.getSheet()
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4171 _paragraph_code = _sheet.getParagraph(self.__field_selection,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4172 self.__section_selection)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4173 _paragraph = self.__budget.getSheetParagraph(_paragraph_code)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4174 self.__textbuffer.set_text(_paragraph)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4175 else:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4176 self.__textbuffer.set_text("")
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4177
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4178 def _field_controlSelection(self, selection, model, path,
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4179 path_currently_selected, *data):
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4180 """_controlSelection(selection, model, path,
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4181 path_currently_selected, *data)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4182
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4183 selection: treeselection
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4184 path: selected path
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4185
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4186 Method connected to set_selection_function() in field treeview
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4187 This method is called before any node is selected or unselected,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4188 giving some control over which nodes are selected.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4189 The selection function should return TRUE if the state
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4190 of the node may be toggled, and FALSE if the state of the node should
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4191 be left unchanged.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4192
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4193 When a user select a row in the field treeview the section treeview is
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4194 reloaded to show the sections of this field and already the text sheet.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4195 """
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4196 _treeiter = self.__field_liststore.get_iter(path)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4197 self.__field_selection = self.__field_liststore.get_value(_treeiter, 0)
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
4198 self._setSection()
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4199 return True
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4200
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4201 def _section_controlSelection(self, selection, model, path,
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4202 path_currently_selected, *data):
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4203 """_section_controlSelection(selection, model,
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4204 path, path_currently_selected, *data)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4205
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4206 selection: treeselection
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4207 path: selected path
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4208
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4209 Method connected to set_selection_function() in sector treeview
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4210 This method is called before any node is selected or unselected,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4211 giving some control over which nodes are selected.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4212 The selection function should return TRUE if the state
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4213 of the node may be toggled, and FALSE if the state of the node should
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4214 be left unchanged.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4215
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4216 When a user select a row in the field treeview the text sheet for this
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4217 section in showed
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4218 """
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4219 _treeiter = self.__section_liststore.get_iter(path)
25
189f8274aecd gui. switch navigation menu on switch page
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 23
diff changeset
4220 self.__section_selection = self.__section_liststore.get_value(_treeiter,
189f8274aecd gui. switch navigation menu on switch page
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 23
diff changeset
4221 0)
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
4222 self._setText()
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4223 return True
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4224
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
4225 def _setActivePathRecord(self, path_record):
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
4226 """_setActivePathRecord(path_record))
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4227
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4228 path_record: active path record
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4229
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4230 Set the new path code to show its sheet of condition text.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4231 """
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4232 self.__field_selection = None
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4233 self.__field_liststore.clear()
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4234 self.__section_selection = None
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4235 self.__section_liststore.clear()
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4236 self.__textbuffer.set_text("")
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4237 _budget = self.__budget
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4238 self.__active_path_record = path_record
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4239 _code = _budget.getCode(self.__active_path_record)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4240 self.__label.set_text(utils.mapping(_("Sheet2 of Conditions of the "\
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4241 "record $1"), (_code,)))
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
4242 self._setFields()
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4243
10
d2cbc0278b30 bug fix: A except is raised when a user splits a pane, closes one of the new panes and splits again.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 9
diff changeset
4244 def runMessage(self, message, pane_path, arg=None):
d2cbc0278b30 bug fix: A except is raised when a user splits a pane, closes one of the new panes and splits again.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 9
diff changeset
4245 """runMessage(message, pane_path, arg=None)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4246
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4247 message: the message type
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4248 "change_active": change the active record
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4249 "clear": clear instance
10
d2cbc0278b30 bug fix: A except is raised when a user splits a pane, closes one of the new panes and splits again.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 9
diff changeset
4250 pane_path: tuple that identifies the pane in the notebook page
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4251 arg: tuple whit two items:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4252 0: record path in the budget
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4253 1: record code
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4254 This method receives a message and executes its corresponding action
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4255 """
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4256 _budget = self.__budget
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4257 if message == "change_active":
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4258 if _budget.hasPath(arg):
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
4259 self._setActivePathRecord(arg)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4260 elif message == "clear":
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4261 self._clear()
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4262
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4263 def _clear(self):
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
4264 """_clear()
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4265
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4266 Deletes all the instance atributes
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4267 """
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4268 del self.__wr_page
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4269 del self.__widget
10
d2cbc0278b30 bug fix: A except is raised when a user splits a pane, closes one of the new panes and splits again.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 9
diff changeset
4270 del self.__pane_path
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4271 del self.__budget
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4272 del self.__active_code
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4273 del self.__textbuffer
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4274 del self.__label
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4275 del self.__textbuffer
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4276 del self.__label
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4277 del self.__field_liststore
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4278 del self.__field_treeview
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4279 del self.__field_selection
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4280 del self.__section_liststore
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4281 del self.__section_treeview
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4282 del self.__section_selection
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4283
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
4284 def _getWidget(self):
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
4285 """_getWidget()
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4286
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4287 return the main widget (Gtk.ScrolledWindow)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4288 """
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4289 return self.__widget
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4290
10
d2cbc0278b30 bug fix: A except is raised when a user splits a pane, closes one of the new panes and splits again.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 9
diff changeset
4291 def _getPanePath(self):
d2cbc0278b30 bug fix: A except is raised when a user splits a pane, closes one of the new panes and splits again.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 9
diff changeset
4292 """_getPanePath()
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4293
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4294 return the tuple that identifies the pane in the notebook page
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4295 """
10
d2cbc0278b30 bug fix: A except is raised when a user splits a pane, closes one of the new panes and splits again.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 9
diff changeset
4296 return self.__pane_path
d2cbc0278b30 bug fix: A except is raised when a user splits a pane, closes one of the new panes and splits again.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 9
diff changeset
4297
d2cbc0278b30 bug fix: A except is raised when a user splits a pane, closes one of the new panes and splits again.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 9
diff changeset
4298 def _setPanePath(self, pane_path):
d2cbc0278b30 bug fix: A except is raised when a user splits a pane, closes one of the new panes and splits again.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 9
diff changeset
4299 """_setPanePath()
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4300
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4301 sets the tuple that identifies the pane in the notebook page
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4302 """
10
d2cbc0278b30 bug fix: A except is raised when a user splits a pane, closes one of the new panes and splits again.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 9
diff changeset
4303 self.__pane_path = pane_path
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4304
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4305 def _getWrPage(self):
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4306 """_getWrPage()
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4307
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4308 return the weak reference from Page instance
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4309 """
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4310 return self.__wr_page
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4311
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4312 def _setWrPage(self, wr_page):
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4313 """_setWrPage()
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4314
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4315 set the weak reference from Page instance
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4316 """
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4317 self.__wr_page = wr_page
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4318
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
4319 def _getBudget(self):
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
4320 """_getBudget()
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4321
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4322 return the budget object
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4323 """
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4324 return self.__budget
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4325
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
4326 def _getActivePathRecord(self):
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
4327 """_getActivePathRecord()
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4328
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4329 return the Active Path Record
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4330 """
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4331 return self.__active_path_record
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4332
10
d2cbc0278b30 bug fix: A except is raised when a user splits a pane, closes one of the new panes and splits again.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 9
diff changeset
4333 pane_path = property(_getPanePath, _setPanePath, None,
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4334 "Path that identifie the item in the page notebook")
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
4335 widget = property(_getWidget, None, None,
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4336 "Lista de configuracion de vistas")
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4337 wr_page = property(_getWrPage, _setWrPage, None,
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4338 "Weak reference from Page instance which creates this class")
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
4339 budget = property(_getBudget, None, None,
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4340 "Budget object")
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
4341 active_path_record = property(_getActivePathRecord, None, None,
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4342 "Active Path Record")
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4343
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
4344
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4345 class FileView(object):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4346 """gui.FileView
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4347
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4348 Description:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4349 Class to show the file icons of a record in a pane
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4350 Constructor:
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4351 Description(budget, page, pane_path, path_record=None)
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
4352 budget: the budget (base.obra object)
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4353 wr_page: weak reference from Page instance which creates this class
10
d2cbc0278b30 bug fix: A except is raised when a user splits a pane, closes one of the new panes and splits again.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 9
diff changeset
4354 pane_path: the path position of the description in the page
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
4355 path_record: the path of the active record
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4356 Ancestry:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4357 +-- object
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
4358 +-- FileView
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4359 Atributes:
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4360 widget: the main widget (Gtk.ScrolledWindow object)
10
d2cbc0278b30 bug fix: A except is raised when a user splits a pane, closes one of the new panes and splits again.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 9
diff changeset
4361 pane_path: the tuple that identifies the pane in the notebook page
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4362 budget: The budget (base.obra object)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4363 active_path_record: Read.
25
189f8274aecd gui. switch navigation menu on switch page
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 23
diff changeset
4364 wr_page: Read-Write. weak reference from Page instance
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4365 Methods:
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
4366 runMessage
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4367 """
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4368
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4369 def __init__(self, budget, wr_page, pane_path, path_record=None):
22
7bd4ca56607d bug fix: Mutable default arguments
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
4370 """__init__(budget, page, pane_path, path_record=None)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4371
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4372 budget: the budget (base.obra object)
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4373 wr_page: weak reference from Page instance which creates this class
10
d2cbc0278b30 bug fix: A except is raised when a user splits a pane, closes one of the new panes and splits again.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 9
diff changeset
4374 pane_path: the path position of the description in the page
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4375 path_record: the path of the active record
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4376
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
4377 self.__budget: the budget (base.obra object)
25
189f8274aecd gui. switch navigation menu on switch page
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 23
diff changeset
4378 self.__wr_page: weak reference from Page instance which creates self
10
d2cbc0278b30 bug fix: A except is raised when a user splits a pane, closes one of the new panes and splits again.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 9
diff changeset
4379 self.__pane_path: the path position of the description in the page
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
4380 self.__active_path_record: the path of the active record
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
4381 self.__active_code: the code of the active record
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
4382 self.__icon_box: the box that contains the icon
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4383 self.__widget: main widget, a Gtk.ScrolledWindow
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
4384
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4385 Creates an shows the scroledwindow that contain icon files
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4386 of the record to be showed in a pane.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4387 """
22
7bd4ca56607d bug fix: Mutable default arguments
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
4388 if path_record is None:
7bd4ca56607d bug fix: Mutable default arguments
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
4389 path_record = (0,)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4390 self.__budget = budget
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4391 self.__wr_page = wr_page
10
d2cbc0278b30 bug fix: A except is raised when a user splits a pane, closes one of the new panes and splits again.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 9
diff changeset
4392 self.__pane_path = pane_path
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4393 self.__active_path_record = path_record
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4394 self.__active_code = budget.getCode(self.__active_path_record)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4395 _budget = budget
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4396 _record = self.__budget.getRecord(self.__budget.getCode(
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4397 self.__active_path_record))
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4398
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
4399 self.__icon_box = self._getIconBox(_record)
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4400 _scrollwindow = Gtk.ScrolledWindow()
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4401 _scrollwindow.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4402 self.__icon_box.show()
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4403 _scrollwindow.add(self.__icon_box)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4404 _scrollwindow.show()
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4405 self.__widget = _scrollwindow
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4406
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
4407 def _getIconBox(self, record):
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
4408 """_getIconBox(record)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4409
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4410 record: the active record object
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4411
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4412 Creates and returns the box whith te icon files of the active record.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4413 """
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4414 _files = record.getFiles()
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4415 _flowbox = Gtk.FlowBox()
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4416 _flowbox.set_valign(Gtk.Align.START)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4417 _flowbox.set_max_children_per_line(30)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4418 _flowbox.set_selection_mode(Gtk.SelectionMode.NONE)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4419 _flowbox.set_property("expand", True) # widget expand all space
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4420 for _file in _files:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4421 _path = os.path.dirname(self.__budget.filename)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4422 _file_path = os.path.join(_path, _file.name)
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4423 _box = Gtk.Grid()
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4424 _box.set_orientation(Gtk.Orientation(1)) # 1 Vertical
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4425 if os.path.exists(_file_path):
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4426 _filetype = utils.getFiletype(_file_path)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4427 _event_box = Gtk.LinkButton()
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4428 _file_icon = Gtk.Image()
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4429 # "image", "wmf", "dxf", "pdf" , "video",
25
189f8274aecd gui. switch navigation menu on switch page
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 23
diff changeset
4430 # "office-document", "office-presentation",
189f8274aecd gui. switch navigation menu on switch page
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 23
diff changeset
4431 # "office-spreadsheet", "html", "rtf", "txt", ""
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4432 # icon
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4433 if _filetype in ["image", "wmf"]:
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4434 try:
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4435 _image_pixbuf = GdkPixbuf.Pixbuf.new_from_file(_file_path)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4436 _image_pixbuf = _image_pixbuf.scale_simple(64, 64,
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4437 GdkPixbuf.InterpType(2)) # 2 BILINEAR
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4438 except:
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4439 _image_pixbuf = GdkPixbuf.Pixbuf.new_from_file(
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4440 globalVars.getAppPath("IMAGE-ICON"))
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4441 _image_pixbuf = _image_pixbuf.scale_simple(64, 64,
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4442 GdkPixbuf.InterpType(2)) # 2 BILINEAR
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4443 _file_icon.set_from_pixbuf(_image_pixbuf)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4444 _event_box.connect("activate-link", self._launchFile,
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4445 _filetype, _file_path)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4446 elif _filetype == "dxf":
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4447 _dxf_pixbuf = GdkPixbuf.Pixbuf.new_from_file(
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4448 globalVars.getAppPath("DXF-ICON"))
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4449 _dxf_pixbuf = _dxf_pixbuf.scale_simple(64, 64,
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4450 GdkPixbuf.InterpType(2)) # 2 BILINEAR
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4451 _file_icon.set_from_pixbuf(_dxf_pixbuf)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4452 _event_box.connect("activate-link", self._launchFile,
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4453 "dxf", _file_path)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4454 elif _filetype == "pdf":
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4455 _pdf_pixbuf = GdkPixbuf.Pixbuf.new_from_file(
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4456 globalVars.getAppPath("PDF-ICON"))
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4457 _pdf_pixbuf = _pdf_pixbuf.scale_simple(64, 64,
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4458 GdkPixbuf.InterpType(2)) # 2 BILINEAR
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4459 _file_icon.set_from_pixbuf(_pdf_pixbuf)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4460 _event_box.connect("activate-link", self._launchFile,
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4461 "pdf", _file_path)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4462 elif _filetype == "video":
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4463 _video_pixbuf = Gtk.IconTheme.get_default().load_icon(
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4464 "video-x-generic", 64, 0)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4465 _file_icon.set_from_pixbuf(_video_pixbuf)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4466 _event_box.connect("activate-link", self._launchFile,
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4467 "video", _file_path)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4468 elif _filetype == "office-document":
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4469 _document_pixbuf = Gtk.IconTheme.get_default().load_icon(
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4470 "x-office-document", 64, 0)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4471 _file_icon.set_from_pixbuf(_document_pixbuf)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4472 _event_box.connect("activate-link", self._launchFile,
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4473 "office-document", _file_path)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4474 elif _filetype == "office-presentation":
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4475 _presentation_pixbuf = Gtk.IconTheme.get_default().load_icon(
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4476 "x-office-presentation", 64, 0)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4477 _file_icon.set_from_pixbuf(_presentation_pixbuf)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4478 _event_box.connect("activate-link", self._launchFile,
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4479 "office-presentation", _file_path)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4480 elif _filetype == "office-spreadsheet":
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4481 _spreadsheet_pixbuf = Gtk.IconTheme.get_default().load_icon(
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4482 "x-office-spreadsheet", 64, 0)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4483 _file_icon.set_from_pixbuf(_spreadsheet_pixbuf)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4484 _event_box.connect("activate-link", self._launchFile,
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4485 "office-spreadsheet", _file_path)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4486 elif _filetype == "html":
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4487 _html_pixbuf = Gtk.IconTheme.get_default().load_icon(
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4488 "text-html", 64, 0)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4489 _file_icon.set_from_pixbuf(_html_pixbuf)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4490 _event_box.connect("activate-link", self._launchFile,
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4491 "html", _file_path)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4492 elif _filetype == "rtf":
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4493 _rtf_pixbuf = Gtk.IconTheme.get_default().load_icon(
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4494 "text-x-generic", 64, 0)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4495 _file_icon.set_from_pixbuf(_rtf_pixbuf)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4496 _event_box.connect("activate-link", self._launchFile,
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4497 "rtf", _file_path)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4498 elif _filetype == "txt":
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4499 _txt_pixbuf = Gtk.IconTheme.get_default().load_icon(
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4500 "text-x-generic", 64, 0)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4501 _file_icon.set_from_pixbuf(_txt_pixbuf)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4502 _event_box.connect("activate-link", self._launchFile,
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4503 "txt", _file_path)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4504 else:
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4505 _missing_pixbuf = Gtk.IconTheme.get_default().load_icon(
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4506 "image-missing", 64, 0)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4507 _file_icon.set_from_pixbuf(_missing_pixbuf)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4508 # Is secure open no detected filetype?
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4509 #_event_box.connect("activate-link", self._launchFile,
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4510 # "", _file_path)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4511 _event_box = Gtk.EventBox()
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4512 _event_box.add(_file_icon)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4513 _event_box.props.margin = 5
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4514 _box.add(_event_box)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4515 _file_icon.show()
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4516 _event_box.show()
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4517 # label
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4518 _label_event_box = Gtk.EventBox()
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4519 _label = Gtk.Label(_file.name)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4520 _label_event_box.add(_label)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4521 _label_event_box.show()
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4522 _label.show()
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4523 _label_event_box.props.margin = 5
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4524 _box.add(_label_event_box)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4525 _box.show()
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4526 _box.props.margin = 5
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4527 _flowbox.add(_box)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4528 _flowbox.show()
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4529 #_scrolled.show()
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4530 return _flowbox
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4531
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4532 def _launchFile(self, widget, kind, file_path):
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
4533 """_launchFile(widget, event, kind, file_path)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4534
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4535 widget: the widget that emit the signal
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4536 king: kind of file
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4537 file_path: the path file to be launch
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4538
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4539 Launch the file if a click emit the signal.
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4540 Method connected to "activate-link" signal in images botton link
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4541 Return True: stops propagate event and avoids to raise an error
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4542 when opening an empty uri.
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4543 """
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4544 openwith.launch_file(kind, file_path)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4545 return True
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4546
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
4547 def _setActivePathRecord(self, path_record):
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
4548 """_setActivePathRecord(path_record))
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4549
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4550 path_record: active path record
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4551 Set the new path code to show its description text.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4552 """
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4553 _budget = self.__budget
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4554 self.__active_path_record = path_record
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4555 _code = _budget.getCode(self.__active_path_record)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4556 _record = self.__budget.getRecord(_code)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4557 self.__icon_box.destroy()
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4558 self.__icon_box = self._getIconBox(_record)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4559 self.__icon_box.show()
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4560 self.__widget.add_with_viewport(self.__icon_box)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4561
10
d2cbc0278b30 bug fix: A except is raised when a user splits a pane, closes one of the new panes and splits again.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 9
diff changeset
4562 def runMessage(self, message, pane_path, arg=None):
d2cbc0278b30 bug fix: A except is raised when a user splits a pane, closes one of the new panes and splits again.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 9
diff changeset
4563 """runMessage(message, pane_path, arg=None)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4564
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4565 message: the message type
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4566 "change_active": change the active record
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4567 "clear": clear instance
10
d2cbc0278b30 bug fix: A except is raised when a user splits a pane, closes one of the new panes and splits again.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 9
diff changeset
4568 pane_path: tuple that identifies the pane in the notebook page
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4569 arg: tuple whit two items:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4570 0: record path in the budget
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4571 1: record code
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4572 This method receives a message and executes its corresponding action
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4573 """
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4574 _budget = self.__budget
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4575 if message == "change_active":
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4576 if _budget.hasPath(arg):
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
4577 self._setActivePathRecord(arg)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4578 elif message == "clear":
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4579 self._clear()
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4580
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4581 def _clear(self):
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
4582 """_clear()
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4583
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4584 Delete all instance atributes
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4585 """
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4586 del self.__widget
10
d2cbc0278b30 bug fix: A except is raised when a user splits a pane, closes one of the new panes and splits again.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 9
diff changeset
4587 del self.__pane_path
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4588 del self.__budget
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4589 del self.__active_code
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4590
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
4591 def _getWidget(self):
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
4592 """_getWidget()
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4593
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4594 return the main widget (Gtk.ScrolledWindow)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4595 """
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4596 return self.__widget
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4597
10
d2cbc0278b30 bug fix: A except is raised when a user splits a pane, closes one of the new panes and splits again.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 9
diff changeset
4598 def _getPanePath(self):
d2cbc0278b30 bug fix: A except is raised when a user splits a pane, closes one of the new panes and splits again.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 9
diff changeset
4599 """_getPanePath()
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4600
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4601 return the tuple that identifies the pane in the notebook page
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4602 """
10
d2cbc0278b30 bug fix: A except is raised when a user splits a pane, closes one of the new panes and splits again.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 9
diff changeset
4603 return self.__pane_path
d2cbc0278b30 bug fix: A except is raised when a user splits a pane, closes one of the new panes and splits again.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 9
diff changeset
4604
d2cbc0278b30 bug fix: A except is raised when a user splits a pane, closes one of the new panes and splits again.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 9
diff changeset
4605 def _setPanePath(self, pane_path):
d2cbc0278b30 bug fix: A except is raised when a user splits a pane, closes one of the new panes and splits again.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 9
diff changeset
4606 """_setPanePath()
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4607
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4608 sets the tuple that identifies the pane in the notebook page
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4609 """
10
d2cbc0278b30 bug fix: A except is raised when a user splits a pane, closes one of the new panes and splits again.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 9
diff changeset
4610 self.__pane_path = pane_path
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4611
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4612 def _getWrPage(self):
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4613 """_getWrPage()
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4614
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4615 return the weak reference from Page instance
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4616 """
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4617 return self.__wr_page
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4618
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4619 def _setWrPage(self, wr_page):
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
4620 """setPage()
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4621
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4622 set the weak reference from Page instance
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4623 """
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4624 self.__wr_page = wr_page
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4625
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
4626 def _getBudget(self):
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
4627 """getBudget()
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4628
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4629 return the budget object
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4630 """
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4631 return self.__budget
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4632
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
4633 def _getActivePathRecord(self):
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
4634 """_getActivePathRecord()
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4635
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4636 return the Active Path Record
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4637 """
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4638 return self.__active_path_record
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4639
10
d2cbc0278b30 bug fix: A except is raised when a user splits a pane, closes one of the new panes and splits again.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 9
diff changeset
4640 pane_path = property(_getPanePath, _setPanePath, None,
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4641 "Path that identifie the item in the page notebook")
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
4642 widget = property(_getWidget, None, None,
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4643 "The main widget (Gtk.ScrolledWindow)")
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4644 wr_page = property(_getWrPage, _setWrPage, None,
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4645 "Weak reference from Page instance which creates this class")
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
4646 budget = property(_getBudget, None, None,
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4647 "Budget object")
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
4648 active_path_record = property(_getActivePathRecord, None, None,
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4649 "Active Path Record")
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4650
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4651
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4652 class CompanyView(object):
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4653 """gui:CompanyView:
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4654
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4655 Description:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4656 Class to show the company records of a budget
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4657 Constructor:
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4658 CompanyView(budget, wr_page, pane_path, path_record=(None)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4659 budget: budget showed ("base.Budget" object)
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4660 wr_page: weak reference from Page instance which creates this class
10
d2cbc0278b30 bug fix: A except is raised when a user splits a pane, closes one of the new panes and splits again.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 9
diff changeset
4661 pane_path: tuple that represents the path of the List in the Page
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
4662 path_record: path of the active record in the budget
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4663 Ancestry:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4664 +-- object
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4665 +-- CompanyView
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4666 Atributes:
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
4667 active_path_record: Read. Path of the active record in the budget
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4668 widget: Read. Window that contains the main widget, a Gtk.Paned
10
d2cbc0278b30 bug fix: A except is raised when a user splits a pane, closes one of the new panes and splits again.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 9
diff changeset
4669 pane_path: Read-Write. Pane page identifier
25
189f8274aecd gui. switch navigation menu on switch page
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 23
diff changeset
4670 wr_page: Read-Write. weak reference from Page instance
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
4671 budget: Read. Budget to show, base.budget instance.
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4672 Methods:
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
4673 runMessage
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4674 """
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4675
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4676 def __init__(self, budget, wr_page, pane_path, path_record=None):
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4677 """__init__(budget, wr_page, pane_path, path_record=None)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4678
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4679 budget: budget showed ("base.Budget" object)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4680 wr_page: weak reference from Page instance which creates this class
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4681 pane_path: tuple that represents the path of the pane in the Page
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4682 path_record: path of the active record in the budget
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4683
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4684 self.__selection: "company" or "office" selected treeview
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
4685 self.__budget: budget: budget showed ("base.Budget" object)
25
189f8274aecd gui. switch navigation menu on switch page
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 23
diff changeset
4686 self.__wr_page: weak reference from Page instance
10
d2cbc0278b30 bug fix: A except is raised when a user splits a pane, closes one of the new panes and splits again.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 9
diff changeset
4687 self.__pane_path: tuple that represents the path of the List in the Page
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
4688 self.__active_path_record: path of the active record in the budget
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4689 self.__widget: main widget, a Gtk.Paned
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
4690 self.__treestore: to store companys data
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
4691 self.__option_View: OptionView object
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
4692
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4693 Creates an shows the widgets with the company data.
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4694 """
22
7bd4ca56607d bug fix: Mutable default arguments
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
4695 if path_record is None:
7bd4ca56607d bug fix: Mutable default arguments
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 21
diff changeset
4696 path_record = (0,)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4697 self.__selection = None
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4698 # Seting init args
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4699 if not isinstance(budget, base.Budget):
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4700 raise ValueError( _("Argument must be a Budget object") )
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4701 self.__budget = budget
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4702 self.__wr_page = wr_page
10
d2cbc0278b30 bug fix: A except is raised when a user splits a pane, closes one of the new panes and splits again.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 9
diff changeset
4703 self.__pane_path = pane_path
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4704 self.__active_path_record = path_record
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
4705 # main widget
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4706 self.__widget = Gtk.Paned.new(Gtk.Orientation(0)) # 0 Horizontal
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
4707 self.__widget.set_position(230)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4708 # TreeStore
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4709 self.__treestore = Gtk.TreeStore(str, str)
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
4710 self._setTreeStoreValues()
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4711 # Select Treeview
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4712 _select_treeview = Gtk.TreeView(self.__treestore)
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
4713 _select_treeview.set_enable_search(False)
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
4714 _select_treeview.set_reorderable(False)
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
4715 _select_treeview.set_headers_visible(False)
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
4716 _select_treeview.show()
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4717 # Scrolled_window
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4718 _scrolled_window = Gtk.ScrolledWindow()
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4719 _scrolled_window.set_property("expand", True) # widget expand all space
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4720 _scrolled_window.set_policy(Gtk.PolicyType(1),
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4721 Gtk.PolicyType(1)) # 1 Automatic
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
4722 _scrolled_window.add(_select_treeview)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4723 # colors
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4724 _text_color = globalVars.color["TEXT"]
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4725 _background_color = [
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4726 globalVars.color["UNEVEN"],
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4727 globalVars.color["EVEN"]]
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4728 _code_column = Gtk.TreeViewColumn()
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
4729 _code_column.set_clickable(True)
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
4730 _code_column.set_fixed_width(200)
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4731 _code_cell = Gtk.CellRendererText()
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4732 _code_cell.set_property('foreground', _text_color)
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
4733 _code_column.pack_start(_code_cell, True)
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
4734 _code_column.add_attribute(_code_cell, 'text', 0)
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4735 _summary_cell = Gtk.CellRendererText()
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4736 _summary_cell.set_property('foreground', _text_color)
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
4737 _code_column.pack_start(_summary_cell, True)
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
4738 _code_column.add_attribute(_summary_cell, 'text', 1)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4739 # Index column
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
4740 _select_treeview.append_column(_code_column)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4741 # control selection
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
4742 _treeselection = _select_treeview.get_selection()
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4743 _treeselection.set_mode(Gtk.SelectionMode(1)) # 1 SINGLE
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
4744 _treeselection.set_select_function(self._controlSelection)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4745 # Show
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
4746 _scrolled_window.show()
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4747 # Option View
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4748 self.__option_View = OptionView()
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4749 # Add to main widget
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4750 self.__widget.add1(_scrolled_window)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4751 self.__widget.add2(self.__option_View.widget)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4752 # Selection
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
4753 _select_treeview.set_cursor((0,), None, False)
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
4754 _select_treeview.grab_focus()
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4755 # Show
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
4756 self.__widget.show()
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
4757
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
4758 def _setOptions(self, type):
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
4759 """_setOptions(type)
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
4760
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
4761 type: "company" or "office"
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
4762 Sets the Options in the OptionView
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
4763 """
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4764 if type == "company":
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4765 _options = [("code", _("Code"), "string",
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4766 _("""Code that define the company""")),
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4767 ("summary", _("Summary"), "string",
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4768 _("""Summary of the company name""")),
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4769 ("name", _("Name"), "string",
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4770 _("""Complete name""")),
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4771 ("cif", _("CIF"), "string",
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4772 _("""Fiscal identifier number""")),
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4773 ("web", _("Web"), "string",
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4774 _("""Company web page""")),
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4775 ("email", _("Email"), "string",
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4776 _("""Company email""")),
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4777 ]
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
4778 self.__option_View.options = _options
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4779 elif type == "office":
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4780 _options = [("officeType", _("Type"), "string",
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4781 _("""Type of Office:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4782 C: Central office
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4783 D: Local office
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4784 R: Performer""")),
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4785 ("subname", _("Name"), "string",
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4786 _("Office name")),
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4787 ("address", _("Address"), "string",""),
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4788 ("postal code", _("Postal code"), "string",""),
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4789 ("town", _("Town"), "string",""),
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4790 ("province", _("Province"), "string",""),
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4791 ("country", _("Country"), "string",""),
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4792 ("phone", _("Phone"), "list",
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4793 _("Phone numbers of the office")),
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4794 ("fax", _("Fax"), "list",
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4795 _("Fax numbers of the office")),
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4796 ("contact person", _("Contact person"), "string",
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4797 _("Contact persons in the office")),
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4798 ]
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
4799 self.__option_View.options = _options
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4800 else:
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4801 print(_("Unknow Option Type") )
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
4802
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
4803 def _setTreeStoreValues(self):
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
4804 """_setTreeStoreValues()
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
4805
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
4806 Sets the treestore values from the budget
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4807 """
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4808 _budget = self.__budget
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4809 _company_keys = _budget.getCompanyKeys()
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4810 for _company_key in _company_keys:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4811 _company = _budget.getCompany(_company_key)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4812 _values = [_company_key, _company.summary]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4813 _treeiter = self.__treestore.append(None, _values)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4814 _offices = _company.offices
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4815 for _office in _offices:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4816 # TODO: Test offices
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4817 _values = [_office.officeType, _office.subname]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4818 self.__treestore.append(_treeiter, _values)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4819
25
189f8274aecd gui. switch navigation menu on switch page
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 23
diff changeset
4820 def _controlSelection(self, selection, model, path,
189f8274aecd gui. switch navigation menu on switch page
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 23
diff changeset
4821 path_currently_selected, *data):
189f8274aecd gui. switch navigation menu on switch page
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 23
diff changeset
4822 """_controlSelection(selection, model, path,
189f8274aecd gui. switch navigation menu on switch page
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 23
diff changeset
4823 path_currently_selected, *data)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4824
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4825 selection: selection
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4826
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4827 Method connected to set_selection_function()
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4828 This method is called before any node is selected or unselected,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4829 giving some control over which nodes are selected.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4830 The selection function should return TRUE if the state
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4831 of the node may be toggled, and FALSE if the state of the node should
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4832 be left unchanged.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4833
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4834 The selection changes the company/office in the option treeview
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4835 """
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4836 if len(path) == 1:
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4837 # The selection is a company
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4838 _company_key = self.__treestore[path][0]
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4839 _company = self.__budget.getCompany(_company_key)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4840 _selection = "company"
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4841 _values = _company.values
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4842 else:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4843 # The selection is a office
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4844 _company_key = self.__treestore[path[:1]][0]
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4845 _company = self.__budget.getCompany(_company_key)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4846 _selection = "office"
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4847 _office = _company.offices[path[1]]
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4848 _values = _office.values
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4849 if not self.__selection == _selection:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4850 self.__selection = _selection
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4851 self._setOptions(_selection)
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
4852 self.__option_View.values = _values
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4853 return True
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4854
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
4855 def _showMessageRecord(self, record_path):
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
4856 """_showMessageRecord(record_path)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4857
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4858 record_path: the path of the record to show
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4859 Method connected to "change_active" message
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4860 Show the record especified in the "change_active" message
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4861 """
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4862 self.__active_path_record = record_path
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4863
10
d2cbc0278b30 bug fix: A except is raised when a user splits a pane, closes one of the new panes and splits again.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 9
diff changeset
4864 def runMessage(self, message, pane_path, arg=None):
d2cbc0278b30 bug fix: A except is raised when a user splits a pane, closes one of the new panes and splits again.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 9
diff changeset
4865 """runMessage(message, pane_path, arg=None)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4866
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4867 message: the message type
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4868 "change_active": change the active record
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4869 "clear": clear instance
10
d2cbc0278b30 bug fix: A except is raised when a user splits a pane, closes one of the new panes and splits again.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 9
diff changeset
4870 pane_path: tuple that identifies the pane in the notebook page
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4871 arg: tuple whit two items:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4872 0: record path in the budget
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4873 1: record code
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4874 This method receives a message and executes its corresponding action
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4875 """
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4876 _budget = self.__budget
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4877 if message == "change_active":
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4878 if _budget.hasPath(arg):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4879 _path_record = arg
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
4880 self._showMessageRecord( _path_record)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4881 pass
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4882 elif message == "clear":
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4883 self._clear()
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4884
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
4885 def _colorCell(self, column, cell_renderer, tree_model, iter, lcolor):
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
4886 """_colorCell(column, cell_renderer, tree_model, iter, lcolor)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4887
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4888 column: the Gtk.TreeViewColumn in the treeview
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4889 cell_renderer: a Gtk.CellRenderer
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4890 tree_model: the Gtk.TreeModel
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4891 iter: Gtk.TreeIter pointing at the row
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4892 lcolor: list with 2 gtk colors for even and uneven record
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4893
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4894 Method connected to "set_cell_data_func" of many column
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4895 The set_cell_data_func() method sets the data function (or method)
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4896 to use for the column Gtk.CellRenderer specified by cell_renderer.
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4897 This function (or method) is used instead of the standard attribute
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4898 mappings for setting the column values, and should set the attributes
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4899 of the cell renderer as appropriate. func may be None to remove the
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4900 current data function. The signature of func is:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4901 -def celldatafunction(column, cell, model, iter, user_data)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4902 -def celldatamethod(self, column, cell, model, iter, user_data)
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4903 where column is the Gtk.TreeViewColumn in the treeview, cell is the
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4904 Gtk.CellRenderer for column, model is the Gtk.TreeModel for the
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4905 treeview and iter is the Gtk.TreeIter pointing at the row.
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4906
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4907 The method sets cell background color for all columns
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4908 and text for index and amount columns.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4909 """
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4910 _row_path = tree_model.get_path(iter)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4911 _number = _row_path[-1]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4912 if column is self.__index_column:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4913 cell_renderer.set_property('text', str(_number + 1))
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4914 self.__index_column.get_cells()[1].set_property(
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4915 'cell-background', lcolor[_number % 2])
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4916 if self.__treeview.get_cursor() == (_row_path,column):
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4917 cell_renderer.set_property('cell-background',
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4918 globalVars.color["ACTIVE"])
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4919 else:
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4920 cell_renderer.set_property('cell-background',
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4921 lcolor[_number % 2])
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4922
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4923 def _clear(self):
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
4924 """_clear()
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
4925
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
4926 it deletes the self.__budget value
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4927 """
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4928 del self.__budget
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4929
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
4930 def _getWidget(self):
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
4931 """_getWidget()
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4932
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4933 return the main widget (Gtk.ScrolledWindow)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4934 """
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4935 return self.__widget
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4936
10
d2cbc0278b30 bug fix: A except is raised when a user splits a pane, closes one of the new panes and splits again.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 9
diff changeset
4937 def _getPanePath(self):
d2cbc0278b30 bug fix: A except is raised when a user splits a pane, closes one of the new panes and splits again.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 9
diff changeset
4938 """_getPanePath()
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4939
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4940 return the tuple that identifies the pane in the notebook page
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4941 """
10
d2cbc0278b30 bug fix: A except is raised when a user splits a pane, closes one of the new panes and splits again.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 9
diff changeset
4942 return self.__pane_path
d2cbc0278b30 bug fix: A except is raised when a user splits a pane, closes one of the new panes and splits again.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 9
diff changeset
4943
d2cbc0278b30 bug fix: A except is raised when a user splits a pane, closes one of the new panes and splits again.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 9
diff changeset
4944 def _setPanePath(self, pane_path):
d2cbc0278b30 bug fix: A except is raised when a user splits a pane, closes one of the new panes and splits again.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 9
diff changeset
4945 """_setPanePath()
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4946
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4947 sets the tuple that identifies the pane in the notebook page
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4948 """
10
d2cbc0278b30 bug fix: A except is raised when a user splits a pane, closes one of the new panes and splits again.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 9
diff changeset
4949 self.__pane_path = pane_path
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
4950
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4951 def _getWrPage(self):
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4952 """_getWrPage()
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4953
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4954 return the Page
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4955 """
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4956 return self.__wr_page
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4957
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4958 def _setWrPage(self,wr_page):
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4959 """_setWrPage()
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4960
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4961 set the Page
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4962 """
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4963 self.__wr_page = wr_page
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4964
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
4965 def _getBudget(self):
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
4966 """_getBudget()
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4967
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4968 return the Budget objet
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4969 """
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4970 return self.__budget
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4971
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
4972 def _getActivePathRecord(self):
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
4973 """_getActivePathRecord()
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4974
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4975 return the Active Path Record
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4976 """
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4977 return self.__active_path_record
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4978
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
4979 active_path_record = property(_getActivePathRecord, None, None,
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4980 "Active path record")
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
4981 widget = property(_getWidget, None, None,
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4982 "main widget")
10
d2cbc0278b30 bug fix: A except is raised when a user splits a pane, closes one of the new panes and splits again.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 9
diff changeset
4983 pane_path = property(_getPanePath, _setPanePath, None,
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4984 "Path that identifies the item in the page notebook")
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4985 wr_page = property(_getWrPage, _setWrPage, None,
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4986 "Weak reference from Page instance which creates this class")
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
4987 budget = property(_getBudget, None, None,
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4988 "Budget object")
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4989
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4990
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4991 class OptionView(object):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4992 """gui.OptionView:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4993
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4994 Description:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4995 It creates a treeview whith the column "Option Name" "Value"
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4996 and "Type" to show and edit Options
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4997 Constructor:
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
4998 OptionView()
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
4999 Ancestry:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5000 +-- object
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5001 +-- OptionView
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5002 Atributes:
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
5003 widget: Read. Main widget
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
5004 options: Write
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
5005 values: Write
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5006 Methods:
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
5007 No public Methods
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5008 """
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5009
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
5010 def __init__(self):
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
5011 """__init__()
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
5012
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
5013 self.__option_dict:
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
5014 {"option key" : ["option name", "value", "option type",
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
5015 "option_description"]}
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
5016 self.__option_list: option keys list
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
5017 self.__option_types: valid option types list
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
5018 self.__liststore: Gtk.ListStore
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
5019 self.__treeview: Gtk.TreeView
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
5020 self.__option_column: option column
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
5021 self.__value_column: value column
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
5022 self.__type_column: type column
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
5023 self.__description_label: Gtk.Label
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
5024 self.__widget: Main widget
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
5025
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
5026 Creates an shows the widget that contain the option data.
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5027 """
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5028 self.__option_dict = {}
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5029 self.__option_list = []
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
5030 self.__option_types = {"boolean" : _("Boolean"),
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5031 "integer": _("Integer"),
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5032 "string": _("Text"),
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5033 "color" : _("Color"),
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5034 "list" : _("List")}
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5035 # ListStore
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
5036 self.__liststore = Gtk.ListStore(str, str, str, str, str)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5037 # Treeview
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
5038 self.__treeview = Gtk.TreeView(self.__liststore)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5039 self.__treeview.set_enable_search(False)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5040 self.__treeview.set_reorderable(False)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5041 self.__treeview.set_headers_clickable(False)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5042 # vbox
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
5043 _vbox = Gtk.Grid()
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
5044 _vbox.set_orientation(Gtk.Orientation(1)) # 1 Vertical
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5045 # Scrolled_window
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
5046 _scrolled_window = Gtk.ScrolledWindow()
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
5047 _scrolled_window.set_property("expand", True) # widget expand all space
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
5048 _scrolled_window.set_policy(Gtk.PolicyType(1),
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
5049 Gtk.PolicyType(1)) # 1 Automatic
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5050 _scrolled_window.add(self.__treeview)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5051 _scrolled_window.show()
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
5052 _vbox.add(_scrolled_window)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5053 # colors
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
5054 _text_color = globalVars.color["TEXT"]
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5055 _background_color = [
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
5056 globalVars.color["UNEVEN"],
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
5057 globalVars.color["EVEN"]]
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5058 # Option Column
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
5059 self.__option_column = Gtk.TreeViewColumn()
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
5060 self.__option_column.set_sizing(Gtk.TreeViewColumnSizing(2)) # 2 Fixed
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5061 self.__option_column.set_fixed_width(150)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5062 self.__option_column.set_resizable(True)
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
5063 _option_cell = Gtk.CellRendererText()
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
5064 _option_cell.set_property('foreground', _text_color)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5065 self.__option_column.pack_start(_option_cell, True)
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
5066 self.__option_column.set_cell_data_func(_option_cell, self._colorCell,
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5067 _background_color)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5068 self.__option_column.set_title(_("Option name"))
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5069 self.__option_column.add_attribute(_option_cell, 'text', 1)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5070 self.__treeview.append_column(self.__option_column)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5071 # Value Column
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
5072 self.__value_column = Gtk.TreeViewColumn()
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
5073 self.__value_column.set_sizing(Gtk.TreeViewColumnSizing(2)) # 2 Fixed
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5074 self.__value_column.set_fixed_width(275)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5075 self.__value_column.set_resizable(True)
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
5076 _value_cell = Gtk.CellRendererText()
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
5077 _value_cell.set_property('foreground', _text_color)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5078 self.__value_column.pack_start(_value_cell, True)
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
5079 self.__value_column.set_cell_data_func(_value_cell, self._colorCell,
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5080 _background_color)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5081 self.__value_column.set_title(_("Value"))
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5082 self.__value_column.add_attribute(_value_cell, 'text', 2)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5083 self.__treeview.append_column(self.__value_column)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5084 # Type Column
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
5085 self.__type_column = Gtk.TreeViewColumn()
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
5086 self.__type_column.set_sizing(Gtk.TreeViewColumnSizing(2)) # 2 Fixed
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5087 self.__type_column.set_fixed_width(70)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5088 self.__type_column.set_resizable(True)
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
5089 _type_cell = Gtk.CellRendererText()
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
5090 _type_cell.set_property('foreground', _text_color)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5091 self.__type_column.pack_start(_type_cell, True)
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
5092 self.__type_column.set_cell_data_func(_type_cell, self._colorCell,
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5093 _background_color)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5094 self.__type_column.set_title(_("Type"))
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5095 self.__treeview.append_column(self.__type_column)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5096 # End Column
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
5097 _end_column = Gtk.TreeViewColumn()
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5098 _end_column.set_clickable(False)
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
5099 _end_cell = Gtk.CellRendererText()
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
5100 _end_cell.set_property('cell-background',
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
5101 globalVars.color["UNEVEN"])
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5102 _end_column.pack_start(_end_cell, True)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5103 self.__treeview.append_column(_end_column)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5104 # Connect
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
5105 self.__treeview.connect("key-press-event", self._treeviewKeyPressEvent)
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
5106 self.__treeview.connect("button-press-event",
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
5107 self._treeviewClickedEvent)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5108 # control selection
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
5109 _treeselection = self.__treeview.get_selection()
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
5110 _treeselection.set_mode(Gtk.SelectionMode(3)) # 3 MULTIPLE
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
5111 _treeselection.set_select_function(self._controlSelection)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5112 # labels
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
5113 _frame = Gtk.Frame()
25
189f8274aecd gui. switch navigation menu on switch page
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 23
diff changeset
5114 _frame.set_shadow_type(2) # OUT 2
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
5115 _vbox2 = Gtk.Grid()
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
5116 _vbox2.set_orientation(Gtk.Orientation(1)) # 1 Vertical
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5117 _frame.add(_vbox2)
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
5118 _label = Gtk.Label()
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
5119 _label.set_xalign(0)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
5120 _label.set_yalign(0)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
5121 _label.set_margin_start(12)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5122 _label.set_markup("<b>" + _("Description:") + "</b>")
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5123 _label.show()
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
5124 self.__description_label = Gtk.Label()
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
5125 self.__description_label.set_xalign(0)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
5126 self.__description_label.set_yalign(0)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
5127 self.__description_label.set_margin_start(24)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5128 self.__description_label.show()
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
5129 _vbox2.add(_label)
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
5130 _vbox2.add(self.__description_label)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5131 _vbox2.show()
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5132 _frame.show()
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
5133 _vbox.add(_frame)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5134 # Show
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5135 self.__treeview.show()
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5136 _vbox.show()
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5137 self.__widget = _vbox
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5138
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
5139 def _treeviewKeyPressEvent(self, widget, event):
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
5140 """_treeviewKeyPressEvent(widget, event)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5141
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5142 widget: treewiew widget
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5143 event: Key Press event
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5144 Method connected to "key-press-event" signal
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5145 The "key-press-event" signal is emitted when the user presses a key
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5146 on the keyboard.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5147 Returns :TRUE to stop other handlers from being invoked for the event.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5148 Returns :FALSE to propagate the event further.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5149
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5150 If the user press the right cursor button and the cursor is in the
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
5151 value column or press the left cursor button and the cursor is
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5152 in the value column the event is estoped, else the event is propagated.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5153 """
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5154 (_cursor_path, _column) = self.__treeview.get_cursor()
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
5155 if (event.keyval in [Gdk.keyval_from_name("Right"),
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
5156 Gdk.keyval_from_name("KP_Right")] \
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5157 and _column == self.__value_column) \
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
5158 or (event.keyval in [Gdk.keyval_from_name("Left"),
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
5159 Gdk.keyval_from_name("KP_Left")] \
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5160 and _column == self.__value_column):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5161 return True
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5162 else:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5163 _description = self.__liststore[_cursor_path][4]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5164 self.__description_label.set_text(_description)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5165 return False
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5166
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
5167 def _treeviewClickedEvent(self, widget, event):
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
5168 """_treeviewClickedEvent(widget, event)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5169
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5170 widget: treewiew widget
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5171 event: clicked event
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5172 Method connected to "button-press-event" signal
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5173 The "button-press-event" signal is emitted when a mouse button is
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5174 pressed.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5175 Returns TRUE to stop other handlers from being invoked for the event.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5176 Returns FALSE to propagate the event further.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5177
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5178 The cursos is moved to value column.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5179 """
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5180 path_at_pos = self.__treeview.get_path_at_pos(int(event.x),
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5181 int(event.y))
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5182 if not path_at_pos is None:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5183 _path_cursor, _column, _x, _y = path_at_pos
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5184 _description = self.__liststore[_path_cursor][4]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5185 self.__description_label.set_text(_description)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5186 if _column == self.__value_column:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5187 return False
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5188 else:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5189 self.__treeview.set_cursor(_path_cursor,self.__value_column,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5190 True)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5191 self.__treeview.grab_focus()
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5192 return True
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5193 return True
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
5194
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
5195 def _controlSelection(self, selection, model, path, path_currently_selected,
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
5196 *data):
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
5197 """_controlSelection(selection, model, path, path_currently_selected,
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
5198 *data)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5199
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5200 selection: treeselection
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5201
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5202 Method connected to set_selection_function()
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5203 This method is called before any node is selected or unselected,
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5204 giving some control over which nodes are selected.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5205 The selection function should return TRUE if the state
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5206 of the node may be toggled, and FALSE if the state of the node should
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5207 be left unchanged.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5208
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5209 Return False so none row is selected
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5210 """
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5211 return False
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5212
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
5213 def _colorCell(self, column, cell_renderer, tree_model, iter, lcolor):
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
5214 """_colorCell(column, cell_renderer, tree_model, iter, lcolor)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5215
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
5216 column: the Gtk.TreeViewColumn in the treeview
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
5217 cell_renderer: a Gtk.CellRenderer
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
5218 tree_model: the Gtk.TreeModel
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
5219 iter: Gtk.TreeIter pointing at the row
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
5220 lcolor: list with 2 colors for even and uneven record
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5221
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5222 Method connected to "set_cell_data_func" of the column
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5223 The set_cell_data_func() method sets the data function (or method)
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
5224 to use for the column Gtk.CellRenderer specified by cell_renderer.
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5225 This function (or method) is used instead of the standard attribute
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5226 mappings for setting the column values, and should set the attributes
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5227 of the cell renderer as appropriate. func may be None to remove the
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5228 current data function. The signature of func is:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5229 -def celldatafunction(column, cell, model, iter, user_data)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5230 -def celldatamethod(self, column, cell, model, iter, user_data)
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
5231 where column is the Gtk.TreeViewColumn in the treeview, cell is the
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
5232 Gtk.CellRenderer for column, model is the Gtk.TreeModel for the
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
5233 treeview and iter is the Gtk.TreeIter pointing at the row.
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5234
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5235 The method sets cell background color for all columns
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5236 and text for type column.
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5237 """
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5238 _row_path = tree_model.get_path(iter)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5239 _number = _row_path[-1]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5240 if self.__treeview.get_cursor() == (_row_path,column):
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
5241 cell_renderer.set_property('cell-background',
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
5242 globalVars.color["ACTIVE"])
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5243 else:
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
5244 cell_renderer.set_property('cell-background',
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5245 lcolor[_number % 2])
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5246 if column is self.__type_column:
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
5247 _type = self.__option_types[tree_model[_row_path][3]]
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5248 cell_renderer.set_property('text', _type)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5249
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
5250 def _setOptions(self, option_list):
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
5251 """_setOptions(option_list)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5252
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5253 option_list: list of tuples
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5254 (option, option name, type)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5255 option: option identifier
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5256 option name: a string with the option name
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5257 Description: a string with the option description
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5258 type: can be "boolean"
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5259 "integer"
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5260 "string"
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5261 "color"
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5262 Sets the Options in the treeview rows
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5263 """
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5264 self.__option_dict = {}
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5265 self.__option_list = []
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5266 self.__liststore.clear()
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5267 if isinstance(option_list, list):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5268 for _option in option_list:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5269 if isinstance(_option, tuple) and len(_option) == 4:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5270 _option_key = _option[0]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5271 _option_name = _option[1]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5272 _option_type = _option[2]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5273 _option_description = _option[3]
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
5274 #-# str and unicode
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
5275 if (isinstance(_option_key, str) or \
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
5276 isinstance(_option_key, unicode)) and \
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5277 (isinstance(_option_name, str) or\
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5278 isinstance(_option_name, unicode))and \
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
5279 _option_type in self.__option_types.keys():
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5280 self.__liststore.append([_option_key, _option_name, "",
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5281 _option_type, _option_description])
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5282 self.__option_dict[_option_key] = [_option_name, "",
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5283 _option_type, _option_description]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5284 self.__option_list.append(_option_key)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5285 else:
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
5286 print(_("Option values must be strings") )
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5287 else:
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
5288 print(_("Option must be a tuple with 4 items") )
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5289 else:
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
5290 print(_("Option list must be a list") )
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
5291
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
5292 def _setValues(self, values):
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
5293 """_setValues(values)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5294
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5295 values: dictionary {option : value}
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5296
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5297 Sets the Options values
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5298 """
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5299 if isinstance(values, dict):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5300 for _option, _value in values.iteritems():
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5301 if _option in self.__option_dict:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5302 _type = self.__option_dict[_option][2]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5303 if _type == "boolean":
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5304 if isinstance(_value, bool):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5305 _num = self.__option_list.index(_option)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5306 _iter = self.__liststore.get_iter((_num,))
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5307 self.__liststore.set_value(_iter, 2, _value)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5308 self.__option_dict[_option][1] = _value
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5309 else:
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
5310 print(_("Icorrect type, must be boolean") )
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5311 elif _type == "integer":
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5312 try:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5313 _value = int(_value)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5314 except ValueError:
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
5315 print(_("Icorrect type, must be integer") )
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5316 else:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5317 _num = self.__option_list.index(_option)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5318 _iter = self.__liststore.get_iter((_num,))
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5319 self.__liststore.set_value(_iter, 2, _value)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5320 self.__option_dict[_option][1] = _value
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5321 elif _type == "string":
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5322 if isinstance(_value, str):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5323 _num = self.__option_list.index(_option)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5324 _iter = self.__liststore.get_iter((_num,))
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5325 self.__liststore.set_value(_iter, 2, _value)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5326 self.__option_dict[_option][1] = _value
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5327 else:
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
5328 print(_("Icorrect type, must be string") )
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5329 elif _type == "list":
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5330 if isinstance(_value, list):
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5331 _num = self.__option_list.index(_option)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5332 _iter = self.__liststore.get_iter((_num,))
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5333 _str_value = ""
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5334 for _item_value in _value:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5335 _str_value = _str_value + _item_value + ","
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5336 if _str_value[-1] == ",":
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5337 _str_value = _str_value[:-1]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5338 self.__liststore.set_value(_iter, 2, _str_value)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5339 self.__option_dict[_option][1] = _value
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5340 else:
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
5341 print(_("Icorrect type, must be list") )
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5342 elif _type == "color":
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5343 if isinstance(_value, str):
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
5344 if Gdk.RGBA().parse(_value):
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
5345 print(_("Icorrect type, must be a parseable " \
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
5346 "color") )
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5347 else:
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5348 _num = self.__option_list.index(_option)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5349 _iter = self.__liststore.get_iter((_num,))
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5350 self.__liststore.set_value(_iter, 2, _value)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5351 self.__option_dict[_option][1] = _value
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5352 else:
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
5353 print(_("Type must be boolean, integer, string or "\
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
5354 "color") )
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5355 else:
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
5356 print( _("Value must be in the option dict") )
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
5357 print(_option, _value)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5358 else:
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
5359 print( _("Values must be a dict") )
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
5360 self.__treeview.set_cursor(Gtk.TreePath.new_from_indices((0,)),
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
5361 self.__value_column, False)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5362 self.__treeview.grab_focus()
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5363 (_cursor_path, _column) = self.__treeview.get_cursor()
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5364 _description = self.__liststore[_cursor_path][4]
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5365 self.__description_label.set_text(_description)
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5366
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
5367 def _getWidget(self):
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
5368 """_getWidget()
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5369
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
5370 return the main widget (Gtk.ScrolledWindow)
1
2ac1551ad2ab add code
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents:
diff changeset
5371 """
7
0359329a1c26 Navigation buttons. Version of the data structure.
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 6
diff changeset
5372 return self.__widget
8
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
5373
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
5374 widget = property(_getWidget, None, None,
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
5375 "main widget")
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
5376 values = property(None, _setValues, None,
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
5377 "values")
55df0b15706b Docstrings and names in GTK/gui.py
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 7
diff changeset
5378 options = property(None, _setOptions, None,
11
fe9c55f86698 Improvements in navigation buttons
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 10
diff changeset
5379 "options")
23
65e7ae0d0e63 GTK2 to GTK3
Miguel Ángel Bárcena Rodríguez <miguelangel@obraencurso.es>
parents: 22
diff changeset
5380