Example #1
0
 def insert_item(self):
     """Insert item"""
     index = self.currentIndex()
     if not index.isValid():
         row = self.model.rowCount()
     else:
         row = index.row()
     data = self.model.get_data()
     if isinstance(data, list):
         key = row
         data.insert(row, '')
     elif isinstance(data, dict):
         key, valid = QInputDialog.getText(self,
                           translate("DictEditor", 'Insert'),
                           translate("DictEditor", 'Key:'),
                           QLineEdit.Normal)
         if valid and not key.isEmpty():
             key = try_to_eval(unicode(key))
         else:
             return
     else:
         return
     value, valid = QInputDialog.getText(self,
               translate("DictEditor", 'Insert'),
               translate("DictEditor", 'Value:'),
               QLineEdit.Normal)
     if valid and not value.isEmpty():
         self.new_value(key, try_to_eval(unicode(value)))
Example #2
0
    def __new_graph(self):

        if self.project is None:
            return

        graph, ok = QInputDialog.getText(
            self.__iface.mainWindow(),
            "Graph",
            "Graph name:",
            QLineEdit.Normal,
            "test_graph",
        )

        if not ok:
            return

        parent, ok = QInputDialog.getText(
            self.__iface.mainWindow(),
            "Parent Graph",
            "Parent Graph name:",
            QLineEdit.Normal,
            "",
        )

        if not ok:
            return

        self.project.new_graph(graph, parent)
        self.__current_graph.addItem(graph)
        self.__current_graph.setCurrentIndex(
            self.__current_graph.findText(graph))
 def onCargajuegoClicked(self):
     """Nos permite Cargar un juego anteriormente guardado"""
     (nombre,ok) = QInputDialog.getText(self, self.tr("Sudoku"), self.tr("Nombre:"),QLineEdit.Normal, self.tr(""))
     if ok==True:
         while str(nombre)=="" and ok==True:
             self.MessageBox(None,"Ingrese Un Nombre..!","ERROR",self.MB_ICONERROR)
             (nombre,ok) = QInputDialog.getText(self, self.tr("Sudoku"), self.tr("Nombre:"),QLineEdit.Normal, self.tr(""))
         if ok==True:
             archivo=open("Partidas.txt","r")
             linea=archivo.readline()
             Existe=0
             while linea!="":
                 partida=linea.split(",")
                 nombreG=partida[0]
                 if str(nombre)==nombreG:
                     Existe=1
                     break
                 linea=archivo.readline()
             if Existe==1:
                 invalida=partida[3]
                 incorrecta=partida[4]
                 ayuda=partida[5]
                 self.n= Sudoku(5,invalida,incorrecta,ayuda,partida)
                 self.n.setVisible(True)
                 self.close()
             else:
                 self.MessageBox(None,"No Se Encontro El Archivo..!","ERROR",self.MB_ICONERROR)
             archivo.close()
Example #4
0
 def insert_item(self):
     """Insert item"""
     index = self.currentIndex()
     if not index.isValid():
         row = self.model.rowCount()
     else:
         row = index.row()
     data = self.model.get_data()
     if isinstance(data, list):
         key = row
         data.insert(row, '')
     elif isinstance(data, dict):
         key, valid = QInputDialog.getText(
             self, translate("DictEditor", 'Insert'),
             translate("DictEditor", 'Key:'), QLineEdit.Normal)
         if valid and not key.isEmpty():
             key = try_to_eval(unicode(key))
         else:
             return
     else:
         return
     value, valid = QInputDialog.getText(self,
                                         translate("DictEditor", 'Insert'),
                                         translate("DictEditor", 'Value:'),
                                         QLineEdit.Normal)
     if valid and not value.isEmpty():
         self.new_value(key, try_to_eval(unicode(value)))
Example #5
0
def getStringMsg( title, text, preset=None ):
    if preset is None:
        (ans, ok) = QInputDialog.getText(IMC.mainWindow, title, text)
    else:
        (ans, ok) = QInputDialog.getText(IMC.mainWindow, title, text,
                                         QLineEdit.Normal, preset)
    return (ans, ok)
 def onActionguardarTriggered(self):
     """Guarda la partida actual
         Se pide el nombre con el que se desea guardar la partida y luego se procede a grabarla con encriptacion."""
     (nombre,ok) = QInputDialog.getText(self, self.tr("Sudoku"), self.tr("Nombre:"),QLineEdit.Normal, self.tr(""))
     if ok==True:
         while str(nombre)=="" and ok==True:
             self.MessageBox(None,"Ingrese Un Nombre..!","ERROR",self.MB_ICONERROR)
             (nombre,ok) = QInputDialog.getText(self, self.tr("Sudoku"), self.tr("Nombre:"),QLineEdit.Normal, self.tr(""))
         if ok==True:
             solucion=open("Resueltos.txt","a")
             solucion.write(str(nombre))
             solucion.write(",")
             for i in range(9):
                 for j in range(9):
                     solucion.write(str(self.resuelto[i][j]))
             solucion.write("\n")
             solucion.close()
             archivo=open("Partidas.txt","a")
             archivo.write(str(nombre))
             archivo.write(",")
             for i in range(9):
                 for j in range(9):
                     if self.numeros[i][j]==0:
                         archivo.write("j")
                     elif self.numeros[i][j]==1:
                         archivo.write("n")
                     elif self.numeros[i][j]==2:
                         archivo.write("l")
                     elif self.numeros[i][j]==3:
                         archivo.write("d")
                     elif self.numeros[i][j]==4:
                         archivo.write("y")
                     elif self.numeros[i][j]==5:
                         archivo.write("s")
                     elif self.numeros[i][j]==6:
                         archivo.write("t")
                     elif self.numeros[i][j]==7:
                         archivo.write("v")
                     elif self.numeros[i][j]==8:
                         archivo.write("a")
                     else:
                         archivo.write("e")
             archivo.write(",")
             archivo.write(self.cronometro)
             if self.invalida:
                 archivo.write(",1")
             else:
                 archivo.write(",0")
             if self.incorrecta:
                 archivo.write(",1")
             else:
                 archivo.write(",0")
             if self.ayuda:
                 archivo.write(",1")
             else:
                 archivo.write(",0")
             archivo.write("\n")
             archivo.close()
             self.MessageBox(None,"Partida Guardada..!","Sudoku",self.MB_ICONEXCLAMATION)
