5
# .context : Application View Controller
6
# .title : list tree view widget display capabilities (Qt3)
7
# .kind : python source
8
# .author : Fabrizio Pollastri
9
# .site : Revello - Italy
10
# .creation : 9-Dec-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/>.
32
from PyQt4.QtCore import * # Qt core
33
from PyQt4.QtGui import * # Qt GUI interface
34
from PyQt4.uic import * # ui files realizer
36
import copy # object cloning support
37
import sys # system support
39
from avc import * # AVC
41
UI_FILE = 'qt4_listtreeview.ui' # qt ui descriptor
43
UPDATE_PERIOD = 2000 # ms
46
class Example(QApplication,AVC):
48
Showcase of display capabilities for the list tree view widget
54
QApplication.__init__(self,sys.argv)
55
self.root = loadUi(UI_FILE)
59
self.list = {'head':['col1 int','col2 str'], \
60
'body':[[1,'one'],[2,'two'],[3,'three']]}
61
self.list_work = copy.deepcopy(self.list)
62
self.tree = {'head':['col1 int','col2 str'],'body':{ \
66
# children of root row '1'
67
'1.1':[11,'one one'], \
68
'1.2':[12,'one two'], \
69
# children of root row '2'
70
'2.1':[21,'two one'], \
71
'2.2':[22,'two two']}}
73
# start variables update
74
update = self.update()
75
self.timer1 = QTimer()
76
QObject.connect(self.timer1,SIGNAL("timeout()"),update.next)
77
self.timer1.start(UPDATE_PERIOD)
82
Tabular data rows data are rolled down.
84
rows_num = len(self.list['body'])
86
# save last row of data
87
last_row = self.list_work['body'][-1]
88
# shift down one position each data row
89
for i in range(1,rows_num):
90
self.list_work['body'][-i] = \
91
self.list_work['body'][-1-i]
92
# copy last row into first position
93
self.list_work['body'][0] = last_row
94
# copy working copy into connected variable
95
self.list = self.list_work
101
example = Example() # instantiate the application
102
example.avc_init() # connect widgets with variables
103
example.exec_() # run Qt event loop until quit