當前位置: 首頁>>代碼示例>>Python>>正文


Python QtCore.QDir類代碼示例

本文整理匯總了Python中PySide.QtCore.QDir的典型用法代碼示例。如果您正苦於以下問題:Python QDir類的具體用法?Python QDir怎麽用?Python QDir使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了QDir類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: getProjectFile

def getProjectFile(filename=None):
    d = QDir()
    d.cd(app.manifest.get('gendir',"bin")) # cd into the directory we generate to
    if filename is None:    # we want just the generation directory
        return d.absolutePath()  # so return the absolute path   
    else:                   # the only other option is a file in the gendir
        return d.absoluteFilePath(filename) # so give the absolute path to that file
開發者ID:kaijfox,項目名稱:captan,代碼行數:7,代碼來源:main.py

示例2: render

    def render(self, fileName, width, height):
        self.setViewportSize(QSize(width, height))

        fileInfo = QFileInfo(fileName)
        dir = QDir()
        dir.mkpath(fileInfo.absolutePath())
        viewportSize = self.viewportSize()
        pageSize = self.mainFrame().contentsSize()
        if pageSize.isEmpty():
            return False

        buffer = QImage(pageSize, QImage.Format_ARGB32)
        buffer.fill(qRgba(255, 255, 255, 0))
        p =  QPainter(buffer)

        p.setRenderHint( QPainter.Antialiasing,          True)
        p.setRenderHint( QPainter.TextAntialiasing,      True)
        p.setRenderHint( QPainter.SmoothPixmapTransform, True)

        self.setViewportSize(pageSize)
        self.mainFrame().render(p)
        p.end()

        self.setViewportSize(viewportSize)

        return buffer.save(fileName)
開發者ID:pborky,項目名稱:webkit-scraper,代碼行數:26,代碼來源:webkit_scraper.py

示例3: __init__

    def __init__(self, parent=None):
        QWidget.__init__(self, parent)
        self.setupUi(self)

        self.settings = QSettings(QSettings.IniFormat, QSettings.UserScope, COMPANY, APPNAME)
        self.restoreGeometry(self.settings.value(self.__class__.__name__))

        self.images = []

        if len(sys.argv) > 1:
            d = QDir(path=sys.argv[1])
        else:
            d = QDir(path=QFileDialog.getExistingDirectory())

        d.setNameFilters(['*.png'])
        d.setFilter(QDir.Files or QDir.NoDotAndDotDot)

        d = QDirIterator(d)

        images = []

        while d.hasNext():
            images.append(d.next())

        for i in images:
            print i

        self.images = [QImage(i) for i in images]
        self.images += [crop_image_from_file(i, 50)[0] for i in images]
開發者ID:Ingener74,項目名稱:Silly-Crossbow,代碼行數:29,代碼來源:AberrantTiger.py

示例4: __init__

    def __init__(self, parent=None, common_name=None, image=None):
        QtGui.QDialog.__init__(self, parent)
        self.ui = Ui_Form()
        self.ui.setupUi(self)
        types = controller.get_types()
        self.directory = QDir.root()
        self.display = QGraphicsView()
        self.ui.scrollArea.setWidget(self.display)
        for tipo in types:
            self.ui.typeBox.addItem(tipo["nombre"], tipo["id_tipo"])

        if common_name is None:
            self.ui.btn_done.clicked.connect(self.add)
            if image is None:
                self.ui.image.setPlainText(image)
        else:
            self.setWindowTitle(u"Editar animal")
            self.common = common_name
            animal_data = controller.get_animal(common_name)
            self.ui.common_name.setPlainText(animal_data["nombre_comun"])
            self.ui.cientific_name.setText(animal_data["nombre_cientifico"])
            self.ui.data.setText(animal_data["datos"])
            tipo = self.ui.typeBox.currentText()
            id_type = controller_form.get_id_type(tipo)

            id_animal = controller_form.get_id_animal(common_name)
            self.image = controller_form.get_image(id_animal)
            if self.image:
                self.path = QDir.currentPath() + "/images/" + self.image[0] + self.image[1]
                self.ui.image.setPlainText(self.path)
                Ifile = QFileInfo(self.path)
                pixImage = controller_form.get_root_image(self.path)
                item = QGraphicsPixmapItem(pixImage.scaled(100,100))
                scene = QGraphicsScene()
                scene.addItem(item)
                self.display.setScene(scene)
                self.ui.image.setPlainText(self.path)
            else:
                noimage = controller_form.no_image()
                item = QGraphicsPixmapItem(noimage.scaled(100,100))
                scene = QGraphicsScene()
                scene.addItem(item)
                self.display.setScene(scene)
                scene = QGraphicsScene()
                scene.addItem(item)
                self.display.setScene(scene)
                self.path = ""
                self.ui.image.setPlainText(self.path)

            self.ui.btn_done.clicked.connect(self.edit)
        self.ui.btn_delete.clicked.connect(self.delete)
        self.ui.btn_open.clicked.connect(self.open)
        self.ui.btn_cancel.clicked.connect(self.cancel)
