def ask_password_dialog(parent, title, prompt, timeout = None): if parent is None: app = qt4tools.create_qapplication() translator = qt4tools.get_translator() app.installTranslator(translator) import icon dialog = QInputDialog() timer = QTimer() if not timeout is None: dialog.connect(timer, SIGNAL("timeout()"), dialog.reject) timer.setInterval(timeout * 1000) timer.start() dialog.setWindowIcon(icon.BIT_LOGO) dialog.setWindowTitle(title) dialog.setLabelText(prompt) dialog.setTextEchoMode(QLineEdit.Password) QApplication.processEvents() ret = dialog.exec_() timer.stop() if ret: password = dialog.textValue() else: password = '' del(dialog) return(password)
def _create_folder(self): DEBUG("Creating a folder...") current_item = self.currentItem() qinput = QInputDialog(self) qinput.setInputMode(QInputDialog.TextInput) qinput.setWindowTitle(self.tr("Nueva Carpeta")) qinput.setLabelText(self.tr("Nombre:")) qinput.resize(400, 100) ok = qinput.exec_() folder_name = qinput.textValue() if ok: path = os.path.join(current_item.path, folder_name) if os.path.exists(path): QMessageBox.information(self, self.tr("Información"), self.tr("La carpeta ya existe"), QMessageBox.Yes) DEBUG("The folder already exists...") return # Creo la carpeta os.mkdir(path) # Agrego el ítem al árbol folder_item = TreeItem(current_item, [folder_name]) folder_item.path = path folder_item.isFile = False folder_item.setExpanded(True)
def ask_password_dialog(parent, title, prompt, timeout=None): if parent is None: qt4tools.create_qapplication() import icon dialog = QInputDialog() timer = QTimer() if not timeout is None: dialog.connect(timer, SIGNAL("timeout()"), dialog.reject) timer.setInterval(timeout * 1000) timer.start() dialog.setWindowIcon(icon.BIT_LOGO) dialog.setWindowTitle(title) dialog.setLabelText(prompt) dialog.setTextEchoMode(QLineEdit.Password) QApplication.processEvents() ret = dialog.exec_() timer.stop() if ret: password = dialog.textValue() else: password = '' del (dialog) return (password)