1 from __future__
import absolute_import
2 from builtins
import range
9 import logging.handlers
15 from PyQt4.QtCore import SIGNAL,qVersion,QString,QVariant, Qt
16 from PyQt4.QtGui import QApplication,QMenu,QPixmap,QAction,QFileDialog,QIcon,QMessageBox
18 from Vispa.Main.Directories import logDirectory,pluginDirectory,baseDirectory,homeDirectory,iniFileName,applicationName,docDirectory,websiteUrl
28 from .
import Resources
33 MAX_VISIBLE_RECENT_FILES = 10
34 MAX_VISIBLE_UNDO_EVENTS = 10
35 FAILED_LOADING_PLUGINS_ERROR =
"Errors while loading plugins. For details see error output or log file.\n\nThe following plugins won't work correctly:\n\n" 36 TAB_PREMATURELY_CLOSED_WARNING =
"Tab was closed before user request could be handled." 37 NO_PROCESS_EVENTS =
False 40 QApplication.__init__(self, argv)
59 logging.debug(
'Running with Qt-Version ' +
str(qVersion()))
90 return self._commandLineOptions
96 """ Returns version string. 101 """ Returns True if given versionString is newer than current used version of Qt. 103 [majorV, minorV, revisionV] = versionString.split(
".")
104 [majorQ, minorQ, revisionQ] =
str(qVersion()).
split(
".")
107 elif majorV < majorQ:
109 elif majorV == majorQ:
112 elif minorV < minorQ:
114 elif minorV == minorQ:
115 if revisionV > revisionQ:
117 elif revisionV < revisionQ:
119 elif revisionV == revisionQ:
124 """ Set the available command line options. 126 self._commandLineParser.add_option(
"-f",
"--file", dest=
"filename", help=
"open a FILE", metavar=
"FILE")
127 self._commandLineParser.add_option(
"-l",
"--loglevel", dest=
"loglevel", help=
"set LOGLEVEL to 10=DEBUG, 20=INFO, 30=WARNING, 40=ERROR, 50=CRITICAL", metavar=
"LOGLEVEL", type=
"int")
130 """ Initialize command line parser. 132 After calling this function, plugins may add options. 134 class QuiteOptionParser(optparse.OptionParser):
136 optparse.OptionParser.__init__(self,add_help_option=
False)
137 def error(self,message=""):
139 self._commandLineParser = QuiteOptionParser()
140 self._setCommandLineOptions()
141 (self._commandLineOptions, self._args) = self._commandLineParser.parse_args()
142 if self._commandLineOptions.loglevel:
143 logging.root.setLevel(self._commandLineOptions.loglevel)
144 self._commandLineParser = optparse.OptionParser()
145 self._setCommandLineOptions()
148 """ Analyzes the command line attributes and print usage summary if required. 150 (self._commandLineOptions, self._args) = self._commandLineParser.parse_args()
151 if self._commandLineOptions.filename:
152 self.
mainWindow().setStartupScreenVisible(
False)
153 self.
openFile(self._commandLineOptions.filename)
154 if len(self._args) > 0:
155 self.
mainWindow().setStartupScreenVisible(
False)
159 """ Check if logfile is closed correctly 162 file = open(filename,
"r") 163 for line
in file.readlines():
164 if "INFO Start logging" in line:
166 if "INFO Stop logging" in line:
171 """ Add logging handlers for a log file as well as stderr. 178 logfile = os.path.join(logDirectory,
"log" +
str(instance) +
".txt")
182 logfile = os.path.join(logDirectory,
"log" +
str(instance) +
".txt")
185 if not os.path.exists(logfile):
191 nextlogfile = os.path.join(logDirectory,
"log" +
str(instance + 1) +
".txt")
192 if os.path.exists(nextlogfile):
194 file = open(nextlogfile,
"a")
195 file.write(
"Cleaning up logfile after abnormal termination: INFO Stop logging\n")
197 if os.path.exists(logDirectory):
198 handler1 = logging.handlers.RotatingFileHandler(logfile, maxBytes=100000, backupCount=1)
199 formatter1 = logging.Formatter(
'%(asctime)s %(levelname)s %(message)s')
200 handler1.setFormatter(formatter1)
203 handler2 = logging.StreamHandler(sys.stderr)
204 formatter2 = logging.Formatter(
'%(asctime)s %(levelname)s %(message)s')
205 handler2.setFormatter(formatter2)
207 logging.root.handlers = []
208 if os.path.exists(logDirectory):
209 logging.root.addHandler(handler1)
210 logging.root.addHandler(handler2)
214 self._infologger.setLevel(logging.INFO)
215 self._infologger.handlers = []
217 self._infologger.info(
"Start logging to " + self.
_logFile)
220 """ Show the MainWindow and run the application. 226 self._infologger.info(
"Stop logging to " + self.
_logFile)
229 """ Connect signal to observe the TabWidget in the MainWindow. 231 logging.debug(
'Application: _connectSignals()')
232 self.connect(self._window.tabWidget(), SIGNAL(
"currentChanged(int)"), self.
tabChanged)
234 self.connect(self._window.tabWidget(), SIGNAL(
"tabCloseRequested(int)"), self.
tabCloseRequest)
237 """ Search all subfolders of the plugin directory for vispa plugins and registers them. 239 logging.debug(
'Application: _loadPlugins()')
240 dirs = [
"Vispa.Plugins." +
str(f)
for f
in os.listdir(pluginDirectory)
241 if os.path.isdir(os.path.join(pluginDirectory, f))
and not f.startswith(
".")
and not f.startswith(
"CVS")]
245 module = __import__(di, globals(), locals(),
"Vispa.Plugins")
249 failedToLoad.append(di)
250 except PluginIgnoredException
as e:
251 logging.info(
'Application: plugin ' + di +
' cannot be loaded and is ignored: ' +
str(e))
252 except AttributeError
as e:
253 logging.info(
'Application: plugin ' + di +
' is deactivated (define plugin in __init__.py to activate): ' +
str(e))
255 for pluginName
in self._loadablePlugins.keys():
259 failedToLoad.append(pluginName)
261 if len(failedToLoad) > 0:
267 if name
in [plugin.__class__.__name__
for plugin
in self.
_plugins]:
268 logging.info(
"%s: initalizePlugin(): Plugin '%s' already loaded. Aborting..." % (self.__class__.__name__, name))
270 if not name
in self._loadablePlugins.keys():
271 logging.error(
"%s: initalizePlugin(): Unknown plugin '%s'. Aborting..." % (self.__class__.__name__, name))
276 self._plugins.append(pluginObject)
277 logging.debug(
'Application: added plugin ' + name)
288 """ Returns plugin with given name or None if there is no such one. 290 if not name.endswith(
"Plugin"):
294 if name == plugin.__class__.__name__:
299 controllers=[self._window.tabWidget().widget(i).controller()
for i
in range(0, self._window.tabWidget().
count())]
300 controllers+=[tab.controller()
for tab
in self.
mainWindow().tabWidgets()]
304 if controller.tab().tabWidget():
305 self._window.activateWindow()
308 controller.tab().activateWindow()
311 """ Return the TabController that belongs to the tab selected in the MainWindow. 314 if isinstance(self.activeWindow(),AbstractTab):
315 return self.activeWindow().controller()
317 currentWidget = self._window.tabWidget().currentWidget()
318 if isinstance(currentWidget, AbstractTab):
319 return currentWidget.controller()
320 raise NoCurrentTabControllerException
329 def createAction(self, name, slot=None, shortcut=None, image=None, enabled=True):
330 """ create an action with name and icon and connect it to a slot. 335 image0.load(
":/resources/" + image +
".svg")
336 action = QAction(QIcon(image0), name, self.
_window)
338 action = QAction(name, self.
_window)
339 action.setEnabled(enabled)
341 self.connect(action, SIGNAL(
"triggered()"), slot)
343 if isinstance(shortcut, list):
344 action.setShortcuts(shortcut)
346 action.setShortcut(shortcut)
350 """Called for the first time this function creates the file menu and fill it. 352 The function is written in a way that it recreates the whole menu, if it 353 is called again later during execution. So it is possible to aad new 354 plugins and use them (which means they appear in the menus) without 355 restarting the program. 357 logging.debug(
'Application: _fillFileMenu()')
359 if not self._window.fileMenu().isEmpty():
360 self._window.fileMenu().
clear()
365 newFileActions += plugin.getNewFileActions()
367 if len(newFileActions) == 1:
368 newFileActions[0].setShortcut(
'Ctrl+N')
370 self._window.fileMenu().addActions(newFileActions)
374 self._window.fileMenu().addAction(openFileAction)
375 self._window.fileToolBar().addAction(openFileAction)
379 self._window.fileMenu().addAction(self.
_fileMenuItems[
'reloadFileAction'])
383 if not hasattr(self,
'recentFilesMenu'):
388 action.setVisible(
False)
389 self._recentFilesMenu.addAction(action)
390 self._recentFilesMenuActions.append(action)
391 self._recentFilesMenu.addSeparator()
393 self._recentFilesMenu.addAction(self.
_fileMenuItems[
'clearMissingRecentFilesAction'])
395 self._recentFilesMenu.addAction(self.
_fileMenuItems[
'clearRecentFilesAction'])
399 self._window.fileMenu().addSeparator()
403 self._window.fileMenu().addAction(self.
_fileMenuItems[
'closeFileAction'])
407 self._window.fileMenu().addAction(self.
_fileMenuItems[
'closeAllAction'])
409 self._window.fileMenu().addSeparator()
413 self._window.fileMenu().addAction(self.
_fileMenuItems[
'saveFileAction'])
414 self._window.fileToolBar().addAction(self.
_fileMenuItems[
'saveFileAction'])
418 self._window.fileMenu().addAction(self.
_fileMenuItems[
'saveFileAsAction'])
422 self._window.fileMenu().addAction(self.
_fileMenuItems[
'saveAllFilesAction'])
424 self._window.fileMenu().addSeparator()
430 self._window.fileMenu().addAction(exit)
433 """Called for the first time this function creates the edit menu and fills it. 435 The function is written in a way that it recreates the whole menu, if it 436 is called again later during execution. So it is possible to aad new 437 plugins and use them (which means they appear in the menus) without 438 restarting the program. 440 logging.debug(
'Application: _fillEditMenu()')
442 if not self._window.editMenu().isEmpty():
443 self._window.editMenu().
clear()
452 self._window.editMenu().addAction(self.
_editMenuItems[
"undoAction"])
453 self._window.editMenu().addAction(self.
_editMenuItems[
"redoAction"])
462 action.setVisible(
False)
463 self._undoActionsMenu.addAction(action)
464 self._undoMenuActions.append(action)
470 action.setVisible(
False)
471 self._redoActionsMenu.addAction(action)
472 self._redoMenuActions.append(action)
476 self._window.editMenu().addAction(self.
_editMenuItems[
'cutAction'])
481 self._window.editMenu().addAction(self.
_editMenuItems[
'copyAction'])
486 self._window.editMenu().addAction(self.
_editMenuItems[
'pasteAction'])
491 self._window.editMenu().addAction(self.
_editMenuItems[
'selectAllAction'])
494 self._window.editMenu().addSeparator()
498 self._window.editMenu().addAction(self.
_editMenuItems[
'findAction'])
502 logging.debug(
'Application: _fillHelpMenu()')
507 self._window.helpMenu().addAction(self.
_helpMenuItems[
'aboutAction'])
512 self._window.helpMenu().addAction(self.
_helpMenuItems[
'openLogFile'])
515 if os.path.exists(os.path.join(docDirectory,
"index.html")):
522 """ Update recent files and enable disable menu entries in file and edit menu. 529 for i
in range(0, num_recent_files):
540 if num_recent_files == 0:
542 self.
_fileMenuItems[
'clearMissingRecentFilesAction'].setEnabled(
False)
545 self.
_fileMenuItems[
'clearMissingRecentFilesAction'].setEnabled(
True)
548 at_least_one_flag =
False 549 at_least_two_flag =
False 551 at_least_one_flag =
True 552 at_least_two_flag =
True 554 at_least_one_flag =
True 556 self.
_fileMenuItems[
'saveFileAction'].setEnabled(at_least_one_flag)
557 self.
_fileMenuItems[
'saveFileAsAction'].setEnabled(at_least_one_flag)
558 self.
_fileMenuItems[
'reloadFileAction'].setEnabled(at_least_one_flag)
559 self.
_fileMenuItems[
'closeFileAction'].setEnabled(at_least_one_flag)
561 self.
_fileMenuItems[
'saveAllFilesAction'].setEnabled(at_least_two_flag)
562 self.
_fileMenuItems[
'closeAllAction'].setEnabled(at_least_two_flag)
565 if at_least_one_flag:
573 copy_paste_enabled_flag = at_least_one_flag
and self.
currentTabController().isCopyPasteEnabled()
574 self.
_editMenuItems[
'cutAction'].setEnabled(copy_paste_enabled_flag)
575 self.
_editMenuItems[
'copyAction'].setEnabled(copy_paste_enabled_flag)
576 self.
_editMenuItems[
'pasteAction'].setEnabled(copy_paste_enabled_flag)
590 if undo_supported_flag:
594 if num_undo_events > 1:
598 for i
in range(0, num_undo_events):
599 undo_event = undo_events[num_undo_events - i - 1]
611 if num_redo_events > 1:
615 for i
in range(0, num_redo_events):
616 redo_event = redo_events[num_redo_events - i - 1]
625 except NoCurrentTabControllerException:
629 """ Opens Vispa Offline Documentation 631 webbrowser.open(os.path.join(docDirectory,
"index.html"), 2,
True)
634 """ Open new browser tab and opens Vispa Project Website. 636 webbrowser.open(websiteUrl, 2,
True)
639 """ Creates menu in main window's menu bar before help menu and adds it to _pluginMenus list. 642 self._window.menuBar().insertMenu(self._window.helpMenu().menuAction(), menu)
643 self._pluginMenus.append(menu)
647 """ Shows given menu if it is in _pluginMenus list. 653 for action
in menuObject.actions():
654 if hasattr(action,
"_wasVisible")
and action._wasVisible!=
None:
655 action.setVisible(action._wasVisible)
656 action._wasVisible=
None 658 action.setVisible(
True)
659 menuObject.menuAction().setVisible(show)
662 """ Hides given menu object if it it in _pluginMenus list. 667 """ Hides all menus in _pluginMenus list. 671 menuObject.menuAction().setVisible(
False)
672 for action
in menuObject.actions():
673 if not hasattr(action,
"_wasVisible")
or action._wasVisible==
None:
674 action._wasVisible=action.isVisible()
675 action.setVisible(
False)
678 """ Creates tool bar in main window and adds it to _pluginToolBars list. 680 toolBar = self._window.addToolBar(name)
681 self._pluginToolBars.append(toolBar)
685 """ Shows given toolbar if it is in _pluginToolBars list. 688 toolBarObject.setVisible(show)
691 """ Hides given toolbar object if it it in _pluginToolBars list. 698 """ Hides all toolbars in _toolBarMenus list. 704 """ Creates tool bar with three buttons "user", "100 %" and "all". 706 See TabController's documentation of zoomUser(), zoomHundred() and zoomAll() to find out more on the different zoom levels. 714 """ Makes zoom tool bar visible. 716 Should be called from TabController's selected() function, if the controller wants to use the tool bar. 721 """ Makes zoom tool bar invisible. 723 self._zoomToolBar.hide()
726 """ Creates tool bar with buttons to invoke undo and redo events. 728 Needs to be called after _fillEditMenu() as actions are defined there. 735 """ Makes undo tool bar visible. 740 """ Hides undo tool bar. 742 self._undoToolBar.hide()
745 """ Empties list of recent files and updates main menu. 752 """ Removes entries from recent files menu if file does no longer exist. 756 if os.path.exists(file):
763 """ Adds given filename to list of recent files. 765 logging.debug(
'Application: addRecentFile() - ' + filename)
766 if isinstance(filename, QString):
767 filename =
str(filename)
770 del self.
_recentFiles[self._recentFiles.index(filename)]
775 """ Returns list of recently opened files. 780 """ Returns directory name of first entry of recent files list. 783 if os.path.abspath(os.getcwd())
in [os.path.abspath(baseDirectory),os.path.abspath(os.path.join(baseDirectory,
"bin"))]
or platform.system() ==
"Darwin":
786 elif platform.system() ==
"Darwin":
788 return homeDirectory +
"/Documents" 797 filetypes = plugin.filetypes()
799 if len(filetypes) > 0:
800 extension=filetypes[0].
extension().lower()
802 if os.path.splitext(os.path.basename(file))[1][1:].lower()==extension:
808 screen.analysisDesignerRecentFilesList().
clear()
809 screen.analysisDesignerRecentFilesList().addItem(
"...")
810 screen.analysisDesignerRecentFilesList().setCurrentRow(0)
811 plugin=self.
plugin(
"AnalysisDesignerPlugin")
815 screen.analysisDesignerRecentFilesList().addItem(os.path.basename(file))
817 screen.pxlEditorRecentFilesList().
clear()
818 screen.pxlEditorRecentFilesList().addItem(
"...")
819 screen.pxlEditorRecentFilesList().setCurrentRow(0)
820 plugin=self.
plugin(
"PxlPlugin")
824 screen.pxlEditorRecentFilesList().addItem(os.path.basename(file))
830 logging.debug(
'Application: shutting down plugins' )
836 """ Loop over all plugins and remember their file extensions. 840 self._knownFiltersList.append(
'All files (*.*)')
842 for ft
in plugin.filetypes():
844 self._knownFiltersList.append(ft.fileDialogFilter())
846 allKnownFilter =
'All known files (*.' +
" *.".
join(self._knownExtensionsDictionary.keys()) +
')' 847 self._knownFiltersList.insert(1, allKnownFilter)
848 logging.debug(
'Application: _collectFileExtensions() - ' + allKnownFilter)
850 logging.debug(
'Application: _collectFileExtensions()')
854 """Displays a common open dialog for all known file types. 856 logging.debug(
'Application: openFileDialog()')
858 if not defaultFileFilter:
867 filename = QFileDialog.getOpenFileName(
873 if not filename.isEmpty():
877 """ Decides which plugin should handle opening of the given file name. 879 logging.debug(
'Application: openFile()')
880 statusMessage = self.
startWorking(
"Opening file " + filename)
881 if isinstance(filename, QString):
882 filename =
str(filename)
886 if filename == controller.filename():
891 baseName = os.path.basename(filename)
892 ext = os.path.splitext(baseName)[1].lower().
strip(
".")
898 foundCorrectPlugin =
False 899 if os.path.exists(filename):
901 foundCorrectPlugin =
True 906 logging.error(self.__class__.__name__ +
": openFile() - Error while opening '" +
str(filename) +
"'.")
909 logging.error(self.__class__.__name__ +
": openFile() - Error while opening '" +
str(filename) +
"' : " +
exception_traceback())
910 self.
errorMessage(
"Exception while opening file. See log for details.")
912 if not foundCorrectPlugin:
913 errormsg =
'Unknown file type (.' + ext +
'). Aborting.' 915 errormsg =
'File does not exist: ' + filename
923 logging.error(errormsg)
928 """ Tells current tab controller to refresh. 930 logging.debug(
'Application: reloadFile()')
935 except NoCurrentTabControllerException:
941 """ Tells current tab controller to close. 943 logging.debug(
'Application: closeCurrentFile()')
946 except NoCurrentTabControllerException:
952 """ Closes all open tabs unless user aborts closing. 954 logging.debug(
'Application: closeAllFiles()')
959 if controller.close() ==
False:
967 """ Tells current tab controller to save its file. 969 logging.debug(
'Application: saveFile()')
972 except NoCurrentTabControllerException:
976 """This functions asks the user for a file name. 978 logging.debug(
'Application: saveFileAsDialog()')
981 except NoCurrentTabControllerException:
985 if currentTabController.filename():
986 startDirectory = currentTabController.filename()
991 for filetype
in currentTabController.supportedFileTypes():
992 filetypesList.append(
Filetype(filetype[0], filetype[1]).fileDialogFilter())
993 filetypesList.append(
'Any (*.*)')
995 selectedFilter = QString(
"")
996 filename =
str(QFileDialog.getSaveFileName(
1000 ";;".
join(filetypesList), selectedFilter))
1003 if os.path.splitext(filename)[1].
strip(
".") ==
"" and str(selectedFilter) !=
'Any (*.*)':
1004 ext = currentTabController.supportedFileTypes()[filetypesList.index(
str(selectedFilter))][0]
1005 filename = os.path.splitext(filename)[0] +
"." + ext
1006 return currentTabController.save(filename)
1010 """ Tells tab controllers of all tabs to save. 1012 logging.debug(
'Application: saveAllFiles()')
1019 """ Called when cut action is triggered (e.g. from menu entry) and forwards it to current tab controller. 1023 except NoCurrentTabControllerException:
1027 """ Called when copy action is triggered (e.g. from menu entry) and forwards it to current tab controller. 1031 except NoCurrentTabControllerException:
1035 """ Called when paste action is triggered (e.g. from menu entry) and forwards it to current tab controller. 1039 except NoCurrentTabControllerException:
1043 """ Called when selectAll action is triggered (e.g. from menu entry) and forwards it to current tab controller. 1047 except NoCurrentTabControllerException:
1051 """ Called when find action is triggered (e.g. from menu entry) and forwards it to current tab controller. 1055 except NoCurrentTabControllerException:
1059 """ Handles button pressed event from zoom tool bar and forwards it to current tab controller. 1063 except NoCurrentTabControllerException:
1067 """ Handles button pressed event from zoom tool bar and forwards it to current tab controller. 1071 except NoCurrentTabControllerException:
1075 """ Handles button pressed event from zoom tool bar and forwards it to current tab controller. 1079 except NoCurrentTabControllerException:
1083 """ Handles undo action for buttons in undo tool bar and edit menu. 1087 sender = self.sender()
1089 num = sender.data().toInt()
1094 except NoCurrentTabControllerException:
1098 """ Handles redo action for buttons in undo tool bar and edit menu. 1102 sender = self.sender()
1104 num = sender.data().toInt()
1109 except NoCurrentTabControllerException:
1113 """ Displays about box. 1115 logging.debug(
'Application: aboutBoxSlot()')
1123 logging.warning(
"%s: openLogFileSlot(): _logFile not set. Aborting..." % self.__class__.__name__)
1126 """ Slot for opening recent file. 1128 Called from recent file menu action. Filename is set as data object (QVariant) of action. 1131 logging.debug(
'Application: openRecentFileSlot() - ' + filename)
1135 """ when a different tab is activated update menu 1137 logging.debug(
'Application: tabChanged()')
1147 except NoCurrentTabControllerException:
1153 """ Update menu and window title. 1159 return str(self._window.windowTitle()).
split(
"-")[0].
strip()
1162 """ update window caption 1169 except NoCurrentTabControllerException:
1173 dirName = os.path.dirname(sys.argv[0])
1174 if os.path.abspath(dirName)
in filename:
1175 filename = filename[len(os.path.abspath(dirName)) + 1:]
1176 name = name +
" - " + filename
1177 self._window.setWindowTitle(name)
1181 self.
_ini = ConfigParser.ConfigParser()
1188 self._ini.write(configfile)
1195 """ Save the list of recent files. 1197 logging.debug(
'Application: _loadIni()')
1200 if ini.has_section(
"history"):
1202 if ini.has_option(
"history",
str(i)):
1206 """ Load the list of recent files. 1208 logging.debug(
'Application: _saveIni()')
1210 if ini.has_section(
"history"):
1211 ini.remove_section(
"history")
1212 ini.add_section(
"history")
1219 """ Displays error message. 1221 QMessageBox.critical(self.
mainWindow(),
'Error', message)
1224 """ Displays warning message. 1226 QMessageBox.warning(self.
mainWindow(),
'Warning', message)
1229 """ Displays info message. 1231 QMessageBox.about(self.
mainWindow(),
'Info', message)
1233 def showMessageBox(self, text, informativeText="", standardButtons=QMessageBox.Ok | QMessageBox.Cancel | QMessageBox.Ignore, defaultButton=QMessageBox.Ok, extraButtons=None):
1234 """ Shows a standardized message box and returns the pressed button. 1236 See documentation on Qt's QMessageBox for a list of possible standard buttons. 1240 msgBox.setParent(self.
mainWindow(), Qt.Sheet)
1241 msgBox.setText(text)
1242 msgBox.setInformativeText(informativeText)
1243 msgBox.setStandardButtons(standardButtons)
1244 if extraButtons!=
None:
1245 for button,role
in extraButtons:
1246 msgBox.addButton(button,role)
1247 msgBox.setDefaultButton(defaultButton)
1248 return msgBox.exec_()
1251 """ Opens file given as argument if possible in Vispa. 1253 If Vispa cannot handle the file type the file will be opened in it's default application. 1255 logging.debug(self.__class__.__name__ +
": doubleClickOnFile() - " +
str(filename))
1260 baseName = os.path.basename(filename)
1261 ext = os.path.splitext(baseName)[1].lower().
strip(
".")
1264 if os.path.exists(filename):
1270 if 'Windows' in platform.system():
1271 os.startfile(filename)
1272 elif 'Darwin' in platform.system():
1273 if os.access(filename, os.X_OK):
1274 logging.warning(
"It seems that executing the python program is the default action on this system, which is processed when double clicking a file. Please change that to open the file witrh your favourite editor, to use this feature.")
1276 subprocess.call((
"open", filename))
1277 elif 'Linux' in platform.system():
1279 if os.access(filename, os.X_OK):
1280 logging.warning(
"It seems that executing the python program is the default action on this system, which is processed when double clicking a file. Please change that to open the file witrh your favourite editor, to use this feature.")
1284 subprocess.call((
"xdg-open", filename))
1287 subprocess.call((
"gnome-open", filename))
1289 logging.error(self.__class__.__name__ +
": doubleClickOnFile() - Platform '" + platform.platform() +
"'. Cannot open file. I Don't know how!")
1291 logging.error(self.__class__.__name__ +
": doubleClickOnFile() - Platform '" + platform.platform() +
"'. Error while opening file: " +
str(filename))
1301 self._progressWidget.start()
1302 self._window.statusBar().showMessage(message +
"...")
1305 self._progressWidget.setToolTip(message)
1309 if not id
in self._workingMessages.keys():
1310 logging.error(self.__class__.__name__ +
": stopWorking() - Unknown id %s. Aborting..." %
str(id))
1313 self._window.statusBar().showMessage(self.
_workingMessages[self._workingMessages.keys()[0]] +
"...")
1314 self._progressWidget.setToolTip(self.
_workingMessages[self._workingMessages.keys()[0]])
1316 self._progressWidget.stop()
1317 self._progressWidget.setToolTip(
"")
1318 self._window.statusBar().showMessage(self.
_workingMessages[id] +
"... " + end +
".")
1322 self.
mainWindow().tabWidget().setCurrentIndex(i)
1326 self._window.statusBar().showMessage(message, timeout)
1329 """ Cancel operations in current tab. 1331 logging.debug(__name__ +
": cancel")
1334 except NoCurrentTabControllerException:
def infoMessage(self, message)
std::vector< std::string_view > split(std::string_view, const char *)
def getLastOpenLocation(self)
def doubleClickOnFile(self, filename)
def errorMessage(self, message)
_knownExtensionsDictionary
def hidePluginMenus(self)
def hideUndoToolBar(self)
def commandLineOptions(self)
def showPluginMenu(self, menuObject, show=True)
def showPluginToolBar(self, toolBarObject, show=True)
def openFileDialog(self, defaultFileFilter=None)
def _connectSignals(self)
def showZoomToolBar(self)
def _readCommandLineAttributes(self)
def exception_traceback()
def atLeastQtVersion(self, versionString)
def createUndoToolBar(self)
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
def hidePluginToolBars(self)
def _collectFileExtensions(self)
def clearRecentFiles(self)
def createAction(self, name, slot=None, shortcut=None, image=None, enabled=True)
def createPluginMenu(self, name)
def showUndoToolBar(self)
def _checkFile(self, filename)
def stopWorking(self, id, end="done")
void clear(CLHEP::HepGenMatrix &m)
Helper function: Reset all elements of a matrix to 0.
def openFile(self, filename)
def setCurrentTabController(self, controller)
def tabCloseRequest(self, i)
def warningMessage(self, message)
def recentFilesFromPlugin(self, plugin)
def showStatusMessage(self, message, timeout=0)
def updateWindowTitle(self)
FAILED_LOADING_PLUGINS_ERROR
def createStatusBar(self)
def startWorking(self, message="")
def clearMissingRecentFiles(self)
def createZoomToolBar(self)
def openRecentFileSlot(self)
def initializePlugin(self, name)
static std::string join(char **cmd)
def currentTabController(self)
def _initCommandLineAttributes(self)
TAB_PREMATURELY_CLOSED_WARNING
def updateStartupScreen(self)
def shutdownPlugins(self)
def saveFileAsDialog(self)
char data[epos_bytes_allocation]
def updateMenuAndWindowTitle(self)
def hideZoomToolBar(self)
def _openDocumentation(self)
def commandLineParser(self)
def showMessageBox(self, text, informativeText="", standardButtons=QMessageBox.Ok|QMessageBox.Cancel|QMessageBox.Ignore, defaultButton=QMessageBox.Ok, extraButtons=None)
def addRecentFile(self, filename)
def tabChanged(self, tab=None)
def openLogFileSlot(self)
def createPluginToolBar(self, name)
def hidePluginMenu(self, menuObject)
def setVersion(self, version)
def zoomHundredEvent(self)
def _setCommandLineOptions(self)