Example #7
0
 def on_importGoogleContactsButton_clicked(self):
     googleUsername, ok = QInputDialog.getText(self, 'Google Username', 'Enter your Google username/email', text=getConfig('googleUsername', ''))
     if not ok:
         return
     googlePassword, ok = QInputDialog.getText(self, 'Google Password', 'Enter your Google password', mode=QLineEdit.Password)
     if not ok:
         return
     setConfig('googleUsername', googleUsername)
     self.import_google_contacts_signal.emit(googleUsername, googlePassword)
Example #8
0
 def writeConfiguration():
     key, ok = QInputDialog.getText(self, "Write Config Value", "Key:")
     if (not ok) or (not key):
         utils.informationBox("Cancelled.")
         return
     value, ok = QInputDialog.getText(self, "Write Config Value", "Value:")
     if (not ok) or (not value):
         utils.informationBox("Cancelled.")
         return
     self.config.writeConf(key, value)
Example #9
0
 def editContact(self, name='', conversationId=''):
     phone = conversationId.split('@')[0]
     if len(phone) == 0 or phone[0] != '+':
         phone = '+' + phone
     name, ok = QInputDialog.getText(self, 'Contact Name', 'Enter this contact\'s name', text=name)
     if not ok:
         return
     phone, ok = QInputDialog.getText(self, 'Contact Phone', 'Enter this contact\'s phone number\n(leading with a "+" and your country code)', text=phone)
     if not ok:
         return
     self.update_contact_signal.emit(name, phone)
Example #10
0
    def _add_new_file(self):
        item = self.currentItem()
        if item.parent() is None:
            pathForFile = item.path
        else:
            pathForFile = os.path.join(item.path, item.text(0))
        result = QInputDialog.getText(self, self.tr("New File"),
                                      self.tr("Enter the File Name:"))
        fileName = result[0]

        if result[1] and fileName.strip() != '':
            try:
                fileName = os.path.join(pathForFile, fileName)
                fileName = file_manager.store_file_content(fileName,
                                                           '',
                                                           newFile=True)
                name = file_manager.get_basename(fileName)
                subitem = ProjectItem(item, name, pathForFile)
                subitem.setToolTip(0, name)
                subitem.setIcon(0, self._get_file_icon(name))
                mainContainer = main_container.MainContainer()
                mainContainer.open_file(fileName)
            except file_manager.NinjaFileExistsException as ex:
                QMessageBox.information(
                    self, self.tr("File Already Exists"),
                    self.tr("Invalid Path: the file '%s' already exists." %
                            ex.filename))
Example #11
0
 def exportLayer(self):
     if self.tabWidget.count() != 0:
         index = self.tabWidget.currentIndex()
         table = self.tabWidget.widget(index).findChildren(QtGui.QTableWidget)[0]
         items = table.selectedItems()
         if len(items) > 0:
             type = ''
             if items[0].feature.geometry().type() == QGis.Point:
                 type = 'Point'
             elif items[0].feature.geometry().type() == QGis.Line:
                 type = 'LineString'
             else:
                 type = 'Polygon'
             features = []
             for item in items:
                 if item.feature not in features:
                     features.append(item.feature)
             name = ''
             ok = True
             while not name.strip() and ok == True:
                 name, ok = QInputDialog.getText(self, self.tr('Layer name'), self.tr('Give a name to the layer:'))
             if ok:
                 layer = QgsVectorLayer(type+"?crs="+table.crs.authid(),name,"memory")
                 layer.startEditing()
                 layer.dataProvider().addFeatures(features)
                 layer.dataProvider().addAttributes(features[0].fields().toList())
                 layer.commitChanges()
                 QgsMapLayerRegistry.instance().addMapLayer(layer)
         else:
             self.mb.pushMessage(self.tr('Warning'), self.tr('There is no selected feature !'), level=QgsMessageBar.WARNING, duration=3)
Example #12
0
 def _add_file_to_project(self, path):
     """Add the file for 'path' in the project the user choose here."""
     if self._active_project:
         pathProject = [self._active_project.project]
         addToProject = add_to_project.AddToProject(pathProject, self)
         addToProject.exec_()
         if not addToProject.pathSelected:
             return
         main_container = IDE.get_service('main_container')
         if not main_container:
             return
         editorWidget = main_container.get_current_editor()
         if not editorWidget.file_path:
             name = QInputDialog.getText(None,
                                         translations.TR_ADD_FILE_TO_PROJECT,
                                         translations.TR_FILENAME + ": ")[0]
             if not name:
                 QMessageBox.information(
                     self,
                     translations.TR_INVALID_FILENAME,
                     translations.TR_INVALID_FILENAME_ENTER_A_FILENAME)
                 return
         else:
             name = file_manager.get_basename(editorWidget.file_path)
         new_path = file_manager.create_path(addToProject.pathSelected, name)
         ide_srv = IDE.get_service("ide")
         old_file = ide_srv.get_or_create_nfile(path)
         new_file = old_file.save(editorWidget.get_text(), new_path)
         #FIXME: Make this file replace the original in the open tab
     else:
         pass
 def _add_file_to_project(self, path):
     """Add the file for 'path' in the project the user choose here."""
     if self._active_project:
         pathProject = [self._active_project.project]
         addToProject = add_to_project.AddToProject(pathProject, self)
         addToProject.exec_()
         if not addToProject.pathSelected:
             return
         main_container = IDE.get_service('main_container')
         if not main_container:
             return
         editorWidget = main_container.get_current_editor()
         if not editorWidget.file_path:
             name = QInputDialog.getText(None,
                 self.tr("Add File To Project"), self.tr("File Name:"))[0]
             if not name:
                 QMessageBox.information(self, self.tr("Invalid Name"),
                     self.tr("The file name is empty, please enter a name"))
                 return
         else:
             name = file_manager.get_basename(editorWidget.file_path)
         new_path = file_manager.create_path(addToProject.pathSelected, name)
         ide_srv = IDE.get_service("ide")
         old_file, ide_srv.get_or_create_nfile(path)
         new_file = old_file.save(editorWidget.get_text(), path)
         #FIXME: Make this file replace the original in the open tab
     else:
         pass
Example #14
0
    def test_ldap(self):
        dc, base, uri, filter, password = self.specific_config.generateTest()
        if uri is None or uri == '':
            QMessageBox.critical(
                self,
                "Missing data",
                "Please fill URI field"
                )
            return
        if dc is None:
            dc == ''

        filter, ok = QInputDialog.getText(
            self,
            tr("LDAP Filter"),
            tr("Please enter a filter:"),
            QLineEdit.Normal,
            filter
            )

        if not ok:
            return

        async = self.mainwindow.client.async()
        async.call(
            'nuauth',
            'testLDAP',
            dc, base, uri, unicode(filter), password,
            callback = self.success_test,
            errback = self.error_test
            )
