Version: 9.15.0
catalog.py
Go to the documentation of this file.
1 # Copyright (C) 2006-2025 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 
20 from qt import *
21 from . import browser_session
22 from . import browser_catalog
23 import pilot
24 
26  """
27  CatalogTool()
28  Main window of Catalog Tool
29  """
30  def __init__(self,parent=None):
31  QMainWindow.__init__(self,parent)
32  self.appliappli=parent
33  self.createWidgetscreateWidgets()
34  self.initActionsinitActions()
35  self.initMenusinitMenus()
36  self.initToolbarinitToolbar()
37  self.initStatusbarinitStatusbar()
38  cata=pilot.getRuntime().getBuiltinCatalog()
39  self.registerregister(cata,"Builtin Catalog")
40 
41  def createWidgets(self):
42  self.tabWidgettabWidget = QTabWidget(self)
43  #self.currentPanel=None
44  #self.connect(self.tabWidget, SIGNAL('currentChanged(QWidget *)'),self.handlePanelChanged)
45  self.setCentralWidget(self.tabWidgettabWidget)
46  self.resize(800,600)
47 
48  def initActions(self):
49  self.actionsactions = []
50  self.impSessionActimpSessionAct=QAction('Import from session...',0,self)
51  self.impSessionActimpSessionAct.connect(self.impSessionActimpSessionAct,SIGNAL('activated()'), self.importFromSessionimportFromSession)
52  self.actionsactions.append(self.impSessionActimpSessionAct)
53  self.impProcActimpProcAct=QAction('Import from proc...',0,self)
54  self.impProcActimpProcAct.connect(self.impProcActimpProcAct,SIGNAL('activated()'), self.importFromProcimportFromProc)
55  self.actionsactions.append(self.impProcActimpProcAct)
56 
57  def initMenus(self):
58  menubar = self.menuBar()
59 
60  #menu import
61  self.importMenuimportMenu=QPopupMenu(self)
62  self.impSessionActimpSessionAct.addTo(self.importMenuimportMenu)
63  self.impProcActimpProcAct.addTo(self.importMenuimportMenu)
64  menubar.insertItem('&Import',self.importMenuimportMenu)
65 
66  def importFromSession(self):
67  browser_session.MainBrowser(self,self.appliappli).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.registerregister(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.appliappli)
86  panel.setCata(cata)
87  self.tabWidgettabWidget.addTab( panel,name)
88  self.tabWidgettabWidget.showPage(panel)
89 
90  def initToolbar(self):
91  #tb = QToolBar(self)
92  #self.importAct.addTo(tb)
93  self.toolbarstoolbars={}
94  #self.toolbars['Import']=tb
95 
96  def initStatusbar(self):
97  sb = self.statusBar()
98  self.SBfileSBfile=QLabel(sb)
99  sb.addWidget(self.SBfileSBfile)
100  QWhatsThis.add(self.SBfileSBfile, """<p>Message""")
101  self.SBfileSBfile.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