def on_btn_beautify_clicked(self): try: try: from css_html_prettify import css_prettify except: _t = QMessageBox.question(self, "Can't beautify", "Python package \"css_html_prettify\" could not be loaded.\nDo you want to try installing it now?", QMessageBox.Yes, QMessageBox.No) if _t == QMessageBox.Yes: from devtools import PluginInstaller PluginInstaller().installPackages(['css_html_prettify']) self.on_btn_beautify_clicked() return #import traceback; QMessageBox.Critical("Can't minify", traceback.format_exc()).exec_() index = self.tabWidget.currentIndex _old = "" if index == 0: _old = self.qssEditor.toPlainText() elif index == 1: _old = self.chatEditor.toPlainText() _beautified = css_prettify(_old) if index == 0: QApplication.instance().styleSheet = _beautified self.qssEditor.setPlainText(_beautified) elif index == 1: self.chatEditor.setPlainText(_beautified);return if QMessageBox(QMessageBox.Warning, "Use minified QSS?", "Your minified QSS code has been applied.\n\nIf you encounter any issues with the minified code you should click on cancel.", QMessageBox.Ok | QMessageBox.Cancel).exec_() == QMessageBox.Cancel: QApplication.instance().styleSheet = _old self.qssEditor.setPlainText(_old) except: try: from traceback import format_exc QMessageBox(QMessageBox.Critical, "Can't beautify", format_exc()).exec_() except: print(format_exc())
def confirm(self, title, message): x = QDialog() x.setAttribute(Qt.WA_DeleteOnClose) _t = QMessageBox.question(x, title, message, QMessageBox.Yes, QMessageBox.No) if _t == QMessageBox.Yes: return True else: return False
def deleteFiles(self, files=None): if self.readonly: return if not files: selfiles = self.selectedFiles() else: selfiles = files if not selfiles: return if QMessageBox.question( self, self._tr("Delete files"), self._tr("Do you really want to delete all " "selected files?")) == QMessageBox.No: return pathes = [f.fullpath for f in selfiles] self.delretcode = ts3lib.createReturnCode() err = ts3lib.requestDeleteFile(self.schid, self.cid, self.password, pathes, self.delretcode) if err != ERROR_ok: self.showError(self._tr("Error deleting files"), err)
def confirm(title, message): """ :param title: :param message: :return: """ x = QWidget() x.setAttribute(Qt.WA_DeleteOnClose) _x = QMessageBox.question(x, title, message, QMessageBox.Yes, QMessageBox.No) if _x == QMessageBox.Yes: return True if _x == QMessageBox.Yes else False
def updateReply(self, reply): version = loads(reply.readAll().data().decode('utf-8'))["version"] if version != self.version: x = QDialog() x.setAttribute(Qt.WA_DeleteOnClose) _x = QMessageBox.question( x, "{} v{} by {}".format(self.name, self.version, self.author), "Noua versiune v{} la linksteam a fost gasita, dai update acum?" .format(version), QMessageBox.Yes, QMessageBox.No) if _x == QMessageBox.Yes: QDesktopServices.openUrl(QUrl(self.repourl))
def on_btn_beautify_clicked(self): try: try: from bs4 import BeautifulSoup except Exception: from traceback import format_exc print("Error: {0}".format(format_exc())) _t = QMessageBox.question( self, "Can't beautify", "Python package \"beautifulsoup4\" could not be loaded.\nDo you want to try installing it now?", QMessageBox.Yes, QMessageBox.No) if _t == QMessageBox.Yes: from devtools import PluginInstaller PluginInstaller().installPackages(['beautifulsoup4']) self.on_btn_beautify_clicked() return #import traceback; QMessageBox.Critical("Can't minify", traceback.format_exc()).exec_() index = self.tabWidget.currentIndex _old = "" if index == 0: _old = self.qssEditor.toPlainText() elif index == 1: _old = self.chatEditor.toPlainText() elif index == 2: _old = self.tplEditor.toPlainText() elif index == 3: _old = self.chatEditor_html.toPlainText() _beautified = BeautifulSoup(_old) _beautified = _beautified.prettify() if index == 0: QApplication.instance().styleSheet = _beautified self.qssEditor.setPlainText(_beautified) elif index == 1: self.chatEditor.setPlainText(_beautified) return elif index == 2: self.tplEditor.setPlainText(_beautified) return elif index == 3: self.chatEditor_html.setPlainText(_beautified) return if QMessageBox( QMessageBox.Warning, "Use beautified code?", "Your beautified code has been applied.\n\nIf you encounter any issues with the beautified code you should click on cancel.", QMessageBox.Ok | QMessageBox.Cancel).exec_() == QMessageBox.Cancel: QApplication.instance().styleSheet = _old self.qssEditor.setPlainText(_old) except: try: from traceback import format_exc QMessageBox(QMessageBox.Critical, "Can't beautify", format_exc()).exec_() except: print(format_exc())
def on_siteremoveButton_clicked(self): ids = {it.data(Qt.UserRole) for it in self.siteTable.selectedItems()} if ids: if (QMessageBox.question(self, self._tr("Remove site packages"), self._tr("Are you sure to remove the " "selected packages? Some " "plugins might not work " "properly.")) == QMessageBox.Yes): try: for idx in ids: devtools.removePackage(self.sitepkgs[idx]["name"], self.sitepkgs[idx]["version"]) except Exception as e: QMessageBox.critical(self, self._tr("Error"), str(e)) self.reloadSite()
def deleteFiles(self, files=None): if self.readonly: return if not files: selfiles = self.selectedFiles() else: selfiles = files if not selfiles: return if QMessageBox.question(self, self._tr("Delete files"), self._tr("Do you really want to delete all " "selected files?")) == QMessageBox.No: return pathes = [f.fullpath for f in selfiles] self.delretcode = ts3lib.createReturnCode() err = ts3lib.requestDeleteFile(self.schid, self.cid, self.password, pathes, self.delretcode) if err != ERROR_ok: self.showError(self._tr("Error deleting files"), err)