開發者ID:Dalanth,項目名稱:FinalINFO175,代碼行數:53,代碼來源:view_form.py

示例5: parse_interface

def parse_interface(interfacename):
    tree = xmlparse("views" + QDir.separator() + interfacename + ".xml").getroot() # get the tree
    Compiler.current_interfacename = interfacename # set the current interfacename
    imported = [] # this is the list of interfaces to parse after this one
    
    Compiler.code += "from PySide.QtGui import *\nfrom PySide.QtCore import *\n" # import PySide
    Compiler.code += "from oxide.widgets.all import *\n" # import Oxide
    if interfacename == Compiler.start: # if this is the start interface, create a QApplication
        Compiler.code += "import sys\n"         # using sys.argv,
        Compiler.code += "app = OxideApplication(sys.argv)\n" # create a QApplication
        
    add_util_funcs() # add the utility functions
    
    add_model(interfacename,"__main__") # now add the model code to the output file
    
    for element in tree: # iterate through the elements in the tree
        if element.tag.lower() == "animations": # here we handle the special 'animations' tag
            Compiler.to_be_own_class = False # there is no way that we're in the resources tag here
            for animation in element: # go through each animation
                parse_animation(animation) # and parse it
        
        elif element.tag.lower() == "window": # here we handle the window
            Compiler.to_be_own_class = False # there is no way that we're in the resources tag here
            parse_toplevel(element)       # using parse_window
            
        elif element.tag.lower() == "resources":
            Compiler.to_be_own_class = True
            
            for child in element:
                Compiler.direct_resources_child = True
                parse_abstract_element(child)
                Compiler.direct_resources_child = False
                    
            Compiler.direct_resources_child = False
            
        elif element.tag.lower() == "import":
            Compiler.code += "import " + element.get('interface') + "\n"
            imported.append(element.get('interface'))
                    
    if interfacename == Compiler.start: # to finish up, if this is the start file
        Compiler.code += "sys.exit(app.exec_())\n" # run the application
    
    # now it has come time to put the code on the filesystem        
    if not QDir("bin").exists(): # if the 'bin' folder doesn't exist
        QDir().mkdir("bin")     # create it
    interfacefile = open(Compiler.gendir + QDir.separator() + interfacename + ".py", 'w')
    interfacefile.write(Compiler.code) # write Compiler.code to the file
    
    Compiler.code = "" # reset Compiler.code
    
    for interface in imported:
        parse_interface(interface)
開發者ID:kaijfox,項目名稱:oxide,代碼行數:52,代碼來源:main.py

示例6: onBrowseClicked

 def onBrowseClicked(self):
     """Slot. Called when the user clicks on the `browseButton` button"""
     
     # Presents the user with a native directory selector window
     localdir = QFileDialog.getExistingDirectory()
     localdir = QDir.fromNativeSeparators(localdir)
     if len(localdir) > 0:
         # If `localdir`'s value is good, store it using a `QSettings` object
         # and triggers a sync request.
         # Careful with '\' separators on Windows.
         localdir = QDir.toNativeSeparators(localdir)
         get_settings().setValue(SettingsKeys['localdir'], localdir)
         self.localdirEdit.setText(localdir)
開發者ID:ShareByLink,項目名稱:iqbox-ftp,代碼行數:13,代碼來源:views.py

示例7: processModels

def processModels():
    for filename in QDir("models").entryList(QDir.Files):
        out = ""
        for line in open("models" + QDir.separator() + filename).readlines():
            try:
                if not line.strip()[0] == "#":
                    if line[:8] == "from " + app.manifest.get('gendir',"bin"): out += "# " + line;
                    else: out += line
                else: out += line
            except IndexError: # it must have just been a newline (lstrip makes it ""), so there is no index 0
                out += "\n"
        f = open("models" + QDir.separator() + filename, 'w')
        f.write(out)
        f.close()
開發者ID:kaijfox,項目名稱:captan,代碼行數:14,代碼來源:main.py

示例8: on_change_root_path

    def on_change_root_path(self, current_path):
        if current_path == SOURCEIMAGES_TAG:
            current_path = os.path.join(
                cmds.workspace(query=True, rootDirectory=True),
                cmds.workspace(fileRuleEntry='sourceImages')
            )

        self.files_model.setRootPath(current_path)
        self.files_list.setRootIndex(self.files_model.index(current_path))
        if self.path_edit:
            self.path_edit.setText(current_path)

        if self.parent_folder_btn:
            current_dir = QDir(current_path)
            self.parent_folder_btn.setEnabled(current_dir.cdUp())