Example #15
0
    def newExperiment(self):
        if self.dirty:
            success = self.showDirtySaveBox()
            if not success:
                return False

        basePath = str(QFileDialog.getExistingDirectory(self, "New experiment storage path:", EXPERIMENT_DIR))
        if basePath == "":
            return False

        basePath = basePath.replace(os.getcwd() + "/", "")

        name, accepted = QInputDialog.getText( self, "Experiment Name", "New experiment name:")
        if not accepted:
            return False

        name = str(name)

        self.resetUI()
        self.enableUI()

        self.storage = FileStorage(name, basePath)
        self.experiment = self.storage.base

        self.ui.nameText.setText(name)
        return True
Example #16
0
 def _add_file_to_project(self, path):
     pathProject = [self.ide.explorer.get_actual_project()]
     addToProject = ui_tools.AddToProject(pathProject, self.ide)
     addToProject.exec_()
     if not addToProject.pathSelected:
         return
     editorWidget = self.ide.mainContainer.get_actual_editor()
     if not editorWidget.ID:
         name = unicode(QInputDialog.getText(None,
             self.tr("Add File To Project"), self.tr("File Name:"))[0])
         if not name:
             QMessageBox.information(self, self.tr("Invalid Name"),
                 self.tr("The file name is empty, please enter a name"))
             return
     else:
         name = file_manager.get_basename(editorWidget.ID)
     path = file_manager.create_path(
         unicode(addToProject.pathSelected), name)
     try:
         path = file_manager.store_file_content(
             path, editorWidget.get_text(), newFile=True)
         editorWidget.ID = path
         self.ide.explorer.add_existing_file(path)
         self.ide.change_window_title(path)
         name = file_manager.get_basename(path)
         self.ide.mainContainer.actualTab.setTabText(
             self.ide.mainContainer.actualTab.currentIndex(), name)
         editorWidget._file_saved()
     except file_manager.NinjaFileExistsException, ex:
         QMessageBox.information(self, self.tr("File Already Exists"),
             self.tr("Invalid Path: the file '%s' already exists." % \
                 ex.filename))
Example #17
0
    def __new_project(self):

        # @todo open dialog to configure project name and srid
        fil = QFileDialog.getSaveFileName(
            None,
            u"New project name (no space, plain ascii)",
            QgsProject.instance().readEntry("albion", "last_dir", "")[0],
            "QGIS poject file (*.qgs)",
        )
        if not fil:
            return
        fil = fil if len(fil) > 4 and fil[-4:] == ".qgs" else fil + ".qgs"
        fil = fil.replace(" ", "_")
        try:
            fil.decode("ascii")
        except UnicodeDecodeError:
            self.__iface.messageBar().pushError(
                "Albion:",
                "project name may only contain asci character (no accent)")
            return

        srid, ok = QInputDialog.getText(
            self.__iface.mainWindow(),
            "Project SRID",
            "Project SRID EPSG:",
            QLineEdit.Normal,
            "32632",
        )
        if not ok:
            return
        srid = int(srid)

        project_name = str(os.path.split(fil)[1][:-4])

        if Project.exists(project_name):
            if (QMessageBox.Yes != QMessageBox(
                    QMessageBox.Information,
                    "Delete existing DB",
                    "Database {} exits, to you want to delete it ?".format(
                        project_name),
                    QMessageBox.Yes | QMessageBox.No,
            ).exec_()):
                return
            Project.delete(project_name)

        self.__iface.messageBar().pushInfo("Albion:", "creating project...")
        Project.create(project_name, srid)

        # load template
        open(fil, "w").write(
            open(resource("template_project.qgs")).read().replace(
                "template_project", project_name))
        self.__iface.newProject()
        QgsProject.instance().setFileName(fil)
        QgsProject.instance().read()
        QgsProject.instance().writeEntry("albion", "project_name",
                                         project_name)
        QgsProject.instance().writeEntry("albion", "srid", srid)
        QgsProject.instance().write()
        self.__qgis__project__loaded()
Example #18
0
 def createDump(self):
     text, ok = QInputDialog.getText(self, "Create dump", "dump name:",
                                     QLineEdit.Normal,
                                     "k800-restore-" + str(self.dumpnumber))
     if ok and text != "":
         if (self.vfs.getnode(self.nand.absolute() + "/" +
                              str(text)) == None):
             self.dumpnumber += 1
             newroot = Node(str(text))
             newroot.__disown__()
             for id in range(0, len(self.tables.tablesIdWriteMap) - 1):
                 write = int(
                     str(self.gtable.cellWidget(id, 0).currentText()), 16)
                 self.tables.map[id] = self.tables.tablesIdWriteMap[id][
                     write]
             virtual = VirtualMap(self, newroot, self.fullFs, self.tables,
                                  "virtual", self.blockSize)
             separt = SEPartitionBlock(virtual, self.boot.partitionblock,
                                       self.blockSize)
             self.createPart(separt, newroot, virtual)
             self.registerTree(self.nand, newroot)
         else:
             box = QMessageBox(QMessageBox.Warning, "Error",
                               "Error node already exists",
                               QMessageBox.NoButton, self)
             box.exec_()
             self.createDump()
    def rename(self):
        # get new name and confirm change
        curItem = self.form.listWidget.currentItem()
        name = unicode(curItem.text())
        text, didEnter = QInputDialog.getText(self, "Rename Class",
                "Rename to:", text=name)
        if not didEnter:
            return
        if not text:
            utils.errorBox("You must enter a name for the class.",
                    "No name provided")
            return
        if text == name:
            return # assume user meant to cancel

        # check for dupes
        text = unicode(text)
        if db.classes.isDupe(text):
            utils.errorBox("You already have a class by that name.",
                    "Duplicate Entry")
            return

        # update state, db, and listbox
        rClass = db.classes.getClassByName(name)
        rClass.setName(text)
        curItem.setData(0, text)
