Version: 9.16.0
catalog.py
Go to the documentation of this file.
1# Copyright (C) 2006-2026 CEA, EDF
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
20from qt import *
21from . import browser_session
22from . import browser_catalog
23import pilot
24
26 """
28 Main window of Catalog Tool
29 """
30 def __init__(self,parent=None):
31 QMainWindow.__init__(self,parent)
32 self.appli=parent
33 self.createWidgets()
34 self.initActions()
35 self.initMenus()
36 self.initToolbar()
37 self.initStatusbar()
38 cata=pilot.getRuntime().getBuiltinCatalog()
39 self.register(cata,"Builtin Catalog")
40
41 def createWidgets(self):
42 self.tabWidget = QTabWidget(self)
43 #self.currentPanel=None
44 #self.connect(self.tabWidget, SIGNAL('currentChanged(QWidget *)'),self.handlePanelChanged)
45 self.setCentralWidget(self.tabWidget)
46 self.resize(800,600)
47
48 def initActions(self):
49 self.actions = []
50 self.impSessionAct=QAction('Import from session...',0,self)
51 self.impSessionAct.connect(self.impSessionAct,SIGNAL('activated()'), self.importFromSession)
52 self.actions.append(self.impSessionAct)
53 self.impProcAct=QAction('Import from proc...',0,self)
54 self.impProcAct.connect(self.impProcAct,SIGNAL('activated()'), self.importFromProc)
55 self.actions.append(self.impProcAct)
56
57 def initMenus(self):
58 menubar = self.menuBar()
59
60 #menu import
61 self.importMenu=QPopupMenu(self)
62 self.impSessionAct.addTo(self.importMenu)
63 self.impProcAct.addTo(self.importMenu)
64 menubar.insertItem('&Import',self.importMenu)
65
67 browser_session.MainBrowser(self,self.appli).show()
68 return
69
70 def importFromProc(self):
71 fn = QFileDialog.getOpenFileName(QString.null,QString.null,self)
72 if fn.isEmpty():
73 self.statusBar().message('Loading aborted',2000)
74 return
75 filename = str(fn)
76 cata=pilot.getRuntime().loadCatalog("proc",filename)
77 print(cata)
78 print(cata._nodeMap)
79 for name,node in list(cata._nodeMap.items()):
80 print(name,node)
81 self.register(cata,filename)
82
83 def register(self,cata,name):
84 """Add a catalog in the catalog tool list"""
85 panel=browser_catalog.Browser(self,appli=self.appli)
86 panel.setCata(cata)
87 self.tabWidget.addTab( panel,name)
88 self.tabWidget.showPage(panel)
89
90 def initToolbar(self):
91 #tb = QToolBar(self)
92 #self.importAct.addTo(tb)
93 self.toolbars={}
94 #self.toolbars['Import']=tb
95
96 def initStatusbar(self):
97 sb = self.statusBar()
98 self.SBfile=QLabel(sb)
99 sb.addWidget(self.SBfile)
100 QWhatsThis.add(self.SBfile, """<p>Message""")
101 self.SBfile.setText("")
102
def initStatusbar(self)
Definition: catalog.py:96
def __init__(self, parent=None)
Definition: catalog.py:30
def createWidgets(self)
Definition: catalog.py:41
def initActions(self)
Definition: catalog.py:48
def importFromSession(self)
Definition: catalog.py:66
def initMenus(self)
Definition: catalog.py:57
def register(self, cata, name)
Definition: catalog.py:83
def initToolbar(self)
Definition: catalog.py:90
def importFromProc(self)
Definition: catalog.py:70