Salome HOME
mergefrom branch BR_V511_PR tag mergeto_trunk_03feb09
[modules/yacs.git] / src / pyqt / gui / browser_session.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 browser
22 import sessions
23 import pilot
24
25 class Browser(browser.Browser):
26   def init(self):
27     self.rootItem=sessions.Sessions(port=2809)
28     self.objectBrowser.additem(self.rootItem)
29     self.boxManager.setRootItem(self.rootItem)
30     self.setStretchFactor(self.hSplitter,10)
31
32 class MainBrowser(QMainWindow):
33   def __init__(self,parent,appli):
34     QMainWindow.__init__(self,parent)
35     self.appli=appli
36     self.catalogTool=parent
37     self.createWidgets()
38
39   def createWidgets(self):
40     box=QVBox(self)
41
42     hb=QHBox(box)
43     self.browser=Browser(hb,self.appli)
44
45     row2=QHBox(box)
46     but1=QPushButton( "Import catalog", row2 )
47     but1.setFixedSize( but1.sizeHint())
48     #but2=QPushButton( "Cancel", row2 )
49     self.connect( but1, SIGNAL("clicked()"), self.handleBut1 )
50     #box.connect( but2, SIGNAL("clicked()"), self.handleCancel )
51     self.setCentralWidget(box)
52     #self.resize(800,600)
53
54   def handleBut1(self):
55     addr=self.browser.selected.addr+"#Kernel.dir/ModulCatalog.object"
56     cata=pilot.getRuntime().loadCatalog("session",addr)
57     self.catalogTool.register(cata,self.browser.selected.addr)
58
59 if __name__ == "__main__":
60   app = QApplication(sys.argv)
61   t=MainBrowser(None,None)
62   app.setMainWidget(t)
63   t.show()
64   app.exec_loop()
65