Example #20
0
    def showTempPasswordDialog(self):
        """ Sets overridePassword for a server.
        Using this one doesn't actually have to enter the password
        in the ServerDialog (and by extension save to disk).
        """
        serverList = ServerList()

        # Create a stringlist to be used by the qinputdialog
        stringList = []
        for server in serverList.getTable():
            stringList.append(server.name)

        # Display list of servers
        (serverString, ok) = QInputDialog.getItem(
            self,
            QApplication.translate("MainWindow", "Select server"),
            QApplication.translate("MainWindow", "Server:"),
            stringList,
            editable=False)
        if ok:
            server = serverList.getServerObjectByName(serverString)
            if server != None:
                # Ask for password
                (value, ok) = QInputDialog.getText(
                    self,
                    QApplication.translate("MainWindow", "Temporary password"),
                    QApplication.translate("MainWindow", "Enter password:"),
                    QLineEdit.Password)
                if ok:
                    # Use value as the overridePassword for the server.
                    LumaConnection(server).overridePassword(value)
Example #21
0
 def onClickAddExpButton(self):
     self.tryApply(self.currIdx)
     if self.tmpPref['experimenter'] != self.parent().prm['experimenter']:
         conf = applyChanges(self)
         if conf.exec_():
             self.permanentApply()
         else:
             self.revertChanges()
     msg = self.tr("Experimenter's Identifier:")
     name, ok = QInputDialog.getText(self, self.tr('Input Dialog'), msg)
     if ok:
         self.tmpPref['experimenter']['defaultExperimenter'].append('')
         self.tmpPref['experimenter']['experimenter_id'].append(name)
         self.tmpPref['experimenter']['experimenter_name'].append('')
         self.tmpPref['experimenter']['experimenter_surname'].append('')
         self.tmpPref['experimenter']['experimenter_email'].append('')
         self.tmpPref['experimenter']['experimenter_address'].append('')
         self.tmpPref['experimenter']['experimenter_address2'].append('')
         self.tmpPref['experimenter']['experimenter_telephone'].append('')
         self.tmpPref['experimenter']['experimenter_mobile'].append('')
         self.permanentApply()
         self.currIdx = self.experimenterChooser.count() 
         self.experimenterNameTF.setText(self.tmpPref['experimenter']['experimenter_name'][self.currIdx])
         self.experimenterSurnameTF.setText(self.tmpPref['experimenter']['experimenter_surname'][self.currIdx])
         self.experimenterEmailTF.setText(self.tmpPref['experimenter']['experimenter_email'][self.currIdx])
         self.experimenterAddressTF.setText(self.tmpPref['experimenter']['experimenter_address'][self.currIdx])
         self.experimenterAddressTF2.setText(self.tmpPref['experimenter']['experimenter_address2'][self.currIdx])
         self.experimenterTelephoneTF.setText(self.tmpPref['experimenter']['experimenter_telephone'][self.currIdx])
         self.experimenterMobileTF.setText(self.tmpPref['experimenter']['experimenter_mobile'][self.currIdx])
         self.experimenterChooser.addItem(name)
         self.experimenterChooser.setCurrentIndex(self.currIdx)
Example #22
0
    def plotEIC(self):
        if self.flags == 'spectra':

            #show double combobox
            #select the good spectra then draw
            pass
        else:
            mass, ok = QInputDialog.getText(self.view, "EIC query", "mass:")
            if not (mass and ok):
                return
            xmlfile = self.fullXmlPath(self.selection[0].data().toString())
            if not xmlfile:
                xmlfile = self.fullXmlPath(
                    self.selection[0].parent().data().toString())
            if not xmlfile:
                print "item clicked not recognized..."
                return
            sample = self.model.sample(xmlfile)
            if sample.kind == 'HighRes':
                error = (sample.ppm / 1e6) * float(mass)
                x, y = massExtraction(sample, float(mass), error)
                from core.MetObjects import MSChromatogram
                chrom = MSChromatogram(x_data=x, y_data=y, sample=sample)
            else:
                chrom = sample.getChromWithTrans(math.ceil(float(mass)))
        self.view.addMdiSubWindow(
            MSQtCanvas([chrom],
                       "EIC %s" % str(mass),
                       labels={
                           'bottom': 'RT(s)',
                           'left': 'INTENSITY'
                       }))
 def _getValue(self, title, label, valueType=QVariant.String, defaultValue='', minValue=0, maxValue=0, decimals=0):
     if valueType == QVariant.Double:
         return QInputDialog.getDouble(None, title, label, defaultValue, minValue, maxValue, decimals)
     elif valueType == QVariant.Int:
         return QInputDialog.getInt(None, title, label, defaultValue, minValue, maxValue)
     else:
         return QInputDialog.getText(None, title, label, text=defaultValue)
Example #24
0
 def add_category(self):
     text, ok = QInputDialog.getText(self, 'Create new category',
                                     'Category name:')
     if ok:
         catItem = QStandardItem(text)
         catItem.setCheckable(True)
         self.model.appendRow(catItem)
Example #25
0
 def javaScriptPrompt(self, frame, msg, default):
     if USING_LIVE_ISO: return True, "live"
     res, ok = QInputDialog.getText(self.parent(),
                                    self.tr("MOD-App Prompt"),
                                    msg,
                                    QLineEdit.Normal, default)
     return ok, res
Example #26
0
def insert_debugging_prints(editorWidget):
    cursor = editorWidget.textCursor()
    if cursor.hasSelection():
        result = str(QInputDialog.getText(editorWidget,
            editorWidget.tr("Print Text"),
            editorWidget.tr("Insert a Text to use in the Print or "
                            "leave empty to just print numbers:"))[0])
        print_text = ""
        if result:
            print_text = "%s: " % result
        #begin Undo feature
        cursor.beginEditBlock()
        start = editorWidget.document().findBlock(
            cursor.selectionStart()).firstLineNumber()
        end = editorWidget.document().findBlock(
            cursor.selectionEnd()).firstLineNumber()
        lines = end - start
        for i in range(lines):
            position = editorWidget.document().findBlockByLineNumber(
                start + (i * 2)).position()
            cursor.setPosition(position)
            indentation = get_indentation(cursor.block().text())
            cursor.movePosition(QTextCursor.EndOfLine)
            cursor.insertText("\n%sprint('%s%i')" % (
                indentation, print_text, i))
        #end Undo feature
        cursor.endEditBlock()
