Version: 8.3.0
Item.py
Go to the documentation of this file.
1 # Copyright (C) 2006-2016 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, or (at your option) any later version.
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 
20 import sys
21 from qt import *
22 import CONNECTOR
23 import adapt
24 
25 class Item:
26  def __init__(self,label=""):
27  self.label=label
28  self.emitting=0
29 
30  def isExpandable(self):
31  return False
32 
33  def getChildren(self):
34  return []
35  def father(self):
36  return None
37 
38  def getIconName(self):
39  return "python"
40 
41  def panel(self,parent):
42  """Retourne un widget pour browser/editer l'item"""
43  qvbox=QVBox(parent)
44  label=QLabel("Default Panel",qvbox)
45  label.setAlignment( Qt.AlignHCenter | Qt.AlignVCenter )
46  return qvbox
47 
48  def box(self,parent):
49  """Retourne un widget pour browser/editer l'item"""
50  qvbox=QVBox(parent)
51  label=QLabel("Default Panel",qvbox)
52  label.setAlignment( Qt.AlignHCenter | Qt.AlignVCenter )
53  return qvbox
54 
55  def selected(self):
56  """Method called on selection"""
57  #print "Item selected"
58  def dblselected(self):
59  """Method called on double selection"""
60  #print "Item dblselected"
61 
62 ADAPT=adapt.adapt
63 items={}
64 def adapt(obj):
65  if items.has_key(obj.ptr()):
66  return items[obj.ptr()]
67  else:
68  item= ADAPT(obj,Item)
69  items[obj.ptr()]=item
70  return item
71 
72 if __name__ == "__main__":
73  app = QApplication(sys.argv)
74  t=Item("label").panel(None)
75  app.setMainWidget(t)
76  t.show()
77  app.exec_loop()
78