Warn about overwriting previously imported SMS
[retroconv] / bak / testother.py
1 import sys
2 from PyQt4.QtCore import * 
3 from PyQt4.QtGui import * 
4
5 #################################################################### 
6 def main(): 
7     app = QApplication(sys.argv) 
8     w = MyWindow() 
9     w.show() 
10     sys.exit(app.exec_()) 
11
12 #################################################################### 
13 class MyWindow(QWidget): 
14     def __init__(self, *args): 
15         QWidget.__init__(self, *args) 
16
17         # create table
18         list_data = ["Tarek","Ehab","Galal"]
19         lm = MyListModel(list_data, self)
20         lv = QListView()
21         lv.setViewMode(QListView.IconMode)
22         lv.setModel(lm)
23
24         # layout
25         layout = QVBoxLayout()
26         layout.addWidget(lv) 
27         self.setLayout(layout)
28
29 #################################################################### 
30 class MyListModel(QAbstractListModel): 
31     def __init__(self, datain, parent=None, *args): 
32         """ datain: a list where each item is a row
33         """
34         QAbstractListModel.__init__(self, parent, *args) 
35         self.listdata = datain
36  
37     def rowCount(self, parent=QModelIndex()): 
38         return len(self.listdata) 
39  
40     def data(self, index, role): 
41         if index.isValid() and role == Qt.DisplayRole:
42             return QVariant(self.listdata[index.row()])
43         else: 
44             return QVariant()
45
46 ####################################################################
47 if __name__ == "__main__": 
48     main()