Example #27
0
	def addNewFile(self, node):
		"""
		Adds a new file next to given Node associated path.

		:param node: Node.
		:type node: ProjectNode or DirectoryNode or FileNode
		:return: Method success.
		:rtype: bool
		"""

		if self.__scriptEditor.model.isAuthoringNode(node):
			return self.__scriptEditor.newFile()

		file, state = QInputDialog.getText(self, "Add File", "Enter your new file name:")
		if not state:
			return False

		if node.family in ("Project", "Directory"):
			directory = node.path
		elif node.family == "File":
			directory = os.path.dirname(node.path)

		# file = foundations.strings.toString(file)
		if not file in os.listdir(directory):
			file = os.path.join(directory, file)
			LOGGER.info("{0} | Adding '{1}' file!".format(self.__class__.__name__, file))
			open(file, "w").close()
		else:
			self.__raiseFileSystemException(file, directory)
		return True
 def _add_file_to_project(self, path):
     """Add the file for 'path' in the project the user choose here."""
     if self._active_project:
         pathProject = [self._active_project.project]
         addToProject = add_to_project.AddToProject(pathProject, self)
         addToProject.exec_()
         if not addToProject.pathSelected:
             return
         main_container = IDE.get_service('main_container')
         if not main_container:
             return
         editorWidget = main_container.get_current_editor()
         if not editorWidget.file_path:
             name = QInputDialog.getText(None,
                                         self.tr("Add File To Project"),
                                         self.tr("File Name:"))[0]
             if not name:
                 QMessageBox.information(
                     self, self.tr("Invalid Name"),
                     self.tr("The file name is empty, please enter a name"))
                 return
         else:
             name = file_manager.get_basename(editorWidget.file_path)
         new_path = file_manager.create_path(addToProject.pathSelected,
                                             name)
         ide_srv = IDE.get_service("ide")
         old_file, ide_srv.get_or_create_nfile(path)
         new_file = old_file.save(editorWidget.get_text(), path)
         #FIXME: Make this file replace the original in the open tab
     else:
         pass
Example #29
0
	def addNewDirectory(self, node):
		"""
		Adds a new directory next to given Node associated path.

		:param node: Node.
		:type node: ProjectNode or DirectoryNode or FileNode
		:return: Method success.
		:rtype: bool
		"""

		if self.__scriptEditor.model.isAuthoringNode(node):
			return False

		directory, state = QInputDialog.getText(self, "Add Directory", "Enter your new directory name:")
		if not state:
			return False

		if node.family in ("Project", "Directory"):
			parentDirectory = node.path
		elif node.family == "File":
			parentDirectory = os.path.dirname(node.path)

		directory = foundations.strings.toString(directory)
		if not directory in os.listdir(parentDirectory):
			directory = os.path.join(parentDirectory, directory)
			LOGGER.info("{0} | Adding '{1}' directory!".format(self.__class__.__name__, directory))
			os.makedirs(directory)
		else:
			self.__raiseFileSystemException(file, parentDirectory)
		return True
Example #30
0
    def pulsa_boton_crear_archivo_nuevo(self):
        text, ok = QInputDialog.getText(self, 'Crear un archivo nuevo',
                                        'Nombre del archivo:',
                                        QLineEdit.Normal, "nuevo")

        if ok and text:
            self.editor.crear_y_seleccionar_archivo(text)
Example #31
0
 def setArch(self):
     arch = self.store.getArch()
     arch, ok = QInputDialog.getText(self, 'Architecture Dialog',
          'Enter Architecture', QLineEdit.Normal, arch)
     arch = str(arch)
     if ok:
         self.store.setArch(arch)
Example #32
0
 def export(self):
   text, ok = QInputDialog.getText(self, "Advanced search", "Filter export name",\
                                     QLineEdit.Normal, "") 
   if ok and text != "":
     siNode = self.vfs.getnode("/Searched items")
     filtersNode = Node(str(text), 0, siNode, None)
     filtersNode.__disown__()
     filtersNode.setDir()
     e = event()
     e.thisown = False
     vnode = Variant(filtersNode)
     vnode.thisown = False
     e.value = vnode
     VFS.Get().notify(e)
     nb_row = self.model.rowCount()
     for i in range(0, nb_row):
       index = self.model.index(i, 0)
       if not index.isValid():
         continue
       data = self.model.data(index, Qt.CheckStateRole)
       if data == Qt.Checked or data == Qt.PartiallyChecked:
         n = VFS.Get().getNodeFromPointer(long(index.internalId()))
         l = VLink(n, filtersNode)
         l.__disown__()
   else:
     box = QMessageBox(QMessageBox.Warning, "Error", "Error node already exists", \
                         QMessageBox.NoButton, self)
     box.exec_()
Example #33
0
    def _onRename(self):
        """Handler for File->File System->Rename"""
        document = core.workspace().currentDocument()
        if document.qutepart.document().isModified() or \
           document.isExternallyModified() or \
           document.isExternallyRemoved() or \
           document.isNeverSaved():
            QMessageBox.warning(core.mainWindow(), 'Rename file', 'Save the file before renaming')
            return

        newPath, ok = QInputDialog.getText(core.mainWindow(), 'Rename file', 'New file name', text=document.filePath())
        if not ok:
            return

        if newPath == document.filePath():
            return

        if newPath == '/dev/null':
            try:
                os.remove(document.filePath())
            except (OSError, IOError) as ex:
                QMessageBox.critical(core.mainWindow(), 'Not this time', 'The OS thinks it needs the file')
            else:
                core.workspace().closeDocument(document)
        else:
            try:
                os.rename(document.filePath(), newPath)
            except (OSError, IOError) as ex:
                QMessageBox.critical(core.mainWindow(), 'Failed to rename file', str(ex))
            else:
                document.setFilePath(newPath)
                document.saveFile()
Example #34
0
    def _onRename(self):
        """Handler for File->File System->Rename"""
        document = core.workspace().currentDocument()
        if document.qutepart.document().isModified() or \
           document.isExternallyModified() or \
           document.isExternallyRemoved() or \
           document.isNeverSaved():
            QMessageBox.warning(core.mainWindow(), 'Rename file', 'Save the file before renaming')
            return

        newPath, ok = QInputDialog.getText(core.mainWindow(), 'Rename file', 'New file name', text=document.filePath())
        if not ok:
            return

        if newPath == document.filePath():
            return

        if newPath == '/dev/null':
            try:
                os.remove(document.filePath())
            except (OSError, IOError) as ex:
                QMessageBox.critical(core.mainWindow(), 'Not this time', 'The OS thinks it needs the file')
            else:
                core.workspace().closeDocument(document)
        else:
            try:
                os.rename(document.filePath(), newPath)
            except (OSError, IOError) as ex:
                QMessageBox.critical(core.mainWindow(), 'Failed to rename file', str(ex))
            else:
                document.setFilePath(newPath)
                document.saveFile()
Example #35
0
    def renameSnippet(self):

        window = self.tabWidget.currentWidget().mdi.activeSubWindow()
        title, ok = QInputDialog.getText(self, u"Tytuł", u"Wpisz nowy tytuł dla okna:")

        if ok and title:
            window.setWindowTitle(unicode(title))
