7 import logging.handlers
13 from PyQt4.QtCore import SIGNAL,qVersion,QString,QVariant, Qt
14 from PyQt4.QtGui import QApplication,QMenu,QPixmap,QAction,QFileDialog,QIcon,QMessageBox
16 from Vispa.Main.Directories import logDirectory,pluginDirectory,baseDirectory,homeDirectory,iniFileName,applicationName,docDirectory,websiteUrl
31 MAX_VISIBLE_RECENT_FILES = 10
32 MAX_VISIBLE_UNDO_EVENTS = 10
33 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"
34 TAB_PREMATURELY_CLOSED_WARNING =
"Tab was closed before user request could be handled."
35 NO_PROCESS_EVENTS =
False
38 QApplication.__init__(self, argv)
57 logging.debug(
'Running with Qt-Version ' + str(qVersion()))
88 return self._commandLineOptions
94 """ Returns version string.
99 """ Returns True if given versionString is newer than current used version of Qt.
101 [majorV, minorV, revisionV] = versionString.split(
".")
102 [majorQ, minorQ, revisionQ] = str(qVersion()).
split(
".")
105 elif majorV < majorQ:
107 elif majorV == majorQ:
110 elif minorV < minorQ:
112 elif minorV == minorQ:
113 if revisionV > revisionQ:
115 elif revisionV < revisionQ:
117 elif revisionV == revisionQ:
122 """ Set the available command line options.
124 self._commandLineParser.add_option(
"-f",
"--file", dest=
"filename", help=
"open a FILE", metavar=
"FILE")
125 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")
128 """ Initialize command line parser.
130 After calling this function, plugins may add options.
132 class QuiteOptionParser(optparse.OptionParser):
134 optparse.OptionParser.__init__(self,add_help_option=
False)
135 def error(self,message=""):
137 self._commandLineParser = QuiteOptionParser()
138 self._setCommandLineOptions()
139 (self._commandLineOptions, self._args) = self._commandLineParser.parse_args()
140 if self._commandLineOptions.loglevel:
141 logging.root.setLevel(self._commandLineOptions.loglevel)
142 self._commandLineParser = optparse.OptionParser()
143 self._setCommandLineOptions()
146 """ Analyzes the command line attributes and print usage summary if required.
148 (self._commandLineOptions, self._args) = self._commandLineParser.parse_args()
149 if self._commandLineOptions.filename:
150 self.
mainWindow().setStartupScreenVisible(
False)
151 self.
openFile(self._commandLineOptions.filename)
152 if len(self._args) > 0:
153 self.
mainWindow().setStartupScreenVisible(
False)
157 """ Check if logfile is closed correctly
160 file = open(filename,
"r")
161 for line
in file.readlines():
162 if "INFO Start logging" in line:
164 if "INFO Stop logging" in line:
169 """ Add logging handlers for a log file as well as stderr.
176 logfile = os.path.join(logDirectory,
"log" + str(instance) +
".txt")
180 logfile = os.path.join(logDirectory,
"log" + str(instance) +
".txt")
183 if not os.path.exists(logfile):
189 nextlogfile = os.path.join(logDirectory,
"log" + str(instance + 1) +
".txt")
190 if os.path.exists(nextlogfile):
192 file = open(nextlogfile,
"a")
193 file.write(
"Cleaning up logfile after abnormal termination: INFO Stop logging\n")
195 if os.path.exists(logDirectory):
196 handler1 = logging.handlers.RotatingFileHandler(logfile, maxBytes=100000, backupCount=1)
197 formatter1 = logging.Formatter(
'%(asctime)s %(levelname)s %(message)s')
198 handler1.setFormatter(formatter1)
201 handler2 = logging.StreamHandler(sys.stderr)
202 formatter2 = logging.Formatter(
'%(asctime)s %(levelname)s %(message)s')
203 handler2.setFormatter(formatter2)
205 logging.root.handlers = []
206 if os.path.exists(logDirectory):
207 logging.root.addHandler(handler1)
208 logging.root.addHandler(handler2)
212 self._infologger.setLevel(logging.INFO)
213 self._infologger.handlers = []
215 self._infologger.info(
"Start logging to " + self.
_logFile)
218 """ Show the MainWindow and run the application.
224 self._infologger.info(
"Stop logging to " + self.
_logFile)
227 """ Connect signal to observe the TabWidget in the MainWindow.
229 logging.debug(
'Application: _connectSignals()')
230 self.connect(self._window.tabWidget(), SIGNAL(
"currentChanged(int)"), self.
tabChanged)
232 self.connect(self._window.tabWidget(), SIGNAL(
"tabCloseRequested(int)"), self.
tabCloseRequest)
235 """ Search all subfolders of the plugin directory for vispa plugins and registers them.
237 logging.debug(
'Application: _loadPlugins()')
238 dirs = [
"Vispa.Plugins." + str(f)
for f
in os.listdir(pluginDirectory)
239 if os.path.isdir(os.path.join(pluginDirectory, f))
and not f.startswith(
".")
and not f.startswith(
"CVS")]
243 module = __import__(di, globals(), locals(),
"Vispa.Plugins")
247 failedToLoad.append(di)
248 except PluginIgnoredException,e:
249 logging.info(
'Application: plugin ' + di +
' cannot be loaded and is ignored: ' + str(e))
250 except AttributeError,e:
251 logging.info(
'Application: plugin ' + di +
' is deactivated (define plugin in __init__.py to activate): ' + str(e))
253 for pluginName
in self._loadablePlugins.keys():
257 failedToLoad.append(pluginName)
259 if len(failedToLoad) > 0:
265 if name
in [plugin.__class__.__name__
for plugin
in self.
_plugins]:
266 logging.info(
"%s: initalizePlugin(): Plugin '%s' already loaded. Aborting..." % (self.__class__.__name__, name))
268 if not name
in self._loadablePlugins.keys():
269 logging.error(
"%s: initalizePlugin(): Unknown plugin '%s'. Aborting..." % (self.__class__.__name__, name))
274 self._plugins.append(pluginObject)
275 logging.debug(
'Application: added plugin ' + name)
286 """ Returns plugin with given name or None if there is no such one.
288 if not name.endswith(
"Plugin"):
292 if name == plugin.__class__.__name__:
297 controllers=[self._window.tabWidget().widget(i).controller()
for i
in range(0, self._window.tabWidget().
count())]
298 controllers+=[tab.controller()
for tab
in self.
mainWindow().tabWidgets()]
302 if controller.tab().tabWidget():
303 self._window.activateWindow()
306 controller.tab().activateWindow()
309 """ Return the TabController that belongs to the tab selected in the MainWindow.
312 if isinstance(self.activeWindow(),AbstractTab):
313 return self.activeWindow().controller()
315 currentWidget = self._window.tabWidget().currentWidget()
316 if isinstance(currentWidget, AbstractTab):
317 return currentWidget.controller()
318 raise NoCurrentTabControllerException
327 def createAction(self, name, slot=None, shortcut=None, image=None, enabled=True):
328 """ create an action with name and icon and connect it to a slot.
333 image0.load(
":/resources/" + image +
".svg")
334 action = QAction(QIcon(image0), name, self.
_window)
336 action = QAction(name, self.
_window)
337 action.setEnabled(enabled)
339 self.connect(action, SIGNAL(
"triggered()"), slot)
341 if isinstance(shortcut, list):
342 action.setShortcuts(shortcut)
344 action.setShortcut(shortcut)
348 """Called for the first time this function creates the file menu and fill it.
350 The function is written in a way that it recreates the whole menu, if it
351 is called again later during execution. So it is possible to aad new
352 plugins and use them (which means they appear in the menus) without
353 restarting the program.
355 logging.debug(
'Application: _fillFileMenu()')
357 if not self._window.fileMenu().isEmpty():
358 self._window.fileMenu().
clear()
363 newFileActions += plugin.getNewFileActions()
365 if len(newFileActions) == 1:
366 newFileActions[0].setShortcut(
'Ctrl+N')
368 self._window.fileMenu().addActions(newFileActions)
372 self._window.fileMenu().addAction(openFileAction)
373 self._window.fileToolBar().addAction(openFileAction)
377 self._window.fileMenu().addAction(self.
_fileMenuItems[
'reloadFileAction'])
381 if not hasattr(self,
'recentFilesMenu'):
386 action.setVisible(
False)
387 self._recentFilesMenu.addAction(action)
388 self._recentFilesMenuActions.append(action)
389 self._recentFilesMenu.addSeparator()
391 self._recentFilesMenu.addAction(self.
_fileMenuItems[
'clearMissingRecentFilesAction'])
393 self._recentFilesMenu.addAction(self.
_fileMenuItems[
'clearRecentFilesAction'])
397 self._window.fileMenu().addSeparator()
401 self._window.fileMenu().addAction(self.
_fileMenuItems[
'closeFileAction'])
405 self._window.fileMenu().addAction(self.
_fileMenuItems[
'closeAllAction'])
407 self._window.fileMenu().addSeparator()
411 self._window.fileMenu().addAction(self.
_fileMenuItems[
'saveFileAction'])
412 self._window.fileToolBar().addAction(self.
_fileMenuItems[
'saveFileAction'])
416 self._window.fileMenu().addAction(self.
_fileMenuItems[
'saveFileAsAction'])
420 self._window.fileMenu().addAction(self.
_fileMenuItems[
'saveAllFilesAction'])
422 self._window.fileMenu().addSeparator()
428 self._window.fileMenu().addAction(exit)
431 """Called for the first time this function creates the edit menu and fills it.
433 The function is written in a way that it recreates the whole menu, if it
434 is called again later during execution. So it is possible to aad new
435 plugins and use them (which means they appear in the menus) without
436 restarting the program.
438 logging.debug(
'Application: _fillEditMenu()')
440 if not self._window.editMenu().isEmpty():
441 self._window.editMenu().
clear()
450 self._window.editMenu().addAction(self.
_editMenuItems[
"undoAction"])
451 self._window.editMenu().addAction(self.
_editMenuItems[
"redoAction"])
460 action.setVisible(
False)
461 self._undoActionsMenu.addAction(action)
462 self._undoMenuActions.append(action)
468 action.setVisible(
False)
469 self._redoActionsMenu.addAction(action)
470 self._redoMenuActions.append(action)
474 self._window.editMenu().addAction(self.
_editMenuItems[
'cutAction'])
479 self._window.editMenu().addAction(self.
_editMenuItems[
'copyAction'])
484 self._window.editMenu().addAction(self.
_editMenuItems[
'pasteAction'])
489 self._window.editMenu().addAction(self.
_editMenuItems[
'selectAllAction'])
492 self._window.editMenu().addSeparator()
496 self._window.editMenu().addAction(self.
_editMenuItems[
'findAction'])
500 logging.debug(
'Application: _fillHelpMenu()')
505 self._window.helpMenu().addAction(self.
_helpMenuItems[
'aboutAction'])
510 self._window.helpMenu().addAction(self.
_helpMenuItems[
'openLogFile'])
513 if os.path.exists(os.path.join(docDirectory,
"index.html")):
520 """ Update recent files and enable disable menu entries in file and edit menu.
527 for i
in range(0, num_recent_files):
538 if num_recent_files == 0:
540 self.
_fileMenuItems[
'clearMissingRecentFilesAction'].setEnabled(
False)
543 self.
_fileMenuItems[
'clearMissingRecentFilesAction'].setEnabled(
True)
546 at_least_one_flag =
False
547 at_least_two_flag =
False
549 at_least_one_flag =
True
550 at_least_two_flag =
True
552 at_least_one_flag =
True
554 self.
_fileMenuItems[
'saveFileAction'].setEnabled(at_least_one_flag)
555 self.
_fileMenuItems[
'saveFileAsAction'].setEnabled(at_least_one_flag)
556 self.
_fileMenuItems[
'reloadFileAction'].setEnabled(at_least_one_flag)
557 self.
_fileMenuItems[
'closeFileAction'].setEnabled(at_least_one_flag)
559 self.
_fileMenuItems[
'saveAllFilesAction'].setEnabled(at_least_two_flag)
560 self.
_fileMenuItems[
'closeAllAction'].setEnabled(at_least_two_flag)
563 if at_least_one_flag:
571 copy_paste_enabled_flag = at_least_one_flag
and self.
currentTabController().isCopyPasteEnabled()
572 self.
_editMenuItems[
'cutAction'].setEnabled(copy_paste_enabled_flag)
573 self.
_editMenuItems[
'copyAction'].setEnabled(copy_paste_enabled_flag)
574 self.
_editMenuItems[
'pasteAction'].setEnabled(copy_paste_enabled_flag)
588 if undo_supported_flag:
592 if num_undo_events > 1:
596 for i
in range(0, num_undo_events):
597 undo_event = undo_events[num_undo_events - i - 1]
609 if num_redo_events > 1:
613 for i
in range(0, num_redo_events):
614 redo_event = redo_events[num_redo_events - i - 1]
623 except NoCurrentTabControllerException:
627 """ Opens Vispa Offline Documentation
629 webbrowser.open(os.path.join(docDirectory,
"index.html"), 2,
True)
632 """ Open new browser tab and opens Vispa Project Website.
634 webbrowser.open(websiteUrl, 2,
True)
637 """ Creates menu in main window's menu bar before help menu and adds it to _pluginMenus list.
640 self._window.menuBar().insertMenu(self._window.helpMenu().menuAction(), menu)
641 self._pluginMenus.append(menu)
645 """ Shows given menu if it is in _pluginMenus list.
651 for action
in menuObject.actions():
652 if hasattr(action,
"_wasVisible")
and action._wasVisible!=
None:
653 action.setVisible(action._wasVisible)
654 action._wasVisible=
None
656 action.setVisible(
True)
657 menuObject.menuAction().setVisible(show)
660 """ Hides given menu object if it it in _pluginMenus list.
665 """ Hides all menus in _pluginMenus list.
669 menuObject.menuAction().setVisible(
False)
670 for action
in menuObject.actions():
671 if not hasattr(action,
"_wasVisible")
or action._wasVisible==
None:
672 action._wasVisible=action.isVisible()
673 action.setVisible(
False)
676 """ Creates tool bar in main window and adds it to _pluginToolBars list.
678 toolBar = self._window.addToolBar(name)
679 self._pluginToolBars.append(toolBar)
683 """ Shows given toolbar if it is in _pluginToolBars list.
686 toolBarObject.setVisible(show)
689 """ Hides given toolbar object if it it in _pluginToolBars list.
696 """ Hides all toolbars in _toolBarMenus list.
702 """ Creates tool bar with three buttons "user", "100 %" and "all".
704 See TabController's documentation of zoomUser(), zoomHundred() and zoomAll() to find out more on the different zoom levels.
712 """ Makes zoom tool bar visible.
714 Should be called from TabController's selected() function, if the controller wants to use the tool bar.
719 """ Makes zoom tool bar invisible.
721 self._zoomToolBar.hide()
724 """ Creates tool bar with buttons to invoke undo and redo events.
726 Needs to be called after _fillEditMenu() as actions are defined there.
733 """ Makes undo tool bar visible.
738 """ Hides undo tool bar.
740 self._undoToolBar.hide()
743 """ Empties list of recent files and updates main menu.
750 """ Removes entries from recent files menu if file does no longer exist.
754 if os.path.exists(file):
761 """ Adds given filename to list of recent files.
763 logging.debug(
'Application: addRecentFile() - ' + filename)
764 if isinstance(filename, QString):
765 filename = str(filename)
768 del self.
_recentFiles[self._recentFiles.index(filename)]
773 """ Returns list of recently opened files.
778 """ Returns directory name of first entry of recent files list.
781 if os.path.abspath(os.getcwd())
in [os.path.abspath(baseDirectory),os.path.abspath(os.path.join(baseDirectory,
"bin"))]
or platform.system() ==
"Darwin":
784 elif platform.system() ==
"Darwin":
786 return homeDirectory +
"/Documents"
795 filetypes = plugin.filetypes()
797 if len(filetypes) > 0:
798 extension=filetypes[0].extension().lower()
800 if os.path.splitext(os.path.basename(file))[1][1:].lower()==extension:
806 screen.analysisDesignerRecentFilesList().
clear()
807 screen.analysisDesignerRecentFilesList().addItem(
"...")
808 screen.analysisDesignerRecentFilesList().setCurrentRow(0)
809 plugin=self.
plugin(
"AnalysisDesignerPlugin")
813 screen.analysisDesignerRecentFilesList().addItem(os.path.basename(file))
815 screen.pxlEditorRecentFilesList().
clear()
816 screen.pxlEditorRecentFilesList().addItem(
"...")
817 screen.pxlEditorRecentFilesList().setCurrentRow(0)
818 plugin=self.
plugin(
"PxlPlugin")
822 screen.pxlEditorRecentFilesList().addItem(os.path.basename(file))
828 logging.debug(
'Application: shutting down plugins' )
834 """ Loop over all plugins and remember their file extensions.
838 self._knownFiltersList.append(
'All files (*.*)')
840 for ft
in plugin.filetypes():
842 self._knownFiltersList.append(ft.fileDialogFilter())
844 allKnownFilter =
'All known files (*.' +
" *.".
join(self._knownExtensionsDictionary.keys()) +
')'
845 self._knownFiltersList.insert(1, allKnownFilter)
846 logging.debug(
'Application: _collectFileExtensions() - ' + allKnownFilter)
848 logging.debug(
'Application: _collectFileExtensions()')
852 """Displays a common open dialog for all known file types.
854 logging.debug(
'Application: openFileDialog()')
856 if not defaultFileFilter:
865 filename = QFileDialog.getOpenFileName(
871 if not filename.isEmpty():
875 """ Decides which plugin should handle opening of the given file name.
877 logging.debug(
'Application: openFile()')
878 statusMessage = self.
startWorking(
"Opening file " + filename)
879 if isinstance(filename, QString):
880 filename = str(filename)
884 if filename == controller.filename():
889 baseName = os.path.basename(filename)
890 ext = os.path.splitext(baseName)[1].lower().strip(
".")
896 foundCorrectPlugin =
False
897 if os.path.exists(filename):
899 foundCorrectPlugin =
True
904 logging.error(self.__class__.__name__ +
": openFile() - Error while opening '" + str(filename) +
"'.")
907 logging.error(self.__class__.__name__ +
": openFile() - Error while opening '" + str(filename) +
"' : " +
exception_traceback())
908 self.
errorMessage(
"Exception while opening file. See log for details.")
910 if not foundCorrectPlugin:
911 errormsg =
'Unknown file type (.' + ext +
'). Aborting.'
913 errormsg =
'File does not exist: ' + filename
921 logging.error(errormsg)
926 """ Tells current tab controller to refresh.
928 logging.debug(
'Application: reloadFile()')
933 except NoCurrentTabControllerException:
939 """ Tells current tab controller to close.
941 logging.debug(
'Application: closeCurrentFile()')
944 except NoCurrentTabControllerException:
950 """ Closes all open tabs unless user aborts closing.
952 logging.debug(
'Application: closeAllFiles()')
957 if controller.close() ==
False:
965 """ Tells current tab controller to save its file.
967 logging.debug(
'Application: saveFile()')
970 except NoCurrentTabControllerException:
974 """This functions asks the user for a file name.
976 logging.debug(
'Application: saveFileAsDialog()')
979 except NoCurrentTabControllerException:
983 if currentTabController.filename():
984 startDirectory = currentTabController.filename()
989 for filetype
in currentTabController.supportedFileTypes():
990 filetypesList.append(
Filetype(filetype[0], filetype[1]).fileDialogFilter())
991 filetypesList.append(
'Any (*.*)')
993 selectedFilter = QString(
"")
994 filename = str(QFileDialog.getSaveFileName(
998 ";;".
join(filetypesList), selectedFilter))
1001 if os.path.splitext(filename)[1].strip(
".") ==
"" and str(selectedFilter) !=
'Any (*.*)':
1002 ext = currentTabController.supportedFileTypes()[filetypesList.index(str(selectedFilter))][0]
1003 filename = os.path.splitext(filename)[0] +
"." + ext
1004 return currentTabController.save(filename)
1008 """ Tells tab controllers of all tabs to save.
1010 logging.debug(
'Application: saveAllFiles()')
1017 """ Called when cut action is triggered (e.g. from menu entry) and forwards it to current tab controller.
1021 except NoCurrentTabControllerException:
1025 """ Called when copy action is triggered (e.g. from menu entry) and forwards it to current tab controller.
1029 except NoCurrentTabControllerException:
1033 """ Called when paste action is triggered (e.g. from menu entry) and forwards it to current tab controller.
1037 except NoCurrentTabControllerException:
1041 """ Called when selectAll action is triggered (e.g. from menu entry) and forwards it to current tab controller.
1045 except NoCurrentTabControllerException:
1049 """ Called when find action is triggered (e.g. from menu entry) and forwards it to current tab controller.
1053 except NoCurrentTabControllerException:
1057 """ Handles button pressed event from zoom tool bar and forwards it to current tab controller.
1061 except NoCurrentTabControllerException:
1065 """ Handles button pressed event from zoom tool bar and forwards it to current tab controller.
1069 except NoCurrentTabControllerException:
1073 """ Handles button pressed event from zoom tool bar and forwards it to current tab controller.
1077 except NoCurrentTabControllerException:
1081 """ Handles undo action for buttons in undo tool bar and edit menu.
1085 sender = self.sender()
1087 num = sender.data().toInt()
1092 except NoCurrentTabControllerException:
1096 """ Handles redo action for buttons in undo tool bar and edit menu.
1100 sender = self.sender()
1102 num = sender.data().toInt()
1107 except NoCurrentTabControllerException:
1111 """ Displays about box.
1113 logging.debug(
'Application: aboutBoxSlot()')
1121 logging.warning(
"%s: openLogFileSlot(): _logFile not set. Aborting..." % self.__class__.__name__)
1124 """ Slot for opening recent file.
1126 Called from recent file menu action. Filename is set as data object (QVariant) of action.
1129 logging.debug(
'Application: openRecentFileSlot() - ' + filename)
1133 """ when a different tab is activated update menu
1135 logging.debug(
'Application: tabChanged()')
1145 except NoCurrentTabControllerException:
1151 """ Update menu and window title.
1157 return str(self._window.windowTitle()).
split(
"-")[0].strip()
1160 """ update window caption
1167 except NoCurrentTabControllerException:
1171 dirName = os.path.dirname(sys.argv[0])
1172 if os.path.abspath(dirName)
in filename:
1173 filename = filename[len(os.path.abspath(dirName)) + 1:]
1174 name = name +
" - " + filename
1175 self._window.setWindowTitle(name)
1179 self.
_ini = ConfigParser.ConfigParser()
1186 self._ini.write(configfile)
1193 """ Save the list of recent files.
1195 logging.debug(
'Application: _loadIni()')
1198 if ini.has_section(
"history"):
1200 if ini.has_option(
"history", str(i)):
1204 """ Load the list of recent files.
1206 logging.debug(
'Application: _saveIni()')
1208 if ini.has_section(
"history"):
1209 ini.remove_section(
"history")
1210 ini.add_section(
"history")
1217 """ Displays error message.
1219 QMessageBox.critical(self.
mainWindow(),
'Error', message)
1222 """ Displays warning message.
1224 QMessageBox.warning(self.
mainWindow(),
'Warning', message)
1227 """ Displays info message.
1229 QMessageBox.about(self.
mainWindow(),
'Info', message)
1231 def showMessageBox(self, text, informativeText="", standardButtons=QMessageBox.Ok | QMessageBox.Cancel | QMessageBox.Ignore, defaultButton=QMessageBox.Ok, extraButtons=None):
1232 """ Shows a standardized message box and returns the pressed button.
1234 See documentation on Qt's QMessageBox for a list of possible standard buttons.
1238 msgBox.setParent(self.
mainWindow(), Qt.Sheet)
1239 msgBox.setText(text)
1240 msgBox.setInformativeText(informativeText)
1241 msgBox.setStandardButtons(standardButtons)
1242 if extraButtons!=
None:
1243 for button,role
in extraButtons:
1244 msgBox.addButton(button,role)
1245 msgBox.setDefaultButton(defaultButton)
1246 return msgBox.exec_()
1249 """ Opens file given as argument if possible in Vispa.
1251 If Vispa cannot handle the file type the file will be opened in it's default application.
1253 logging.debug(self.__class__.__name__ +
": doubleClickOnFile() - " + str(filename))
1258 baseName = os.path.basename(filename)
1259 ext = os.path.splitext(baseName)[1].lower().strip(
".")
1262 if os.path.exists(filename):
1268 if 'Windows' in platform.system():
1269 os.startfile(filename)
1270 elif 'Darwin' in platform.system():
1271 if os.access(filename, os.X_OK):
1272 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.")
1274 subprocess.call((
"open", filename))
1275 elif 'Linux' in platform.system():
1277 if os.access(filename, os.X_OK):
1278 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.")
1282 subprocess.call((
"xdg-open", filename))
1285 subprocess.call((
"gnome-open", filename))
1287 logging.error(self.__class__.__name__ +
": doubleClickOnFile() - Platform '" + platform.platform() +
"'. Cannot open file. I Don't know how!")
1289 logging.error(self.__class__.__name__ +
": doubleClickOnFile() - Platform '" + platform.platform() +
"'. Error while opening file: " + str(filename))
1298 if len(self._workingMessages.keys()) == 0:
1299 self._progressWidget.start()
1300 self._window.statusBar().showMessage(message +
"...")
1303 self._progressWidget.setToolTip(message)
1307 if not id
in self._workingMessages.keys():
1308 logging.error(self.__class__.__name__ +
": stopWorking() - Unknown id %s. Aborting..." % str(id))
1310 if len(self._workingMessages.keys()) > 1:
1311 self._window.statusBar().showMessage(self.
_workingMessages[self._workingMessages.keys()[0]] +
"...")
1312 self._progressWidget.setToolTip(self.
_workingMessages[self._workingMessages.keys()[0]])
1314 self._progressWidget.stop()
1315 self._progressWidget.setToolTip(
"")
1316 self._window.statusBar().showMessage(self.
_workingMessages[id] +
"... " + end +
".")
1320 self.
mainWindow().tabWidget().setCurrentIndex(i)
1324 self._window.statusBar().showMessage(message, timeout)
1327 """ Cancel operations in current tab.
1329 logging.debug(__name__ +
": cancel")
1332 except NoCurrentTabControllerException:
_knownExtensionsDictionary
def updateMenuAndWindowTitle
string TAB_PREMATURELY_CLOSED_WARNING
string FAILED_LOADING_PLUGINS_ERROR
def _readCommandLineAttributes
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
def _collectFileExtensions
void clear(CLHEP::HepGenMatrix &m)
Helper function: Reset all elements of a matrix to 0.
def clearMissingRecentFiles
def _setCommandLineOptions
def setCurrentTabController
static std::string join(char **cmd)
int MAX_VISIBLE_UNDO_EVENTS
def _initCommandLineAttributes
int MAX_VISIBLE_RECENT_FILES
def recentFilesFromPlugin