5
# .context : Application View Controller
6
# .title : tree view widget display capabilities (GTK)
7
# .kind : python source
8
# .author : Fabrizio Pollastri
9
# .site : Revello - Italy
10
# .creation : 3-Aug-2008
11
# .copyright : (c) 2008 Fabrizio Pollastri.
12
# .license : GNU General Public License (see below)
14
# This file is part of "AVC, Application View Controller".
16
# AVC is free software; you can redistribute it and/or modify
17
# it under the terms of the GNU General Public License as published by
18
# the Free Software Foundation; either version 3 of the License, or
19
# (at your option) any later version.
21
# AVC is distributed in the hope that it will be useful,
22
# but WITHOUT ANY WARRANTY; without even the implied warranty of
23
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24
# GNU General Public License for more details.
26
# You should have received a copy of the GNU General Public License
27
# along with this program. If not, see <http://www.gnu.org/licenses/>.
33
import gtk #- gimp tool kit bindings
34
import gtk.glade # glade bindings
36
from avc import * # AVC
38
import copy # object cloning support
40
GLADE_XML = 'gtk_listtreeview.glade' # GUI glade descriptor
42
UPDATE_PERIOD = 2000 # ms
47
Showcase of display capabilities for the tree view widget
53
self.glade = gtk.glade.XML(GLADE_XML)
55
# autoconnect GUI signal handlers
56
self.glade.signal_autoconnect(self)
58
# make tree view rows reorderable
59
self.glade.get_widget('list__treeview').set_reorderable(True)
60
self.glade.get_widget('tree__treeview').set_reorderable(True)
63
self.list = {'head':['col1 int','col2 str'], \
64
'body':[[1,'one'],[2,'two'],[3,'three']]}
65
self.list_work = copy.deepcopy(self.list)
66
self.tree = {'head':['col1 int','col2 str'],'body':{ \
70
# children of root row '1'
71
'1.1':[11,'one one'], \
72
'1.2':[12,'one two'], \
73
# children of root row '2'
74
'2.1':[21,'two one'], \
75
'2.2':[22,'two two']}}
77
# start variables update
78
update = self.update()
79
gobject.timeout_add(UPDATE_PERIOD,update.next)
84
Tabular data rows data are rolled down.
86
rows_num = len(self.list['body'])
88
# save last row of data
89
last_row = self.list_work['body'][-1]
90
# shift down one position each data row
91
for i in range(1,rows_num):
92
self.list_work['body'][-i] = \
93
self.list_work['body'][-1-i]
94
# copy last row into first position
95
self.list_work['body'][0] = last_row
96
# copy working copy into connected variable
97
self.list = self.list_work
101
def on_destroy(self,window):
102
"Terminate program at window destroy"
108
example = Example() # instantiate the application
109
example.avc_init() # connect widgets with variables
110
gtk.main() # run GTK event loop until quit