Example #36
0
def insert_debugging_prints(editorWidget):
    cursor = editorWidget.textCursor()
    if cursor.hasSelection():
        result = str(QInputDialog.getText(editorWidget,
            editorWidget.tr("Print Text"),
            editorWidget.tr("Insert a Text to use in the Print or "
                            "leave empty to just print numbers:"))[0])
        print_text = ""
        if result:
            print_text = "%s: " % result
        #begin Undo feature
        cursor.beginEditBlock()
        start = editorWidget.document().findBlock(
            cursor.selectionStart()).firstLineNumber()
        end = editorWidget.document().findBlock(
            cursor.selectionEnd()).firstLineNumber()
        lines = end - start
        for i in range(lines):
            position = editorWidget.document().findBlockByLineNumber(
                start + (i * 2)).position()
            cursor.setPosition(position)
            indentation = get_indentation(cursor.block().text())
            cursor.movePosition(QTextCursor.EndOfLine)
            cursor.insertText("\n%sprint('%s%i')" % (
                indentation, print_text, i))
        #end Undo feature
        cursor.endEditBlock()
Example #37
0
 def _copy_file(self):
     #get the selected QTreeWidgetItem
     item = self.currentItem()
     if item.parent() is None:
         pathForFile = item.path
     else:
         pathForFile = os.path.join(item.path, item.text(0))
     pathProjects = [p.path for p in self.get_open_projects()]
     addToProject = ui_tools.AddToProject(pathProjects, self)
     addToProject.setWindowTitle(self.tr("Copy File to"))
     addToProject.exec_()
     if not addToProject.pathSelected:
         return
     name = QInputDialog.getText(self,
                                 self.tr("Copy File"),
                                 self.tr("File Name:"),
                                 text=item.text(0))[0]
     if not name:
         QMessageBox.information(
             self, self.tr("Invalid Name"),
             self.tr("The file name is empty, please enter a name"))
         return
     path = file_manager.create_path(addToProject.pathSelected, name)
     try:
         content = file_manager.read_file_content(pathForFile)
         path = file_manager.store_file_content(path, content, newFile=True)
         self.add_existing_file(path)
     except file_manager.NinjaFileExistsException as ex:
         QMessageBox.information(
             self, self.tr("File Already Exists"),
             self.tr("Invalid Path: the file '%s' already exists." %
                     ex.filename))
Example #38
0
File: qtutil.py Project: eteq/glue
def edit_layer_label(layer):
    """ Interactively edit a layer's label """
    dialog = QInputDialog()
    label, isok = dialog.getText(None, 'New Label:', 'New Label:',
                                 text=layer.label)
    if isok and str(label) != layer.label:
        layer.label = str(label)
Example #39
0
def newfoldername(basetext, basefolder, formtype, alreadyexists=False):
    message = "Please enter a new folder name for the {}".format(formtype)
    if alreadyexists:
        logger.log("Folder {} already exists.")
        message += "<br> {} folder already exists please select a new one.".format(
            formtype)

    name, ok = QInputDialog.getText(None,
                                    "New {} folder name".format(formtype),
                                    message)
    if not ok:
        raise ValueError

    if not name:
        return "{}_{}".format(basetext, datetime.today().strftime('%d%m%y%f'))
    else:
        name = name.replace(" ", "_")

    if os.path.exists(os.path.join(basefolder, name)):
        return newfoldername(basetext,
                             basefolder,
                             formtype,
                             alreadyexists=True)

    return name
Example #40
0
    def _rename_file(self):
        item = self.currentItem()
        if item.parent() is None:
            pathForFile = item.path
        else:
            pathForFile = os.path.join(item.path, item.text(0))
        result = QInputDialog.getText(self,
                                      self.tr("Rename File"),
                                      self.tr("Enter New File Name:"),
                                      text=item.text(0))
        fileName = result[0]

        if result[1] and fileName.strip() != '':
            fileName = os.path.join(file_manager.get_folder(pathForFile),
                                    fileName)
            if pathForFile == fileName:
                return
            try:
                fileName = file_manager.rename_file(pathForFile, fileName)
                name = file_manager.get_basename(fileName)
                mainContainer = main_container.MainContainer()
                if mainContainer.is_open(pathForFile):
                    mainContainer.change_open_tab_name(pathForFile, fileName)
                subitem = ProjectItem(item.parent(), name,
                                      file_manager.get_folder(fileName))
                subitem.setToolTip(0, name)
                subitem.setIcon(0, self._get_file_icon(name))
                index = item.parent().indexOfChild(item)
                subitem.parent().takeChild(index)
            except file_manager.NinjaFileExistsException as ex:
                QMessageBox.information(
                    self, self.tr("File Already Exists"),
                    self.tr("Invalid Path: the file '%s' already exists." %
                            ex.filename))
Example #41
0
 def _add_file_to_project(self, path):
     """Add the file for 'path' in the project the user choose here."""
     if self._active_project:
         pathProject = [self._active_project.project]
         addToProject = add_to_project.AddToProject(pathProject, self)
         addToProject.exec_()
         if not addToProject.pathSelected:
             return
         main_container = IDE.get_service('main_container')
         if not main_container:
             return
         editorWidget = main_container.get_current_editor()
         if not editorWidget.file_path:
             name = QInputDialog.getText(
                 None, translations.TR_ADD_FILE_TO_PROJECT,
                 translations.TR_FILENAME + ": ")[0]
             if not name:
                 QMessageBox.information(
                     self, translations.TR_INVALID_FILENAME,
                     translations.TR_INVALID_FILENAME_ENTER_A_FILENAME)
                 return
         else:
             name = file_manager.get_basename(editorWidget.file_path)
         new_path = file_manager.create_path(addToProject.pathSelected,
                                             name)
         ide_srv = IDE.get_service("ide")
         old_file = ide_srv.get_or_create_nfile(path)
         new_file = old_file.save(editorWidget.get_text(), new_path)
         #FIXME: Make this file replace the original in the open tab
     else:
         pass
