Version: 8.3.0
panels.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 from qt import *
21 import traceback
22 import Editor
23 import Item
24 
26  def __init__(self,parent,item):
27  QVBox.__init__(self,parent)
28  self.item=item
29  self.setSpacing( 5 )
30 
31  row0=QHBox(self)
32  label=QLabel("Name: ",row0)
33  self.lined0 = QLineEdit(item.node.getName(),row0)
34 
35  label=QLabel("Script: ",self)
36  self.mle=Editor.Editor(self,"multiLineEdit" )
37  self.mle.setText(item.node.getScript())
38 
39  row2=QHBox(self)
40  but1=QPushButton( "Save", row2 )
41  but1.setFixedSize( but1.sizeHint())
42  but2=QPushButton( "Cancel", row2 )
43  but2.setFixedSize( but2.sizeHint())
44  self.connect( but1, SIGNAL("clicked()"), self.handleSave )
45  self.connect( but2, SIGNAL("clicked()"), self.handleCancel )
46 
47  def handleSave(self):
48  self.item.node.setScript(str(self.mle.text()))
49 
50  def handleCancel(self):
51  self.lined0.setText(self.item.node.getName())
52  self.mle.setText(self.item.node.getScript())
53 
55  def __init__(self,parent,item):
56  QVBox.__init__(self,parent)
57  self.item=item
58  self.setSpacing( 5 )
59 
60  row0=QHBox(self)
61  label=QLabel("Name: ",row0)
62  self.lined0 = QLineEdit(self.item.node.getName(),row0)
63 
64  row1=QHBox(self)
65  label=QLabel("Fname: ",row1)
66  self.lined1 = QLineEdit(self.item.node.getFname(),row1)
67 
68  label=QLabel("Function: ",self)
69  self.mle=Editor.Editor(self,"multiLineEdit" )
70  self.mle.setText(self.item.node.getScript())
71 
72  row2=QHBox(self)
73  but1=QPushButton( "Save", row2 )
74  but1.setFixedSize( but1.sizeHint())
75  but2=QPushButton( "Cancel", row2 )
76  but2.setFixedSize( but2.sizeHint())
77  self.connect( but1, SIGNAL("clicked()"), self.handleSave )
78  self.connect( but2, SIGNAL("clicked()"), self.handleCancel )
79 
80  def handleSave(self):
81  self.item.node.setFname(str(self.lined1.text()))
82  self.item.node.setScript(str(self.mle.text()))
83 
84  def handleCancel(self):
85  self.lined0.setText(self.item.node.getName())
86  self.lined1.setText(self.item.node.getFname())
87  self.mle.setText(self.item.node.getScript())
88 
90  def __init__(self,parent,item):
91  QVBox.__init__(self,parent)
92  self.item=item
93  vsplit=QSplitter(Qt.Vertical,self,"VSplitter")
94  vbox=QVBox(vsplit)
95  vbox.layout().setAlignment(Qt.AlignTop|Qt.AlignLeft)
96 
97  row0=QHBox(vbox)
98  label=QLabel("Name: ",row0)
99  self.lined0 = QLineEdit(item.node.getName(),row0)
100 
101  #row1=QVBox(self)
102  #self.setStretchFactor(row1,10)
103 
104  row2=QHBox(vbox)
105  but1=QPushButton( "Save", row2 )
106  but1.setFixedSize( but1.sizeHint())
107  but2=QPushButton( "Cancel", row2 )
108  but2.setFixedSize( but2.sizeHint())
109  self.connect( but1, SIGNAL("clicked()"), self.handleSave )
110  self.connect( but2, SIGNAL("clicked()"), self.handleCancel )
111 
112  nodes= item.node.edGetDirectDescendants()
113  if nodes:
114  node=nodes[0]
115  subitem=Item.adapt(node)
116  panel=subitem.box(vsplit)
117 
118  def handleSave(self):
119  return
120  def handleCancel(self):
121  return
122 
123 class PanelInPort(QVBox):
124  def __init__(self,parent,item):
125  QVBox.__init__(self,parent)
126  self.item=item
127  self.layout().setAlignment(Qt.AlignTop|Qt.AlignLeft)
128  self.setSpacing( 5 )
129  row0=QHBox(self)
130  label=QLabel("Name: ",row0)
131  lined0 = QLineEdit(self.item.port.getName(),row0)
132  label=QLabel("Type: ",row0)
133  QLineEdit(self.item.port.edGetType().name(),row0)
134 
135  label=QLabel("Value: ",self)
136  self.value=QTextEdit(self)
137  self.value.setText("Empty")
138  self.handleRestore()
139 
140  row3=QHBox(self)
141  but1=QPushButton( "Save", row3 )
142  but1.setFixedSize( but1.sizeHint())
143  self.connect( but1, SIGNAL("clicked()"), self.handleSave )
144  but2=QPushButton( "Restore", row3 )
145  but2.setFixedSize( but2.sizeHint())
146  self.connect( but2, SIGNAL("clicked()"), self.handleRestore )
147 
148  def handleSave(self):
149  try:
150  self.item.port.edInitXML(str(self.value.text()))
151  except:
152  traceback.print_exc()
153  self.value.setText(self.item.port.dump())
154 
155  def handleRestore(self):
156  if not self.item.port.isEmpty():
157  self.value.setText(self.item.port.dump())
158 
160  def handleRestore(self):
161  try:
162  self.value.setText(self.item.port.dump())
163  except:
164  traceback.print_exc()