開發者ID:Bioeden,項目名稱:dbMayaTextureToolkit,代碼行數:15,代碼來源:mttFilterFileDialog.py

示例9: getConfigStyleDict

def getConfigStyleDict():
    styledict = {} #initialize the new styledict
    
    # get the tree from the style.xml file
    tree = xmlparse("config" + QDir.separator() + "style.xml").getroot()
    
    for styletype in tree: # iterate over the types of widget
        styletype_key = styletype.tag.lower() if styletype.tag.lower().startswith("default-") else styletype.tag
        styledict[styletype_key] = {} # create a new dictionary for the style-type
        for state in States:
            styledict[styletype_key][state] = {}
        styledict[styletype_key]['normal'] = {}
        styledict[styletype_key]['durations'] = {}

        for styledef_or_statedef in styletype:
            if styledef_or_statedef.tag.lower() in States:
                for styledef in styledef_or_statedef:
                    styledict[styletype_key][styledef_or_statedef.tag.lower()][styledef.tag.lower()] = getValue(styledef)
            elif styledef_or_statedef.tag.lower() in StateTransitions:
                if styledef_or_statedef.get('time') is None:
                    raise StyleError(styletype.tag + " => " + styledef_or_statedef.tag + " must have 'time' attribute")
                styledict[styletype_key]['durations'][styledef_or_statedef.tag.lower()] = int(styledef_or_statedef.get('time'))
            else:
                for state in States:
                    styledict[styletype_key][state][styledef_or_statedef.tag.lower()] = getValue(styledef_or_statedef)
                styledict[styletype_key]['normal'][styledef_or_statedef.tag.lower()] = getValue(styledef_or_statedef)
        
    return styledict
開發者ID:kaijfox,項目名稱:oxide,代碼行數:28,代碼來源:style.py

示例10: create_folder

 def create_folder(self):
 	"""
     Crea carpeta de imagenes si no existe
     """
     self.directory = QDir.root()
     if not os.path.exists(self.directory.currentPath()+"/images"):
         os.makedirs(self.directory.currentPath()+"/images")
開發者ID:Dalanth,項目名稱:FinalINFO175,代碼行數:7,代碼來源:main.py

示例11: fileOpen

 def fileOpen(self, lineEdit, filters):
     openFile = QFileDialog.getOpenFileName(self, "Find Files", QDir.currentPath(), filters="*." + filters)
     uiDebug(openFile)
     if openFile != None :
         lineEdit.setText(openFile[0])
         self.setUserConfig()
         self.showConfig()
開發者ID:xiaomdong,項目名稱:xdIm,代碼行數:7,代碼來源:serverManager.py

示例12: no_image

def no_image():
    """
    Si no existe imagen carga una por defecto
    """
    path = QDir.currentPath() + "/images/noimage.jpg"
    pixMap = QPixmap(path)
    return pixMap
開發者ID:Dalanth,項目名稱:FinalINFO175,代碼行數:7,代碼來源:controller_form.py

示例13: localFromServer

 def localFromServer(self, serverpath):
     # Removing leading '/' so `os.path.join` doesn't treat
     # `localpath` as an absolute path
     localpath = serverpath[1:] if serverpath.startswith('/') else serverpath
     localpath = QDir.toNativeSeparators(localpath)
     localpath = os.path.join(self.localdir, localpath)
     
     return localpath
開發者ID:ShareByLink,項目名稱:iqbox-ftp,代碼行數:8,代碼來源:watchers.py

示例14: _fetchChildren

    def _fetchChildren(self):
        '''Fetch and return new child items.'''
        children = []
        for entry in QDir.drives():
            path = os.path.normpath(entry.canonicalFilePath())
            children.append(Mount(path))

        return children
開發者ID:EfestoLab,項目名稱:riffle,代碼行數:8,代碼來源:model.py

示例15: loadConfig

 def loadConfig(self):
     '''加載配置文件'''
     configfile = QFileDialog.getOpenFileName(self, "Load Config File", QDir.currentPath(), filter="*.cfg")
     uiDebug(configfile)
     if configfile != None :
         self.readConfig(configfile)
         self.stopServer()
         self.startServer()
         self.showConfig()
     uiDebug("loadConfig") 
開發者ID:xiaomdong,項目名稱:xdIm,代碼行數:10,代碼來源:serverManager.py


注:本文中的PySide.QtCore.QDir類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。