Example #42
0
    def db_index_changed(self, index):
        if self._loading_db_combo:
            return
        db_name = str(self.db_combo.itemData(index).toPyObject())
        if db_name == self.model.current_db:
            return

        self.model.save()

        if db_name:
            self.model.load(db_name)
            self.dwim_after_load()
            return

        db_name, ok = QInputDialog.getText(
            self, "New Database", "Enter database name")
        if ok:
            if not re.match(r"^[\w-]+$", db_name):
                QMessageBox.critical(
                    self, "Error",
                    "Database name must contain only the following chars: "
                    "A-Z a-z 0-9 _ -")
                ok = False
            elif db_name in self.model.databases:
                QMessageBox.critical(
                    self, "Error", "Database '%s' already exists" % db_name)
                ok = False
        if not ok:
            self.db_combo.setCurrentIndex(
                self.model.databases.index(self.model.current_db))
            return
        db_name = str(db_name) + ".org"
        self.model.load(db_name)
        self.populate_db_combo()
        self.dwim_after_load()
Example #43
0
 def javaScriptPrompt(self, frame, msg, default):
     if USING_LIVE_ISO: return True, "live"
     res, ok = QInputDialog.getText(self.parent(),
                                    self.tr("MOD-App Prompt"),
                                    msg,
                                    QLineEdit.Normal, default)
     return ok, res
 def _copy_file(self):
     #get the selected QTreeWidgetItem
     path = self.model().filePath(self.currentIndex())
     name = file_manager.get_basename(path)
     global projectsColumn
     pathProjects = [p.path for p in projectsColumn.projects]
     addToProject = add_to_project.AddToProject(pathProjects, self)
     addToProject.setWindowTitle(self.tr("Copy File to"))
     addToProject.exec_()
     if not addToProject.pathSelected:
         return
     name = QInputDialog.getText(self, self.tr("Copy File"),
         self.tr("File Name:"), text=name)[0]
     if not name:
         QMessageBox.information(self, self.tr("Invalid Name"),
             self.tr("The file name is empty, please enter a name"))
         return
     path = file_manager.create_path(addToProject.pathSelected, name)
     try:
         content = file_manager.read_file_content(path)
         path = file_manager.store_file_content(path, content, newFile=True)
     except file_manager.NinjaFileExistsException as ex:
             QMessageBox.information(self, self.tr("File Already Exists"),
                 (self.tr("Invalid Path: the file '%s' already exists.") %
                     ex.filename))
Example #45
0
    def _add_new_file(self):
        item = self.currentItem()
        if item.parent() is None:
            pathForFile = item.path
        else:
            pathForFile = os.path.join(item.path, item.text(0))
        result = QInputDialog.getText(self, self.tr("New File"),
            self.tr("Enter the File Name:"))
        fileName = result[0]

        if result[1] and fileName.strip() != '':
            try:
                fileName = os.path.join(pathForFile, fileName)
                fileName = file_manager.store_file_content(
                    fileName, '', newFile=True)
                name = file_manager.get_basename(fileName)
                subitem = ProjectItem(item, name, pathForFile)
                subitem.setToolTip(0, name)
                subitem.setIcon(0, self._get_file_icon(name))
                mainContainer = main_container.MainContainer()
                mainContainer.open_file(fileName)
            except file_manager.NinjaFileExistsException as ex:
                QMessageBox.information(self, self.tr("File Already Exists"),
                    self.tr("Invalid Path: the file '%s' already exists." %
                        ex.filename))
Example #46
0
 def createView(self):
     name, ok = QInputDialog.getText(None, "View name", "View name")
     if ok:
         try:
             self.db.connector.createSpatialView(name, self._getSqlQuery())
         except BaseError as e:
             DlgDbError.showError(e, self)
Example #47
0
 def _copy_file(self):
     #get the selected QTreeWidgetItem
     item = self.currentItem()
     if item.parent() is None:
         pathForFile = item.path
     else:
         pathForFile = os.path.join(item.path, item.text(0))
     pathProjects = [p.path for p in self.get_open_projects()]
     addToProject = ui_tools.AddToProject(pathProjects, self)
     addToProject.setWindowTitle(self.tr("Copy File to"))
     addToProject.exec_()
     if not addToProject.pathSelected:
         return
     name = QInputDialog.getText(self, self.tr("Copy File"),
         self.tr("File Name:"), text=item.text(0))[0]
     if not name:
         QMessageBox.information(self, self.tr("Invalid Name"),
             self.tr("The file name is empty, please enter a name"))
         return
     path = file_manager.create_path(addToProject.pathSelected, name)
     try:
         content = file_manager.read_file_content(pathForFile)
         path = file_manager.store_file_content(path, content, newFile=True)
         self.add_existing_file(path)
     except file_manager.NinjaFileExistsException as ex:
             QMessageBox.information(self, self.tr("File Already Exists"),
                 self.tr("Invalid Path: the file '%s' already exists." %
                     ex.filename))
Example #48
0
    def on_press(self, event):
        if event.button == 3 and self.artist is None and not event.xdata is None and not event.ydata is None:
            label, success = QInputDialog.getText(self.plot_view, "New label", "Enter label:")

            if success and not str(label).strip() == "":
                self.plot_view.annotate(str(label), event.xdata, event.ydata)
                self.plot_view.draw()
Example #49
0
    def callback_MocapRowEntry(self):
        # https://stackoverflow.com/questions/7907928/openpyxl-check-for-empty-
        global item
        global description
        global SuffixCount
        global rowCountIndex

        sheet = wb.get_sheet_by_name('Project 1')

        sheet['A'+str(rowCountIndex)].value = str(SuffixCount)
        sheet['B'+str(rowCountIndex)].value = 'MVN_Take_'+ str(SuffixCount)
        sheet['C'+str(rowCountIndex)].value = 'FBX_'+str(SuffixCount)+'.fbx'

        # for selecting which level the mocap was captured on #
        items = ('No-Level', 'Single-Level', 'Multi-Level')
        item, ok = QInputDialog.getItem(self, "Select Which Level", "Capture-Type", items, 0, False)
        if ok and item:
            sheet['D'+str(rowCountIndex)].value = str(item)

        # for entering the description for the mocap take #
        description, ok = QInputDialog.getText(self, "Take Description", "Enter a Description for this Take:")
        if ok and description:
            sheet['E'+str(rowCountIndex)].value = str(description)
            self.le_outputfield.setText('Entry '+ str(SuffixCount)+' Entered!')
        print('|| Entry: ' + str(SuffixCount) + ' | Level-Type: ' + str(item) + ' | Description: ' + str(description) + ' ||')

        SaveFile('template.xlsx')
        SuffixCount += 1
        rowCountIndex += 1
Example #50
0
 def __call__(self):
     password, ok = QInputDialog.getText(None,
         '%s request' % self.value.label,
         'Please enter %s for %s' % (self.value.label,
                                     self.backend_name),
                                         QLineEdit.Password)
     return password
