Salome HOME
692347ea8cddbca484e40f5c1feb506945a94863
[modules/yacs.git] / src / pyqt / gui / Item.py
1 #  Copyright (C) 2006-2008  CEA/DEN, EDF R&D
2 #
3 #  This library is free software; you can redistribute it and/or
4 #  modify it under the terms of the GNU Lesser General Public
5 #  License as published by the Free Software Foundation; either
6 #  version 2.1 of the License.
7 #
8 #  This library is distributed in the hope that it will be useful,
9 #  but WITHOUT ANY WARRANTY; without even the implied warranty of
10 #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 #  Lesser General Public License for more details.
12 #
13 #  You should have received a copy of the GNU Lesser General Public
14 #  License along with this library; if not, write to the Free Software
15 #  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 #
17 #  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 #
19 import sys
20 from qt import *
21 import CONNECTOR
22 import adapt
23
24 class Item:
25   def __init__(self,label=""):
26     self.label=label
27     self.emitting=0
28
29   def isExpandable(self):
30     return False
31   
32   def getChildren(self):
33     return []
34   def father(self):
35     return None
36   
37   def getIconName(self):
38     return "python"
39
40   def panel(self,parent):
41     """Retourne un widget pour browser/editer l'item"""
42     qvbox=QVBox(parent)
43     label=QLabel("Default Panel",qvbox)
44     label.setAlignment( Qt.AlignHCenter | Qt.AlignVCenter )
45     return qvbox
46
47   def box(self,parent):
48     """Retourne un widget pour browser/editer l'item"""
49     qvbox=QVBox(parent)
50     label=QLabel("Default Panel",qvbox)
51     label.setAlignment( Qt.AlignHCenter | Qt.AlignVCenter )
52     return qvbox
53
54   def selected(self):
55     """Method called on selection"""
56     #print "Item selected"
57   def dblselected(self):
58     """Method called on double selection"""
59     #print "Item dblselected"
60
61 ADAPT=adapt.adapt
62 items={}
63 def adapt(obj):
64   if items.has_key(obj.ptr()):
65     return items[obj.ptr()]
66   else:
67     item= ADAPT(obj,Item)
68     items[obj.ptr()]=item
69     return item
70
71 if __name__ == "__main__":
72   app = QApplication(sys.argv)
73   t=Item("label").panel(None)
74   app.setMainWidget(t)
75   t.show()
76   app.exec_loop()
77