def __removeFile(path): try: remove(path) except OSError, e: print >> stderr, e d = errorDialog("Error Deleting File...", str(e)) d.spawn()
def __removeDirectory(path): try: rmtree(path) except OSError, e: print >> stderr, e d = errorDialog("Error Deleting Directory...", str(e)) d.spawn()
def __removeDirectory(path): try: rmtree(path) except OSError, e: print >>stderr, e d = errorDialog("Error Deleting Directory...", str(e)) d.spawn()
def __saveFile(file): """ Private method to write file to desk """ # Save the file print "Attempting to save " + file.path try: f=open(file.path, 'w') datalist = file.data for row in datalist: if row[0] is not None: c1 = row[0] else: c1 = "" if row[1] is not None: c2 = row[1] else: c2 = "" if row[0].strip().startswith("#"): f.write(c1 + c2 + "\n") else: f.write(c1 + " " + c2 + "\n") f.close() __fileSaved(file) except IOError, e: print >>stderr, "Error saving: ", e d = errorDialog("Error Saving...", str(e)) d.spawn()
def __removeFile(path): try: remove(path) except OSError,e: print >>stderr,e d = errorDialog("Error Deleting File...", str(e)) d.spawn()
def __writeRenamedFile(oldFile, newFile): """ Performs the actual renaming of the file """ try: rename(oldFile, newFile) print oldFile + " renamed to " + newFile except OSError, e: print >> stderr, "Rename: ", e d = errorDialog("Error Renaming...", str(e)) d.spawn()
def ensureNotModified(msg): """ Ensure no files have been modified before proceeding, returns True if nothing is modified. If false a dialog is presented to the user """ if hasModified(): #inform user to save d = errorDialog("Unsaved Files Found...", msg) d.spawn() return False else: return True
def __saveToDisk(nFile): print "Saving new file: " + nFile try: f=open(nFile, 'w') f.write("# " + nFile + "\n") f.write("# Created by GPytage\n") f.close except IOError, e: print >>stderr, e d = errorDialog("Error Creating File...", str(e)) d.spawn()
def __saveToDisk(nFile): print "Saving new file: " + nFile try: f = open(nFile, 'w') f.write("# " + nFile + "\n") f.write("# Created by GPytage\n") f.close except IOError, e: print >> stderr, e d = errorDialog("Error Creating File...", str(e)) d.spawn()
def __init__(self): QtWidgets.QMainWindow.__init__(self) self.process = QtCore.QProcess() dock = QtWidgets.QDockWidget(self.tr(getLanguage_left_panel_title()), self) # The dock be non movable, non closable and non floatable by the user. dock.setFeatures(QtWidgets.QDockWidget.NoDockWidgetFeatures) dock.font().setBold(True) # dock.setFont( QtGui.QFont(dock.font()) ) self.contentsWidget = QtWidgets.QListWidget(dock) self.contentsWidget.setSpacing(1) self.contentsWidget.setAlternatingRowColors(True) self.contentsWidget.setIconSize(QtCore.QSize(32, 32)) self.textBrowser = QtWidgets.QTextBrowser() self.textBrowser.setOpenLinks(False) self.setCentralWidget(self.textBrowser) # When an URL is clicked in the central widget (text widget), # the corresponding program is launched self.textBrowser.anchorClicked.connect(self.launchProgram) # When the item (category) in the list widget is changed we change the # page seen in the text browser, that will include information taken from # the .desktop files in that category (folder in CONFIG_DIR). self.contentsWidget.currentItemChanged[QListWidgetItem, QListWidgetItem].connect( self.changePage) # initialize (populates) the main window # This populates the dock with the list of categories self.initContentsWidget() # Set the initially highligted category to be the first one. self.contentsWidget.setCurrentRow(0) # set the widget for the dock widget to the list of categories # whose we just defined the layout in initContentsWidget. # This implicitely shows (displays) the widget as the dock widget # was not yet visible dock.setWidget(self.contentsWidget) helpButton = QtWidgets.QPushButton( QtGui.QIcon("/usr/share/qcontrolcenter/icons/info.png"), "") quitButton = QtWidgets.QPushButton( QtGui.QIcon("/usr/share/qcontrolcenter/icons/exit.png"), "") self.statusBar().addPermanentWidget(helpButton, 0) self.statusBar().addPermanentWidget(quitButton, 0) helpButton.clicked.connect(self.showAbout) quitButton.clicked.connect(self.close) self.addDockWidget(QtCore.Qt.LeftDockWidgetArea, dock) self.setWindowTitle(self.tr(getWindowTitle())) self.setWindowIcon(QtGui.QIcon("icons/arch-logo.png")) self.setMinimumSize(640, 480) if not os.path.exists(CONFIG_DIR): if not os.path.exists('/etc/skel/.qcontrolcenter'): errorDlg = errorDialog(self) errorDlg.show()
def __scanFileContents(self, filepath): """ Return data in specified file in a list of a list [[col1, col2]]""" data = [] #list of list: eg [['python','x86']] try: f = open(filepath, 'r') contents = f.readlines() f.close() except IOError, e: #needed or everything breaks contents = None print >>stderr, e from errorDialog import errorDialog d = errorDialog("Error Reading File...", str(e)) d.spawn() return data