Example #51
0
 def on_importGoogleContactsButton_clicked(self):
     googleUsername, ok = QInputDialog.getText(
         self,
         'Google Username',
         'Enter your Google username/email',
         text=getConfig('googleUsername', ''))
     if not ok:
         return
     googlePassword, ok = QInputDialog.getText(self,
                                               'Google Password',
                                               'Enter your Google password',
                                               mode=QLineEdit.Password)
     if not ok:
         return
     setConfig('googleUsername', googleUsername)
     self.import_google_contacts_signal.emit(googleUsername, googlePassword)
Example #52
0
 def __call__(self):
     password, ok = QInputDialog.getText(None,
         '%s request' % self.value.label,
         'Please enter %s for %s' % (self.value.label,
                                     self.backend_name),
                                         QLineEdit.Password)
     return password
Example #53
0
    def new_item(self, widget):
        loop_ok = False
        dial_msg = None
        proposition = ""

        while not loop_ok:

            if not dial_msg:
                dial_msg = "Enter a name for %s" % self._new_item_name

            name, dial_ok = QInputDialog.getText(widget, self._new_item_title, 
                    dial_msg, text=proposition)

            if not dial_ok:
                # user cancelled
                return

            name = unicode(name).strip()

            if not name:
                dial_msg = "Please enter a valid name (empty values are refused)"
                proposition = ""
                continue

            item, dial_msg, proposition = self._backend_valider(name)

            if item:
                loop_ok = True

        self._add_to_model(item)
Example #54
0
    def _rename_file(self):
        item = self.currentItem()
        if item.parent() is None:
            pathForFile = item.path
        else:
            pathForFile = os.path.join(item.path, item.text(0))
        result = QInputDialog.getText(self, self.tr("Rename File"),
            self.tr("Enter New File Name:"), text=item.text(0))
        fileName = result[0]

        if result[1] and fileName.strip() != '':
            fileName = os.path.join(
                file_manager.get_folder(pathForFile), fileName)
            if pathForFile == fileName:
                return
            try:
                fileName = file_manager.rename_file(pathForFile, fileName)
                name = file_manager.get_basename(fileName)
                mainContainer = main_container.MainContainer()
                if mainContainer.is_open(pathForFile):
                    mainContainer.change_open_tab_name(pathForFile, fileName)
                subitem = ProjectItem(item.parent(), name,
                    file_manager.get_folder(fileName))
                subitem.setToolTip(0, name)
                subitem.setIcon(0, self._get_file_icon(name))
                index = item.parent().indexOfChild(item)
                subitem.parent().takeChild(index)
            except file_manager.NinjaFileExistsException as ex:
                QMessageBox.information(self, self.tr("File Already Exists"),
                    self.tr("Invalid Path: the file '%s' already exists." %
                        ex.filename))
Example #55
0
 def _add_file_to_project(self, path):
     """Add the file for 'path' in the project the user choose here."""
     pathProject = [self.ide.explorer.get_actual_project()]
     addToProject = ui_tools.AddToProject(pathProject, self.ide)
     addToProject.exec_()
     if not addToProject.pathSelected:
         return
     editorWidget = self.ide.mainContainer.get_actual_editor()
     if not editorWidget.ID:
         name = unicode(QInputDialog.getText(None,
             self.tr("Add File To Project"), self.tr("File Name:"))[0])
         if not name:
             QMessageBox.information(self, self.tr("Invalid Name"),
                 self.tr("The file name is empty, please enter a name"))
             return
     else:
         name = file_manager.get_basename(editorWidget.ID)
     path = file_manager.create_path(
         unicode(addToProject.pathSelected), name)
     try:
         path = file_manager.store_file_content(
             path, editorWidget.get_text(), newFile=True)
         editorWidget.ID = path
         self.ide.explorer.add_existing_file(path)
         self.ide.change_window_title(path)
         name = file_manager.get_basename(path)
         self.ide.mainContainer.actualTab.setTabText(
             self.ide.mainContainer.actualTab.currentIndex(), name)
         editorWidget._file_saved()
     except file_manager.NinjaFileExistsException, ex:
         QMessageBox.information(self, self.tr("File Already Exists"),
             self.tr("Invalid Path: the file '%s' already exists." % \
                 ex.filename))
    def save_sensor(self):
        """
            save single sensor,
            create a new one or overwrite existing one
        """
        if self.overFilter.isChecked():
            self.oat.save_to_sqlite(config.db_path, overwrite=True)
            return True
        else:
            new_sensor = copy.deepcopy(self.oat)

            new_name, ok = QInputDialog.getText(
                self, self.tr('Sensor name'),
                self.tr('Enter a new sensor name:'))

            new_sensor.name = new_name
            if not ok:
                return False
            try:
                new_sensor.save_to_sqlite(config.db_path)
            except IOError as _:
                QMessageBox.about(self, "Error",
                                  "Sensor name already exists...")
                return False
            return True
Example #57
0
 def rename_file(self, fname):
     """Rename file"""
     path, valid = QInputDialog.getText(self, _('Rename'),
                                        _('New name:'), QLineEdit.Normal,
                                        osp.basename(fname))
     if valid:
         path = osp.join(osp.dirname(fname), unicode(path))
         if path == fname:
             return
         if osp.exists(path):
             if QMessageBox.warning(
                     self, _("Rename"),
                     _("Do you really want to rename <b>%s</b> and "
                       "overwrite the existing file <b>%s</b>?") %
                 (osp.basename(fname), osp.basename(path)),
                     QMessageBox.Yes | QMessageBox.No) == QMessageBox.No:
                 return
         try:
             misc.rename_file(fname, path)
             self.parent_widget.emit( \
                  SIGNAL("renamed(QString,QString)"), fname, path)
             return path
         except EnvironmentError, error:
             QMessageBox.critical(
                 self, _("Rename"),
                 _("<b>Unable to rename file <i>%s</i></b>"
                   "<br><br>Error message:<br>%s") %
                 (osp.basename(fname), unicode(error)))
Example #58
0
 def createView(self):
     name, ok = QInputDialog.getText(None, "View name", "View name")
     if ok:
         try:
             self.db.connector.createSpatialView(name, self._getSqlQuery())
         except BaseError as e:
             DlgDbError.showError(e, self)
Example #59
0
 def __init__(self, **kwargs):
     super(rendertextas, self).__init__(**kwargs)
     qtext, ok = QInputDialog.getText(self.parent, 'Render Text', 'Text:')
     if ok:
         self.text = str(qtext)
     else:
         self.text = 'hello'